1
0

Merge branch 'master' into globals

Conflicts:
	SetFlags.cmake
This commit is contained in:
Tycho 2014-03-15 06:53:07 -07:00
commit 683e2f4840
11 changed files with 146 additions and 40 deletions

6
MCServer/.gitignore vendored
View File

@ -19,10 +19,8 @@ schematics
*.pdb *.pdb
memdump* memdump*
*.grab *.grab
Galleries.cfg *.cfg
Galleries.example.cfg *.sqlite
Galleries.sqlite
ProtectionAreas.sqlite
helgrind.log helgrind.log
valgrind.log valgrind.log
motd.txt motd.txt

View File

@ -53,7 +53,7 @@ return
{ {
Desc = [[ Desc = [[
cCuboid offers some native support for integral-boundary cuboids. A cuboid internally consists of cCuboid offers some native support for integral-boundary cuboids. A cuboid internally consists of
two {{Vector3i}}s. By default the cuboid doesn't make any assumptions about the defining points, two {{Vector3i}}-s. By default the cuboid doesn't make any assumptions about the defining points,
but for most of the operations in the cCuboid class, the p1 member variable is expected to be the but for most of the operations in the cCuboid class, the p1 member variable is expected to be the
minima and the p2 variable the maxima. The Sort() function guarantees this condition.</p> minima and the p2 variable the maxima. The Sort() function guarantees this condition.</p>
<p> <p>
@ -63,12 +63,17 @@ return
{ {
constructor = constructor =
{ {
{ Params = "OtheCuboid", Return = "cCuboid", Notes = "Creates a new Cuboid object as a copy of OtherCuboid" }, { Params = "", Return = "cCuboid", Notes = "Creates a new Cuboid object with all-zero coords" },
{ Params = "OtherCuboid", Return = "cCuboid", Notes = "Creates a new Cuboid object as a copy of OtherCuboid" },
{ Params = "{{Vector3i|Point1}}, {{Vector3i|Point2}}", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." }, { Params = "{{Vector3i|Point1}}, {{Vector3i|Point2}}", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." },
{ Params = "X, Y, Z", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified point as both its corners (the cuboid has a size of 1 in each direction)." }, { Params = "X, Y, Z", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified point as both its corners (the cuboid has a size of 1 in each direction)." },
{ Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." }, { Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." },
}, },
Assign = { Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "", Notes = "Assigns all the coords stored in the cuboid. Sort-state is ignored." }, Assign =
{
{ Params = "SrcCuboid", Return = "", Notes = "Copies all the coords from the src cuboid to this cuboid. Sort-state is ignored." },
{ Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "", Notes = "Assigns all the coords to the specified values. Sort-state is ignored." },
},
ClampX = { Params = "MinX, MaxX", Return = "", Notes = "Clamps both X coords into the range provided. Sortedness-agnostic." }, ClampX = { Params = "MinX, MaxX", Return = "", Notes = "Clamps both X coords into the range provided. Sortedness-agnostic." },
ClampY = { Params = "MinY, MaxY", Return = "", Notes = "Clamps both Y coords into the range provided. Sortedness-agnostic." }, ClampY = { Params = "MinY, MaxY", Return = "", Notes = "Clamps both Y coords into the range provided. Sortedness-agnostic." },
ClampZ = { Params = "MinZ, MaxZ", Return = "", Notes = "Clamps both Z coords into the range provided. Sortedness-agnostic." }, ClampZ = { Params = "MinZ, MaxZ", Return = "", Notes = "Clamps both Z coords into the range provided. Sortedness-agnostic." },

View File

@ -9,9 +9,56 @@
-- Global variables: -- Global variables:
g_Plugin = nil; g_Plugin = nil;
g_PluginFolder = ""; g_PluginFolder = "";
g_TrackedPages = {}; -- List of tracked pages, to be checked later whether they exist. Each item is an array of referring pagenames.
g_Stats = -- Statistics about the documentation
{
function Initialize(Plugin)
g_Plugin = Plugin;
g_PluginFolder = Plugin:GetLocalFolder();
LOG("Initialising " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
cPluginManager:BindConsoleCommand("api", HandleCmdApi, "Dumps the Lua API docs into the API/ subfolder")
g_Plugin:AddWebTab("APIDump", HandleWebAdminDump)
-- TODO: Add a WebAdmin tab that has a Dump button
return true
end
function HandleCmdApi(a_Split)
DumpApi()
return true
end
function DumpApi()
LOG("Dumping the API...")
-- Load the API descriptions from the Classes and Hooks subfolders:
-- This needs to be done each time the command is invoked because the export modifies the tables' contents
dofile(g_PluginFolder .. "/APIDesc.lua")
if (g_APIDesc.Classes == nil) then
g_APIDesc.Classes = {};
end
if (g_APIDesc.Hooks == nil) then
g_APIDesc.Hooks = {};
end
LoadAPIFiles("/Classes/", g_APIDesc.Classes);
LoadAPIFiles("/Hooks/", g_APIDesc.Hooks);
-- Reset the stats:
g_TrackedPages = {}; -- List of tracked pages, to be checked later whether they exist. Each item is an array of referring pagenames.
g_Stats = -- Statistics about the documentation
{
NumTotalClasses = 0, NumTotalClasses = 0,
NumUndocumentedClasses = 0, NumUndocumentedClasses = 0,
NumTotalFunctions = 0, NumTotalFunctions = 0,
@ -24,32 +71,7 @@ g_Stats = -- Statistics about the documentation
NumUndocumentedHooks = 0, NumUndocumentedHooks = 0,
NumTrackedLinks = 0, NumTrackedLinks = 0,
NumInvalidLinks = 0, NumInvalidLinks = 0,
} }
function Initialize(Plugin)
g_Plugin = Plugin;
Plugin:SetName("APIDump");
Plugin:SetVersion(1);
LOG("Initialising " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
g_PluginFolder = Plugin:GetLocalFolder();
-- Load the API descriptions from the Classes and Hooks subfolders:
if (g_APIDesc.Classes == nil) then
g_APIDesc.Classes = {};
end
if (g_APIDesc.Hooks == nil) then
g_APIDesc.Hooks = {};
end
LoadAPIFiles("/Classes/", g_APIDesc.Classes);
LoadAPIFiles("/Hooks/", g_APIDesc.Hooks);
-- dump all available API functions and objects: -- dump all available API functions and objects:
-- DumpAPITxt(); -- DumpAPITxt();
@ -58,7 +80,6 @@ function Initialize(Plugin)
DumpAPIHtml(); DumpAPIHtml();
LOG("APIDump finished"); LOG("APIDump finished");
return true return true
end end
@ -67,6 +88,9 @@ end
function LoadAPIFiles(a_Folder, a_DstTable) function LoadAPIFiles(a_Folder, a_DstTable)
assert(type(a_Folder) == "string")
assert(type(a_DstTable) == "table")
local Folder = g_PluginFolder .. a_Folder; local Folder = g_PluginFolder .. a_Folder;
for idx, fnam in ipairs(cFile:GetFolderContents(Folder)) do for idx, fnam in ipairs(cFile:GetFolderContents(Folder)) do
local FileName = Folder .. fnam; local FileName = Folder .. fnam;
@ -317,6 +341,11 @@ end
function DumpAPIHtml() function DumpAPIHtml()
LOG("Dumping all available functions and constants to API subfolder..."); LOG("Dumping all available functions and constants to API subfolder...");
-- Create the output folder
if not(cFile:IsFolder("API")) then
cFile:CreateFolder("API");
end
LOG("Copying static files.."); LOG("Copying static files..");
cFile:CreateFolder("API/Static"); cFile:CreateFolder("API/Static");
local localFolder = g_Plugin:GetLocalFolder(); local localFolder = g_Plugin:GetLocalFolder();
@ -366,11 +395,6 @@ function DumpAPIHtml()
ReadDescriptions(API); ReadDescriptions(API);
ReadHooks(Hooks); ReadHooks(Hooks);
-- Create the output folder
if not(cFile:IsFolder("API")) then
cFile:CreateFolder("API");
end
-- Create a "class index" file, write each class as a link to that file, -- Create a "class index" file, write each class as a link to that file,
-- then dump class contents into class-specific file -- then dump class contents into class-specific file
LOG("Writing HTML files..."); LOG("Writing HTML files...");
@ -1428,3 +1452,18 @@ end
function HandleWebAdminDump(a_Request)
if (a_Request.PostParams["Dump"] ~= nil) then
DumpApi()
end
return
[[
<p>Pressing the button will generate the API dump on the server. Note that this can take some time.</p>
<form method="POST"><input type="submit" name="Dump" value="Dump the API"/></form>
]]
end

View File

@ -56,7 +56,8 @@ function Initialize(Plugin)
PM:BindCommand("/sched", "debuggers", HandleSched, "- Schedules a simple countdown using cWorld:ScheduleTask()"); PM:BindCommand("/sched", "debuggers", HandleSched, "- Schedules a simple countdown using cWorld:ScheduleTask()");
PM:BindCommand("/cs", "debuggers", HandleChunkStay, "- Tests the ChunkStay Lua integration for the specified chunk coords"); PM:BindCommand("/cs", "debuggers", HandleChunkStay, "- Tests the ChunkStay Lua integration for the specified chunk coords");
PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings") PM:BindCommand("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings")
PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one"); PM:BindCommand("/sb", "debuggers", HandleSetBiome, "- Sets the biome around you to the specified one")
PM:BindCommand("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z")
Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers) Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers)
Plugin:AddWebTab("StressTest", HandleRequest_StressTest) Plugin:AddWebTab("StressTest", HandleRequest_StressTest)
@ -1298,6 +1299,43 @@ end
function HandleWESel(a_Split, a_Player)
-- Check if the selection is a cuboid:
local IsCuboid = cPluginManager:CallPlugin("WorldEdit", "IsPlayerSelectionCuboid")
if (IsCuboid == nil) then
a_Player:SendMessage(cCompositeChat():SetMessageType(mtFailure):AddTextPart("Cannot adjust selection, WorldEdit is not loaded"))
return true
elseif (IsCuboid == false) then
a_Player:SendMessage(cCompositeChat():SetMessageType(mtFailure):AddTextPart("Cannot adjust selection, the selection is not a cuboid"))
return true
end
-- Get the selection:
local SelCuboid = cCuboid()
local IsSuccess = cPluginManager:CallPlugin("WorldEdit", "GetPlayerCuboidSelection", a_Player, SelCuboid)
if not(IsSuccess) then
a_Player:SendMessage(cCompositeChat():SetMessageType(mtFailure):AddTextPart("Cannot adjust selection, WorldEdit reported failure while getting current selection"))
return true
end
-- Adjust the selection:
local NumBlocks = tonumber(a_Split[2] or "1") or 1
SelCuboid:Expand(NumBlocks, NumBlocks, 0, 0, NumBlocks, NumBlocks)
-- Set the selection:
local IsSuccess = cPluginManager:CallPlugin("WorldEdit", "SetPlayerCuboidSelection", a_Player, SelCuboid)
if not(IsSuccess) then
a_Player:SendMessage(cCompositeChat():SetMessageType(mtFailure):AddTextPart("Cannot adjust selection, WorldEdit reported failure while setting new selection"))
return true
end
a_Player:SendMessage(cCompositeChat():SetMessageType(mtInformation):AddTextPart("Successfully adjusted the selection by " .. NumBlocks .. " block(s)"))
return true
end
function OnPlayerJoined(a_Player) function OnPlayerJoined(a_Player)
-- Test composite chat chaining: -- Test composite chat chaining:
a_Player:SendMessage(cCompositeChat() a_Player:SendMessage(cCompositeChat()

View File

@ -196,9 +196,9 @@ macro(set_exe_flags)
add_flags_cxx("-Wno-error=deprecated -Wno-error=weak-vtables -Wno-error=float-equal") add_flags_cxx("-Wno-error=deprecated -Wno-error=weak-vtables -Wno-error=float-equal")
add_flags_cxx("-Wno-error=missing-prototypes -Wno-error=non-virtual-dtor") add_flags_cxx("-Wno-error=missing-prototypes -Wno-error=non-virtual-dtor")
add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow") add_flags_cxx("-Wno-error=covered-switch-default -Wno-error=shadow")
add_flags_cxx("-Wno-exit-time-destructors -Wno-error=missing-variable-declarations") add_flags_cxx("-Wno-error=exit-time-destructors -Wno-error=missing-variable-declarations")
add_flags_cxx("-Wno-global-constructors -Wno-implicit-fallthrough") add_flags_cxx("-Wno-error=global-constructors -Wno-implicit-fallthrough")
add_flags_cxx("-Wno-missing-noreturn -Wno-error=unreachable-code") add_flags_cxx("-Wno-error=unreachable-code")
endif() endif()
endif() endif()

View File

@ -200,7 +200,7 @@ public:
void Push(const HTTPTemplateRequest * a_Request); void Push(const HTTPTemplateRequest * a_Request);
void Push(cTNTEntity * a_TNTEntity); void Push(cTNTEntity * a_TNTEntity);
void Push(Vector3i * a_Vector); void Push(Vector3i * a_Vector);
void Push(void * a_Ptr); NORETURNDEBUG void Push(void * a_Ptr);
void Push(cHopperEntity * a_Hopper); void Push(cHopperEntity * a_Hopper);
void Push(cBlockEntity * a_BlockEntity); void Push(cBlockEntity * a_BlockEntity);

View File

@ -248,7 +248,7 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{ {
AStringVector Split(StringSplit(a_Message, " ")); AStringVector Split(StringSplit(a_Message, " "));
ASSERT(!Split.empty()); // This should not happen - we know there's at least one char in the message so the split needs to be at least one item long ASSERT(!Split.empty()); // This should not happen - we know there's at least one char in the message so the split needs to be at least one item long
a_Player->SendMessageInfo(Printf("Unknown command: \"%s\"", Split[0].c_str())); a_Player->SendMessageInfo(Printf("Unknown command: \"%s\"", a_Message.c_str()));
LOGINFO("Player %s issued an unknown command: \"%s\"", a_Player->GetName().c_str(), a_Message.c_str()); LOGINFO("Player %s issued an unknown command: \"%s\"", a_Player->GetName().c_str(), a_Message.c_str());
return true; // Cancel sending return true; // Cancel sending
} }

View File

@ -38,6 +38,20 @@ void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2)
void cCuboid::Assign(const cCuboid & a_SrcCuboid)
{
p1.x = a_SrcCuboid.p1.x;
p1.y = a_SrcCuboid.p1.y;
p1.z = a_SrcCuboid.p1.z;
p2.x = a_SrcCuboid.p2.x;
p2.y = a_SrcCuboid.p2.y;
p2.z = a_SrcCuboid.p2.z;
}
void cCuboid::Sort(void) void cCuboid::Sort(void)
{ {
if (p1.x > p2.x) if (p1.x > p2.x)

View File

@ -21,6 +21,7 @@ public:
cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {} cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {}
void Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2); void Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2);
void Assign(const cCuboid & a_SrcCuboid);
void Sort(void); void Sort(void);

View File

@ -60,7 +60,7 @@ protected:
void CheckWorldAge(const AString & a_WorldName, Int64 a_Age); void CheckWorldAge(const AString & a_WorldName, Int64 a_Age);
/// Called when a deadlock is detected. Aborts the server. /// Called when a deadlock is detected. Aborts the server.
void DeadlockDetected(void); NORETURN void DeadlockDetected(void);
} ; } ;

View File

@ -46,6 +46,8 @@
#define SIZE_T_FMT_PRECISION(x) "%" #x "Iu" #define SIZE_T_FMT_PRECISION(x) "%" #x "Iu"
#define SIZE_T_FMT_HEX "%Ix" #define SIZE_T_FMT_HEX "%Ix"
#define NORETURN __declspec(noreturn)
#elif defined(__GNUC__) #elif defined(__GNUC__)
// TODO: Can GCC explicitly mark classes as abstract (no instances can be created)? // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
@ -70,6 +72,8 @@
#define SIZE_T_FMT_PRECISION(x) "%" #x "zu" #define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
#define SIZE_T_FMT_HEX "%zx" #define SIZE_T_FMT_HEX "%zx"
#define NORETURN __attribute((__noreturn__))
#else #else
#error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler" #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
@ -94,6 +98,13 @@
#endif #endif
#ifdef _DEBUG
#define NORETURNDEBUG NORETURN
#else
#define NORETURNDEBUG
#endif
#include <stddef.h> #include <stddef.h>