summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CheckBasicStyle.lua103
-rw-r--r--src/World.cpp2
2 files changed, 102 insertions, 3 deletions
diff --git a/src/CheckBasicStyle.lua b/src/CheckBasicStyle.lua
index 19156b537..8cd454e8f 100644
--- a/src/CheckBasicStyle.lua
+++ b/src/CheckBasicStyle.lua
@@ -266,14 +266,113 @@ end
+--- Array of files to process. Filled from cmdline arguments
+local ToProcess = {}
+
+
+
+
+
+--- Handlers for the command-line arguments
+-- Maps flag => function
+local CmdLineHandlers =
+{
+ -- "-f file" checks the specified file
+ ["-f"] = function (a_Args, a_Idx)
+ local fnam = a_Args[a_Idx + 1]
+ if not(fnam) then
+ error("Invalid flag: '-f' needs a filename following it.")
+ end
+ table.insert(ToProcess, fnam)
+ return a_Idx + 2 -- skip the filename in param parsing
+ end,
+
+ -- "-g" checks files reported by git as being committed.
+ ["-g"] = function (a_Args, a_Idx)
+ local f = io.popen("git diff --cached --name-only --diff-filter=ACMR")
+ for fnam in f:lines() do
+ table.insert(ToProcess, fnam)
+ end
+ end,
+
+ -- "-h" prints help and exits
+ ["-h"] = function (a_Args, a_Idx)
+ print([[
+Usage:")
+"CheckBasicStyle [<options>]
+
+Available options:
+-f <filename> - checks the specified filename
+-g - checks files reported by Git as being committed
+-h - prints this help and exits
+-l <listfile> - checks all files listed in the specified listfile
+-- - reads the list of files to check from stdin
+
+When no options are given, the script checks all files listed in the AllFiles.lst file.
+
+Only .cpp and .h files are ever checked.
+]])
+ os.exit(0)
+ end,
+
+ -- "-l listfile" loads the list of files to check from the specified listfile
+ ["-l"] = function (a_Args, a_Idx)
+ local listFile = a_Args[a_Idx + 1]
+ if not(listFile) then
+ error("Invalid flag: '-l' needs a filename following it.")
+ end
+ for fnam in io.lines(listFile) do
+ table.insert(ToProcess, fnam)
+ end
+ return a_Idx + 2 -- Skip the listfile in param parsing
+ end,
+
+ -- "--" reads the list of files from stdin
+ ["--"] = function (a_Args, a_Idx)
+ for fnam in io.lines() do
+ table.insert(ToProcess, fnam)
+ end
+ 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
+-- Parse the cmdline arguments to see what files to check:
+local idx = 1
+while (arg[idx]) do
+ local handler = CmdLineHandlers[arg[idx]]
+ if not(handler) then
+ error("Unknown command-line argument #" .. idx .. ": " .. arg[idx])
+ end
+ idx = handler(arg, idx) or (idx + 1) -- Call the handler, let it change the next index if it wants
+end
+
+
+-- By default process all files in the AllFiles.lst file (generated by cmake):
+if not(arg[1]) then
+ for fnam in io.lines("AllFiles.lst") do
+ table.insert(ToProcess, fnam)
+ end
+end
+
+
+
+
+
+-- Process the files in the list:
+for _, fnam in ipairs(ToProcess) do
ProcessItem(fnam)
end
+
+
+
+
-- Report final verdict:
print("Number of violations found: " .. g_NumViolations)
if (g_NumViolations > 0) then
diff --git a/src/World.cpp b/src/World.cpp
index 8e1d0b33e..87209e4c2 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -833,7 +833,7 @@ void cWorld::InitialiseAndLoadMobSpawningValues(cIniFile & a_IniFile)
AString DefaultMonsters;
switch (m_Dimension)
{
- case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break;
+ case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, guardian, horse, mooshroom, ocelot, pig, rabbit, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break;
case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break;
case dimEnd: DefaultMonsters = "enderman"; break;
case dimNotSet: ASSERT(!"Dimension not set"); break;