LucidCube/Tools/BlockZapper/BlockZapper.cpp
Rebekah Rowe 6c4b2e9186
Implement GPL3+ and Apache2.0 Dual License.
Commit is being made to allow additions of GPL3+ code previously
un-addable. With these changes, contributions back to cuberite are
possible with the backporting exemtion, as well as adding stuff in
minetest with minetest code properly being read through and implimented
to upgrade it to GPL3 from GPL2.

project still has Apache2.0 license and credits to all its contributers, but now has the freedom of GPL3+ and all the code that can be implimented and shared with it.
2023-03-20 11:49:56 -04:00

110 lines
2.4 KiB
C++

/*
* Copyright 2011-2022 Cuberite Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// BlockZapper.cpp
// Implements the main app entrypoint
#include "Globals.h"
#include <fstream>
#include "Regions.h"
#include "Zapper.h"
#ifdef _MSC_VER
// Under MSVC, link to WinSock2 (needed by FastNBT's byteswapping)
#pragma comment(lib, "ws2_32.lib")
#endif
void ShowHelp(const char * a_ProgramFullName)
{
AString ProgramName(a_ProgramFullName);
size_t idx = ProgramName.rfind(cFile::PathSeparator);
if (idx != AString::npos)
{
ProgramName.erase(0, idx + 1);
}
printf("Tool written by _Xoft(o), code is public domain.\n");
printf("Usage:\n");
printf("%s [-w <MCAFolder>]\n", ProgramName.c_str());
printf("Zaps blocks and / or entities in specified regions.\n");
printf("Regions are read from stdin, the format is:\n");
printf(" x1 x2 y1 y2 z1 z2 [B|E|BE]\n");
printf("B or no specifier zaps blocks only\n");
printf("E zaps entities only\n");
printf("BE zaps blocks and entities\n");
printf("MCA files are searched in the <MCAFolder>; if not specified, in the current folder.\n");
}
int main(int argc, char * argv[])
{
new cMCLogger; // Create a new logger, it will assign itself as the main logger instance
AString MCAFolder = ".";
for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "-w") == 0)
{
if (i < argc - 1)
{
MCAFolder = argv[i + 1];
}
i++;
}
else if (
(strcmp(argv[i], "help") == 0) ||
(strcmp(argv[i], "-?") == 0) ||
(strcmp(argv[i], "/?") == 0) ||
(strcmp(argv[i], "-h") == 0) ||
(strcmp(argv[i], "--help") == 0)
)
{
ShowHelp(argv[0]);
return 0;
}
}
cRegions Regions;
/*
// DEBUG: Read input from a file instead of stdin:
std::fstream fs("test_in.txt");
Regions.Read(fs);
//*/
Regions.Read(std::cin);
cZapper Zapper(MCAFolder);
Zapper.ZapRegions(Regions.GetAll());
LOGINFO("Done");
return 0;
} ;