1
0

Merge remote-tracking branch 'origin/master' into portals

Conflicts:
	src/Chunk.cpp
	src/Entities/Player.cpp
	src/Root.cpp
	src/World.cpp
This commit is contained in:
Tiger Wang 2014-07-22 10:24:28 +01:00
commit 3385ed56b8
180 changed files with 2558 additions and 1497 deletions

1
.gitignore vendored
View File

@ -65,6 +65,7 @@ lib/tolua++/tolua
src/Bindings/Bindings.*
src/Bindings/BindingDependecies.txt
MCServer.dir/
src/AllFiles.lst
#win32 cmake stuff
*.vcxproj

View File

@ -1155,6 +1155,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins,
HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" },
HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" },
HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" },
RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the inventory, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." },
RemoveOneEquippedItem = { Params = "", Return = "", Notes = "Removes one item from the hotbar's currently selected slot" },
SetArmorSlot = { Params = "ArmorSlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified armor slot contents" },
SetEquippedSlotNum = { Params = "EquippedSlotNum", Return = "", Notes = "Sets the currently selected hotbar slot number" },
@ -1384,6 +1385,7 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3");
{ Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" },
{ Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" },
},
RemoveItem = { Params = "{{cItem}}", Return = "number", Notes = "Removes the specified item from the grid, as many as possible, up to the item's m_ItemCount. Returns the number of items that were removed." },
RemoveOneItem =
{
{ Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" },

View File

@ -60,9 +60,10 @@ function Initialize(Plugin)
PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace");
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("/compo", "debuggers", HandleCompo, "- Tests the cCompositeChat bindings")
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")
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("/wesel", "debuggers", HandleWESel, "- Expands the current WE selection by 1 block in X/Z");
PM:BindCommand("/rmitem", "debuggers", HandleRMItem, "- Remove the specified item from the inventory.");
Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers)
Plugin:AddWebTab("StressTest", HandleRequest_StressTest)
@ -533,7 +534,7 @@ function OnTakeDamage(Receiver, TDI)
-- Receiver is cPawn
-- TDI is TakeDamageInfo
LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)");
-- LOG(Receiver:GetClass() .. " was dealt " .. DamageTypeToString(TDI.DamageType) .. " damage: Raw " .. TDI.RawDamage .. ", Final " .. TDI.FinalDamage .. " (" .. (TDI.RawDamage - TDI.FinalDamage) .. " covered by armor)");
return false;
end
@ -1105,6 +1106,41 @@ end
function HandleRMItem(a_Split, a_Player)
-- Check params:
if (a_Split[2] == nil) then
a_Player:SendMessage("Usage: /rmitem <Item> [Count]")
return true
end
-- Parse the item type:
local Item = cItem()
if (not StringToItem(a_Split[2], Item)) then
a_Player:SendMessageFailure(a_Split[2] .. " isn't a valid item")
return true
end
-- Parse the optional item count
if (a_Split[3] ~= nil) then
local Count = tonumber(a_Split[3])
if (Count == nil) then
a_Player:SendMessageFailure(a_Split[3] .. " isn't a valid number")
return true
end
Item.m_ItemCount = Count
end
-- Remove the item:
local NumRemovedItems = a_Player:GetInventory():RemoveItem(Item)
a_Player:SendMessageSuccess("Removed " .. NumRemovedItems .. " Items!")
return true
end
function HandleRequest_Debuggers(a_Request)
local FolderContents = cFile:GetFolderContents("./");
return "<p>The following objects have been returned by cFile:GetFolderContents():<ul><li>" .. table.concat(FolderContents, "</li><li>") .. "</li></ul></p>";

135
src/Bindings/CMakeLists.txt Normal file
View File

@ -0,0 +1,135 @@
cmake_minimum_required (VERSION 2.6)
project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
include_directories (".")
SET (SRCS
Bindings.cpp
DeprecatedBindings.cpp
LuaChunkStay.cpp
LuaState.cpp
LuaWindow.cpp
ManualBindings.cpp
Plugin.cpp
PluginLua.cpp
PluginManager.cpp
WebPlugin.cpp
)
SET (HDRS
Bindings.h
DeprecatedBindings.h
LuaChunkStay.h
LuaFunctions.h
LuaState.h
LuaWindow.h
ManualBindings.h
Plugin.h
PluginLua.h
PluginManager.h
WebPlugin.h
tolua++.h
)
# List all the files that are generated as part of the Bindings build process
set (BINDING_OUTPUTS
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc
)
set(BINDING_DEPENDECIES
tolua
../Bindings/virtual_method_hooks.lua
../Bindings/AllToLua.pkg
../Bindings/gen_LuaState_Call.lua
../Bindings/LuaFunctions.h
../Bindings/LuaState_Call.inc
../Bindings/LuaWindow.h
../Bindings/Plugin.h
../Bindings/PluginLua.h
../Bindings/PluginManager.h
../Bindings/WebPlugin.h
../BiomeDef.h
../BlockArea.h
../BlockEntities/BlockEntity.h
../BlockEntities/BlockEntityWithItems.h
../BlockEntities/ChestEntity.h
../BlockEntities/DispenserEntity.h
../BlockEntities/DropSpenserEntity.h
../BlockEntities/DropperEntity.h
../BlockEntities/FurnaceEntity.h
../BlockEntities/HopperEntity.h
../BlockEntities/JukeboxEntity.h
../BlockEntities/NoteEntity.h
../BlockEntities/SignEntity.h
../BlockEntities/MobHeadEntity.h
../BlockEntities/FlowerPotEntity.h
../BlockID.h
../BoundingBox.h
../ChatColor.h
../ChunkDef.h
../ClientHandle.h
../CraftingRecipes.h
../Cuboid.h
../Defines.h
../Enchantments.h
../Entities/EntityEffect.h
../Entities/Entity.h
../Entities/Floater.h
../Entities/Pawn.h
../Entities/Painting.h
../Entities/Pickup.h
../Entities/Player.h
../Entities/ProjectileEntity.h
../Entities/ArrowEntity.h
../Entities/ThrownEggEntity.h
../Entities/ThrownEnderPearlEntity.h
../Entities/ExpBottleEntity.h
../Entities/ThrownSnowballEntity.h
../Entities/FireChargeEntity.h
../Entities/FireworkEntity.h
../Entities/GhastFireballEntity.h
../Entities/TNTEntity.h
../Entities/ExpOrb.h
../Entities/HangingEntity.h
../Entities/ItemFrame.h
../Generating/ChunkDesc.h
../Group.h
../Inventory.h
../Item.h
../ItemGrid.h
../Mobs/Monster.h
../OSSupport/File.h
../Root.h
../Server.h
../StringUtils.h
../Tracer.h
../UI/Window.h
../Vector3.h
../WebAdmin.h
../World.h
)
if (NOT MSVC)
ADD_CUSTOM_COMMAND(
# add any new generated bindings here
OUTPUT ${BINDING_OUTPUTS}
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDECIES}
)
endif ()
set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS})
target_link_libraries(Bindings lua sqlite tolualib polarssl)
endif()

View File

@ -1336,7 +1336,6 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
{
UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns
// Format string consisting only of %s is used to appease the compiler
LOGD("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
for (int i = lua_gettop(a_LuaState); i > 0; i--)

View File

@ -656,7 +656,7 @@ template<
static int tolua_ForEach(lua_State * tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
if( NumArgs != 1 && NumArgs != 2)
if ((NumArgs != 1) && (NumArgs != 2))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs);
}
@ -958,7 +958,7 @@ tolua_lerror:
static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
{
// Exported manually, because tolua would require the out-only param a_Height to be used when calling
// Takes (a_World,) a_BlockX, a_BlockZ
// Takes a_World, a_BlockX, a_BlockZ
// Returns Height, IsValid
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@ -1947,7 +1947,7 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
}
else
{
LOGERROR("ERROR: cPluginLua:AddWebTab invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str() );
LOGWARNING("cPluginLua:AddWebTab: invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str());
}
return 0;

View File

@ -10,7 +10,8 @@
// The "map" used for biome <-> string conversions:
static struct {
static struct
{
EMCSBiome m_Biome;
const char * m_String;
} g_BiomeMap[] =

View File

@ -4,9 +4,41 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
BeaconEntity.cpp
BlockEntity.cpp
ChestEntity.cpp
CommandBlockEntity.cpp
DispenserEntity.cpp
DropSpenserEntity.cpp
DropperEntity.cpp
EnderChestEntity.cpp
FlowerPotEntity.cpp
FurnaceEntity.cpp
HopperEntity.cpp
JukeboxEntity.cpp
MobHeadEntity.cpp
NoteEntity.cpp
SignEntity.cpp)
add_library(BlockEntities ${SOURCE})
SET (HDRS
BeaconEntity.h
BlockEntity.h
BlockEntityWithItems.h
ChestEntity.h
CommandBlockEntity.h
DispenserEntity.h
DropSpenserEntity.h
DropperEntity.h
EnderChestEntity.h
FlowerPotEntity.h
FurnaceEntity.h
HopperEntity.h
JukeboxEntity.h
MobHeadEntity.h
NoteEntity.h
SignEntity.h)
if(NOT MSVC)
add_library(BlockEntities ${SRCS} ${HDRS})
endif()

View File

@ -27,7 +27,8 @@ class cChestEntity :
typedef cBlockEntityWithItems super;
public:
enum {
enum
{
ContentsHeight = 3,
ContentsWidth = 9,
} ;

View File

@ -35,7 +35,8 @@ class cDropSpenserEntity :
typedef cBlockEntityWithItems super;
public:
enum {
enum
{
ContentsHeight = 3,
ContentsWidth = 3,
} ;

View File

@ -22,7 +22,8 @@ class cHopperEntity :
typedef cBlockEntityWithItems super;
public:
enum {
enum
{
ContentsHeight = 1,
ContentsWidth = 5,
TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper

View File

@ -255,7 +255,8 @@ AString ItemToFullString(const cItem & a_Item)
int StringToMobType(const AString & a_MobString)
{
static struct {
static struct
{
int m_MobType;
const char * m_String;
} MobMap [] =

View File

@ -70,7 +70,7 @@
#include "BlockSand.h"
#include "BlockSapling.h"
#include "BlockSideways.h"
#include "BlockSign.h"
#include "BlockSignPost.h"
#include "BlockSlab.h"
#include "BlockSnow.h"
#include "BlockStairs.h"
@ -81,6 +81,7 @@
#include "BlockTorch.h"
#include "BlockTrapdoor.h"
#include "BlockVine.h"
#include "BlockWallSign.h"
#include "BlockWorkbench.h"
@ -253,7 +254,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( );
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler;
case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType);
case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType);
@ -275,7 +276,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_SAND: return new cBlockSandHandler (a_BlockType);
case E_BLOCK_SANDSTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_SAPLING: return new cBlockSaplingHandler (a_BlockType);
case E_BLOCK_SIGN_POST: return new cBlockSignHandler (a_BlockType);
case E_BLOCK_SIGN_POST: return new cBlockSignPostHandler (a_BlockType);
case E_BLOCK_SNOW: return new cBlockSnowHandler (a_BlockType);
case E_BLOCK_SPRUCE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_STAINED_GLASS: return new cBlockGlassHandler (a_BlockType);
@ -297,7 +298,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_TRIPWIRE: return new cBlockTripwireHandler (a_BlockType);
case E_BLOCK_TRIPWIRE_HOOK: return new cBlockTripwireHookHandler (a_BlockType);
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
case E_BLOCK_WALLSIGN: return new cBlockSignHandler (a_BlockType); // TODO: This needs a special handler
case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType);
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType);
case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType);

View File

@ -9,12 +9,14 @@
class cBlockSignHandler :
class cBlockSignPostHandler :
public cBlockHandler
{
typedef cBlockHandler super;
public:
cBlockSignHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
cBlockSignPostHandler(BLOCKTYPE a_BlockType) :
super(a_BlockType)
{
}
@ -31,6 +33,17 @@ public:
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
{
return false;
}
return (cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
}
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
@ -45,23 +58,6 @@ public:
}
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
switch (a_Direction)
{
case 0x2: return 0x2;
case 0x3: return 0x3;
case 0x4: return 0x4;
case 0x5: return 0x5;
default:
{
break;
}
}
return 0x2;
}
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -84,6 +80,7 @@ public:
return (a_Meta + 12) & 0x0f;
}
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
// Mirrors signs over the XY plane (North-South Mirroring)

View File

@ -119,7 +119,8 @@ public:
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, Face, true);
BLOCKTYPE BlockInQuestion = a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if ( // If on a block that can only hold a torch if torch is standing on it, return that face
// If on a block that can only hold a torch if torch is standing on it, return that face
if (
((BlockInQuestion == E_BLOCK_GLASS) ||
(BlockInQuestion == E_BLOCK_FENCE) ||
(BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) ||

View File

@ -0,0 +1,89 @@
#pragma once
#include "BlockHandler.h"
#include "../Entities/Player.h"
#include "Chunk.h"
class cBlockWallSignHandler :
public cBlockHandler
{
typedef cBlockHandler super;
public:
cBlockWallSignHandler(BLOCKTYPE a_BlockType) :
super(a_BlockType)
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
}
virtual const char * GetStepSound(void) override
{
return "step.wood";
}
virtual void OnPlacedByPlayer(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta
) override
{
a_Player->GetClientHandle()->SendEditSign(a_BlockX, a_BlockY, a_BlockZ);
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX;
int BlockZ = (a_Chunk.GetPosZ() * cChunkDef::Width) + a_RelZ;
GetBlockCoordsBehindTheSign(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ), BlockX, BlockZ);
return (cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(BlockX, a_RelY, BlockZ)));
}
static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ)
{
switch (a_BlockMeta)
{
case 2: a_BlockZ++; break;
case 3: a_BlockZ--; break;
case 4: a_BlockX++; break;
case 5: a_BlockX--; break;
default: break;
}
}
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
switch (a_Direction)
{
case 0x2: return 0x2;
case 0x3: return 0x3;
case 0x4: return 0x4;
case 0x5: return 0x5;
default:
{
break;
}
}
return 0x2;
}
} ;

View File

@ -4,9 +4,99 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
BlockBed.cpp
BlockDoor.cpp
BlockHandler.cpp
BlockPiston.cpp
ChunkInterface.cpp)
add_library(Blocks ${SOURCE})
SET (HDRS
BlockAnvil.h
BlockBed.h
BlockBigFlower.h
BlockBrewingStand.h
BlockButton.h
BlockCactus.h
BlockCake.h
BlockCarpet.h
BlockCauldron.h
BlockChest.h
BlockCloth.h
BlockCobWeb.h
BlockCommandBlock.h
BlockComparator.h
BlockCrops.h
BlockDeadBush.h
BlockDirt.h
BlockDoor.h
BlockDropSpenser.h
BlockEnchantmentTable.h
BlockEnderchest.h
BlockEntity.h
BlockFarmland.h
BlockFenceGate.h
BlockFire.h
BlockFlower.h
BlockFlowerPot.h
BlockFluid.h
BlockFurnace.h
BlockGlass.h
BlockGlowstone.h
BlockGravel.h
BlockHandler.h
BlockHayBale.h
BlockHopper.h
BlockIce.h
BlockLadder.h
BlockLeaves.h
BlockLever.h
BlockLilypad.h
BlockMelon.h
BlockMobHead.h
BlockMushroom.h
BlockMycelium.h
BlockNetherWart.h
BlockNewLeaves.h
BlockNote.h
BlockOre.h
BlockPiston.h
BlockPlanks.h
BlockPluginInterface.h
BlockPortal.h
BlockPressurePlate.h
BlockPumpkin.h
BlockQuartz.h
BlockRail.h
BlockRedstone.h
BlockRedstoneLamp.h
BlockRedstoneRepeater.h
BlockRedstoneTorch.h
BlockSand.h
BlockSapling.h
BlockSideways.h
BlockSignPost.h
BlockSlab.h
BlockSnow.h
BlockStairs.h
BlockStems.h
BlockStone.h
BlockSugarcane.h
BlockTNT.h
BlockTallGrass.h
BlockTorch.h
BlockTrapdoor.h
BlockTripwire.h
BlockTripwireHook.h
BlockVine.h
BlockWallSign.h
BlockWorkbench.h
BroadcastInterface.h
ChunkInterface.h
ClearMetaOnDrop.h
MetaRotator.h
WorldInterface.h)
if(NOT MSVC)
add_library(Blocks ${SRCS} ${HDRS})
endif()

View File

@ -5,144 +5,148 @@ include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/")
include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include")
include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
set(FOLDERS OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++)
set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs)
set(FOLDERS
OSSupport HTTPServer Items Blocks Protocol Generating PolarSSL++ Bindings
WorldStorage Mobs Entities Simulator UI BlockEntities Generating/Prefabs
)
set(BINDING_DEPENDECIES
tolua
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg
Bindings/gen_LuaState_Call.lua
Bindings/LuaFunctions.h
Bindings/LuaWindow.h
Bindings/Plugin.h
Bindings/PluginLua.h
Bindings/PluginManager.h
Bindings/WebPlugin.h
SET (SRCS
BiomeDef.cpp
BlockArea.cpp
BlockID.cpp
BlockInfo.cpp
BoundingBox.cpp
ByteBuffer.cpp
ChatColor.cpp
Chunk.cpp
ChunkData.cpp
ChunkMap.cpp
ChunkSender.cpp
ChunkStay.cpp
ClientHandle.cpp
CommandOutput.cpp
CompositeChat.cpp
CraftingRecipes.cpp
Cuboid.cpp
DeadlockDetect.cpp
Enchantments.cpp
FastRandom.cpp
FurnaceRecipe.cpp
Globals.cpp
Group.cpp
GroupManager.cpp
Inventory.cpp
Item.cpp
ItemGrid.cpp
LightingThread.cpp
LineBlockTracer.cpp
LinearInterpolation.cpp
Log.cpp
MCLogger.cpp
Map.cpp
MapManager.cpp
MobCensus.cpp
MobFamilyCollecter.cpp
MobProximityCounter.cpp
MobSpawner.cpp
MonsterConfig.cpp
Noise.cpp
ProbabDistrib.cpp
RCONServer.cpp
Root.cpp
Scoreboard.cpp
Server.cpp
Statistics.cpp
StringCompression.cpp
StringUtils.cpp
Tracer.cpp
VoronoiMap.cpp
WebAdmin.cpp
World.cpp
main.cpp)
SET (HDRS
AllocationPool.h
BiomeDef.h
BlockArea.h
BlockEntities/BlockEntity.h
BlockEntities/BlockEntityWithItems.h
BlockEntities/ChestEntity.h
BlockEntities/DispenserEntity.h
BlockEntities/DropSpenserEntity.h
BlockEntities/DropperEntity.h
BlockEntities/FurnaceEntity.h
BlockEntities/HopperEntity.h
BlockEntities/JukeboxEntity.h
BlockEntities/NoteEntity.h
BlockEntities/SignEntity.h
BlockEntities/MobHeadEntity.h
BlockEntities/FlowerPotEntity.h
BlockID.h
BlockInServerPluginInterface.h
BlockInfo.h
BlockTracer.h
BoundingBox.h
ByteBuffer.h
ChatColor.h
Chunk.h
ChunkData.h
ChunkDataCallback.h
ChunkDef.h
ChunkMap.h
ChunkSender.h
ChunkStay.h
ClientHandle.h
CommandOutput.h
CompositeChat.h
CraftingRecipes.h
Cuboid.h
DeadlockDetect.h
Defines.h
Enchantments.h
Entities/EntityEffect.h
Entities/Entity.h
Entities/Floater.h
Entities/Pawn.h
Entities/Painting.h
Entities/Pickup.h
Entities/Player.h
Entities/ProjectileEntity.h
Entities/ArrowEntity.h
Entities/ThrownEggEntity.h
Entities/ThrownEnderPearlEntity.h
Entities/ExpBottleEntity.h
Entities/ThrownSnowballEntity.h
Entities/FireChargeEntity.h
Entities/FireworkEntity.h
Entities/GhastFireballEntity.h
Entities/TNTEntity.h
Entities/ExpOrb.h
Entities/HangingEntity.h
Entities/ItemFrame.h
Generating/ChunkDesc.h
Endianness.h
FastRandom.h
ForEachChunkProvider.h
FurnaceRecipe.h
Globals.h
Group.h
GroupManager.h
Inventory.h
Item.h
ItemGrid.h
Mobs/Monster.h
OSSupport/File.h
LeakFinder.h
LightingThread.h
LineBlockTracer.h
LinearInterpolation.h
LinearUpscale.h
Log.h
MCLogger.h
Map.h
MapManager.h
Matrix4.h
MemoryLeak.h
MersenneTwister.h
MobCensus.h
MobFamilyCollecter.h
MobProximityCounter.h
MobSpawner.h
MonsterConfig.h
Noise.h
ProbabDistrib.h
RCONServer.h
Root.h
Scoreboard.h
Server.h
StackWalker.h
Statistics.h
StringCompression.h
StringUtils.h
Tracer.h
UI/Window.h
Vector3.h
VoronoiMap.h
WebAdmin.h
World.h
)
XMLParser.h)
# List all the files that are generated as part of the Bindings build process
set (BINDING_OUTPUTS
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
${CMAKE_CURRENT_SOURCE_DIR}/Bindings/LuaState_Call.inc
)
include_directories(Bindings)
include_directories(.)
if (WIN32)
ADD_CUSTOM_COMMAND(
OUTPUT ${BINDING_OUTPUTS}
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
COMMAND ${CMAKE_COMMAND} -E copy_if_different ../../MCServer/lua51.dll ./lua51.dll
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDECIES}
)
else ()
ADD_CUSTOM_COMMAND(
# add any new generated bindings here
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDECIES}
)
endif ()
set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
include_directories(".")
if (NOT MSVC)
# Bindings need to reference other folders, so they are done here instead
# lib dependencies are not included
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/polarssl/include")
#add cpp files here
add_library(Bindings
Bindings/Bindings
Bindings/DeprecatedBindings
Bindings/LuaChunkStay
Bindings/LuaState
Bindings/LuaWindow
Bindings/ManualBindings
Bindings/Plugin
Bindings/PluginLua
Bindings/PluginManager
Bindings/WebPlugin
)
foreach(folder ${FOLDERS})
add_subdirectory(${folder})
endforeach(folder)
target_link_libraries(Bindings lua sqlite tolualib polarssl)
get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
#clear file
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependecies.txt)
@ -153,43 +157,19 @@ if (NOT MSVC)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h")
foreach(folder ${FOLDERS})
add_subdirectory(${folder})
endforeach(folder)
file(GLOB SOURCE
"*.cpp"
"*.h"
)
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/StackWalker.cpp" "${PROJECT_SOURCE_DIR}/LeakFinder.cpp")
list(APPEND SOURCE "${SRCS}")
list(APPEND SOURCE "${HDRS}")
# If building a windows version, but not using MSVC, add the resources directly to the makefile:
if (WIN32)
FILE(GLOB ResourceFiles
"Resources/*.rc"
)
list(APPEND SOURCE "${ResourceFiles}")
list(APPEND SOURCE "Resources/MCServer.rc")
endif()
else ()
# MSVC-specific handling: Put all files into one project, separate by the folders:
# Get all files in this folder:
file(GLOB_RECURSE SOURCE
"*.cpp"
"*.h"
"*.pkg"
)
source_group("" FILES ${SOURCE})
LIST(APPEND SOURCE "Bindings/Bindings.cpp" "Bindings/Bindings.h")
source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h")
# Add all subfolders as solution-folders:
list(APPEND FOLDERS "Resources")
list(APPEND FOLDERS "Bindings")
function(includefolder PATH)
FILE(GLOB FOLDER_FILES
"${PATH}/*.cpp"
@ -202,9 +182,29 @@ else ()
endfunction(includefolder)
foreach(folder ${FOLDERS})
add_subdirectory(${folder})
includefolder(${folder})
# Get all source files in this folder:
get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
foreach (src ${FOLDER_SRCS})
list(APPEND SOURCE "${folder}/${src}")
endforeach(src)
# Get all headers in this folder:
get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
foreach (hdr ${FOLDER_HDRS})
list(APPEND SOURCE "${folder}/${hdr}")
endforeach(hdr)
endforeach(folder)
list(APPEND SOURCE "${SRCS}")
list(APPEND SOURCE "${HDRS}")
list(APPEND SOURCE "Bindings/AllToLua.pkg")
includefolder("Resources")
source_group("" FILES ${SOURCE})
include_directories("${PROJECT_SOURCE_DIR}")
# Precompiled headers (1st part)
@ -228,8 +228,47 @@ else ()
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /DEBUG")
endif()
# Generate a list of all source files:
set(ALLFILES "")
foreach(folder ${FOLDERS})
get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
foreach (src ${FOLDER_SRCS})
list(APPEND ALLFILES "${folder}/${src}")
endforeach(src)
get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
foreach (hdr ${FOLDER_HDRS})
list(APPEND ALLFILES "${folder}/${hdr}")
endforeach(hdr)
endforeach(folder)
foreach(arg ${ALLFILES})
set(ALLFILESLINES "${ALLFILESLINES}${arg}\n")
endforeach()
FILE(WRITE "AllFiles.lst" "${ALLFILESLINES}")
set(EXECUTABLE MCServer)
if (MSVC)
get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS)
get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
ADD_CUSTOM_COMMAND(
OUTPUT ${BINDING_OUTPUTS}
# Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/MCServer/lua51.dll ./lua51.dll
# Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
# add any new generation dependencies here
DEPENDS ${BINDING_DEPENDECIES}
)
endif()
add_executable(${EXECUTABLE} ${SOURCE})
@ -261,9 +300,11 @@ endif ()
if (NOT MSVC)
target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks)
target_link_libraries(${EXECUTABLE} Protocol Generating Generating_Prefabs WorldStorage)
target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities PolarSSL++)
target_link_libraries(${EXECUTABLE}
OSSupport HTTPServer Bindings Items Blocks
Protocol Generating Generating_Prefabs WorldStorage
Mobs Entities Simulator UI BlockEntities PolarSSL++
)
endif ()
if (WIN32)
target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib)

View File

@ -2,31 +2,31 @@
#include "ChatColor.h"
const std::string cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8
const std::string cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8
const std::string cChatColor::Black = cChatColor::Color + "0";
const std::string cChatColor::Navy = cChatColor::Color + "1";
const std::string cChatColor::Green = cChatColor::Color + "2";
const std::string cChatColor::Blue = cChatColor::Color + "3";
const std::string cChatColor::Red = cChatColor::Color + "4";
const std::string cChatColor::Purple = cChatColor::Color + "5";
const std::string cChatColor::Gold = cChatColor::Color + "6";
const std::string cChatColor::LightGray = cChatColor::Color + "7";
const std::string cChatColor::Gray = cChatColor::Color + "8";
const std::string cChatColor::DarkPurple = cChatColor::Color + "9";
const std::string cChatColor::LightGreen = cChatColor::Color + "a";
const std::string cChatColor::LightBlue = cChatColor::Color + "b";
const std::string cChatColor::Rose = cChatColor::Color + "c";
const std::string cChatColor::LightPurple = cChatColor::Color + "d";
const std::string cChatColor::Yellow = cChatColor::Color + "e";
const std::string cChatColor::White = cChatColor::Color + "f";
const char * cChatColor::Color = "\xc2\xa7"; // or in other words: "§" in UTF-8
const char * cChatColor::Delimiter = "\xc2\xa7"; // or in other words: "§" in UTF-8
const char * cChatColor::Black = "\xc2\xa7""0";
const char * cChatColor::Navy = "\xc2\xa7""1";
const char * cChatColor::Green = "\xc2\xa7""2";
const char * cChatColor::Blue = "\xc2\xa7""3";
const char * cChatColor::Red = "\xc2\xa7""4";
const char * cChatColor::Purple = "\xc2\xa7""5";
const char * cChatColor::Gold = "\xc2\xa7""6";
const char * cChatColor::LightGray = "\xc2\xa7""7";
const char * cChatColor::Gray = "\xc2\xa7""8";
const char * cChatColor::DarkPurple = "\xc2\xa7""9";
const char * cChatColor::LightGreen = "\xc2\xa7""a";
const char * cChatColor::LightBlue = "\xc2\xa7""b";
const char * cChatColor::Rose = "\xc2\xa7""c";
const char * cChatColor::LightPurple = "\xc2\xa7""d";
const char * cChatColor::Yellow = "\xc2\xa7""e";
const char * cChatColor::White = "\xc2\xa7""f";
const std::string cChatColor::Random = cChatColor::Color + "k";
const std::string cChatColor::Bold = cChatColor::Color + "l";
const std::string cChatColor::Strikethrough = cChatColor::Color + "m";
const std::string cChatColor::Underlined = cChatColor::Color + "n";
const std::string cChatColor::Italic = cChatColor::Color + "o";
const std::string cChatColor::Plain = cChatColor::Color + "r";
const char * cChatColor::Random = "\xc2\xa7""k";
const char * cChatColor::Bold = "\xc2\xa7""l";
const char * cChatColor::Strikethrough = "\xc2\xa7""m";
const char * cChatColor::Underlined = "\xc2\xa7""n";
const char * cChatColor::Italic = "\xc2\xa7""o";
const char * cChatColor::Plain = "\xc2\xa7""r";

View File

@ -9,34 +9,36 @@
class cChatColor
{
public:
static const std::string Color;
static const std::string Delimiter;
static const char * Delimiter;
static const std::string Black;
static const std::string Navy;
static const std::string Green;
static const std::string Blue;
static const std::string Red;
static const std::string Purple;
static const std::string Gold;
static const std::string LightGray;
static const std::string Gray;
static const std::string DarkPurple;
static const std::string LightGreen;
static const std::string LightBlue;
static const std::string Rose;
static const std::string LightPurple;
static const std::string Yellow;
static const std::string White;
/** @deprecated use ChatColor::Delimiter instead */
static const char * Color;
// Styles ( source: http://wiki.vg/Chat )
static const std::string Random;
static const std::string Bold;
static const std::string Strikethrough;
static const std::string Underlined;
static const std::string Italic;
static const std::string Plain;
static const char * Black;
static const char * Navy;
static const char * Green;
static const char * Blue;
static const char * Red;
static const char * Purple;
static const char * Gold;
static const char * LightGray;
static const char * Gray;
static const char * DarkPurple;
static const char * LightGreen;
static const char * LightBlue;
static const char * Rose;
static const char * LightPurple;
static const char * Yellow;
static const char * White;
// Styles
// source: http://wiki.vg/Chat
static const char * Random;
static const char * Bold;
static const char * Strikethrough;
static const char * Underlined;
static const char * Italic;
static const char * Plain;
};
// tolua_end

View File

@ -1,3 +1,4 @@
#!/usr/bin/env lua
-- CheckBasicStyle.lua
@ -6,13 +7,14 @@ Checks that all source files (*.cpp, *.h) use the basic style requirements of th
- Tabs for indentation, spaces for alignment
- Trailing whitespace on non-empty lines
- Two spaces between code and line-end comment ("//")
- Spaces after comma, not before (except in #define argument list)
- Spaces after comma, not before
- Opening braces not at the end of a code line
- Spaces after if, for, while
- (TODO) Spaces before *, /, &
- (TODO) Hex numbers with even digit length
- (TODO) Hex numbers in lowercase
- (TODO) Braces not on the end of line
- (TODO) Line dividers (////...) exactly 80 slashes
- (TODO) Not using "* "-style doxy comments continuation lines
- (TODO) Not using "* "-style doxy comment continuation lines
Violations that cannot be checked easily:
- Spaces around "+" (there are things like "a++", "++a", "a += 1", "X+", "stack +1" and ascii-drawn tables)
@ -22,26 +24,12 @@ the line brings the editor directly to the violation.
Returns 0 on success, 1 on internal failure, 2 if any violations found
This script requires LuaFileSystem to be available in the current Lua interpreter.
--]]
-- Check that LFS is installed:
local hasLfs = pcall(require, "lfs")
if not(hasLfs) then
print("This script requires LuaFileSystem to be installed")
os.exit(1)
end
local lfs = require("lfs")
assert(lfs ~= nil)
-- The list of file extensions that are processed:
local g_ShouldProcessExt =
{
@ -52,13 +40,12 @@ local g_ShouldProcessExt =
--- The list of files not to be processed:
local g_IgnoredFiles =
{
"./Bindings/Bindings.cpp",
"./Bindings/DeprecatedBindings.cpp",
"./LeakFinder.cpp",
"./LeakFinder.h",
"./MersenneTwister.h",
"./StackWalker.cpp",
"./StackWalker.h",
"Bindings/Bindings.cpp",
"LeakFinder.cpp",
"LeakFinder.h",
"MersenneTwister.h",
"StackWalker.cpp",
"StackWalker.h",
}
--- The list of files not to be processed, as a dictionary (filename => true), built from g_IgnoredFiles
@ -79,8 +66,8 @@ local g_NumViolations = 0
--- Reports one violation
-- Pretty-prints the message
-- Also increments g_NumViolations
local function ReportViolation(a_FileName, a_LineNumber, a_Message)
print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_Message)
local function ReportViolation(a_FileName, a_LineNumber, a_PatStart, a_PatEnd, a_Message)
print(a_FileName .. "(" .. a_LineNumber .. "): " .. a_PatStart .. " .. " .. a_PatEnd .. ": " .. a_Message)
g_NumViolations = g_NumViolations + 1
end
@ -94,7 +81,7 @@ local function ReportViolationIfFound(a_Line, a_FileName, a_LineNum, a_Pattern,
if not(patStart) then
return
end
ReportViolation(a_FileName, a_LineNum, a_Message .. "(" .. patStart .. " .. " .. patEnd .. ")")
ReportViolation(a_FileName, a_LineNum, patStart, patEnd, a_Message)
end
@ -120,7 +107,26 @@ local g_ViolationPatterns =
-- Check that all commas have spaces after them and not in front of them:
{" ,", "Extra space before a \",\""},
{"^\t*[^#].*,[^%s]", "Needs a space after a \",\""}, -- Anywhere except lines starting with "#" - avoid #define params
{",[^%s\"%%]", "Needs a space after a \",\""}, -- Report all except >> "," << needed for splitting and >>,%s<< needed for formatting
-- Check that opening braces are not at the end of a code line:
{"[^%s].-{\n?$", "Brace should be on a separate line"},
-- Space after keywords:
{"[^_]if%(", "Needs a space after \"if\""},
{"for%(", "Needs a space after \"for\""},
{"while%(", "Needs a space after \"while\""},
{"switch%(", "Needs a space after \"switch\""},
{"catch%(", "Needs a space after \"catch\""},
-- No space after keyword's parenthesis:
{"[^%a#]if %( ", "Remove the space after \"(\""},
{"for %( ", "Remove the space after \"(\""},
{"while %( ", "Remove the space after \"(\""},
{"catch %( ", "Remove the space after \"(\""},
-- No space before a closing parenthesis:
{" %)", "Remove the space before \")\""},
}
@ -145,7 +151,7 @@ local function ProcessFile(a_FileName)
if ((lastChar ~= 13) and (lastChar ~= 10)) then
local numLines = 1
string.gsub(all, "\n", function() numLines = numLines + 1 end) -- Count the number of line-ends
ReportViolation(a_FileName, numLines, "Missing empty line at file end")
ReportViolation(a_FileName, numLines, 1, 1, "Missing empty line at file end")
return
end
@ -178,17 +184,6 @@ local function ProcessItem(a_ItemName)
return
end
-- If the item is a folder, recurse:
local attrs = lfs.attributes(a_ItemName)
if (attrs and (attrs.mode == "directory")) then
for fnam in lfs.dir(a_ItemName) do
if ((fnam ~= ".") and (fnam ~= "..")) then
ProcessItem(a_ItemName .. "/" .. fnam)
end
end
return
end
local ext = a_ItemName:match("%.([^/%.]-)$")
if (g_ShouldProcessExt[ext]) then
ProcessFile(a_ItemName)
@ -199,8 +194,10 @@ end
-- Process the entire current folder:
ProcessItem(".")
-- Process all files in the AllFiles.lst file (generated by cmake):
for fnam in io.lines("AllFiles.lst") do
ProcessItem(fnam)
end
-- Report final verdict:
print("Number of violations found: " .. g_NumViolations)

View File

@ -781,7 +781,7 @@ void cChunk::CheckBlocks()
void cChunk::TickBlocks(void)
{
// Tick dem blocks
// _X: We must limit the random number or else we get a nasty int overflow bug ( http://forum.mc-server.org/showthread.php?tid=457 )
// _X: We must limit the random number or else we get a nasty int overflow bug - http://forum.mc-server.org/showthread.php?tid=457
int RandomX = m_World->GetTickRandomNumber(0x00ffffff);
int RandomY = m_World->GetTickRandomNumber(0x00ffffff);
int RandomZ = m_World->GetTickRandomNumber(0x00ffffff);
@ -1529,11 +1529,12 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType);
if ( // Queue block to be sent only if ...
// Queue block to be sent only if ...
if (
a_SendToClients && // ... we are told to do so AND ...
(
(OldBlockMeta != a_BlockMeta) || // ... the meta value is different OR ...
!( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them); see below for specifics:
!( // ... the old and new blocktypes AREN'T liquids (because client doesn't need to distinguish betwixt them):
((OldBlockType == E_BLOCK_STATIONARY_WATER) && (a_BlockType == E_BLOCK_WATER)) || // Replacing stationary water with water
((OldBlockType == E_BLOCK_WATER) && (a_BlockType == E_BLOCK_STATIONARY_WATER)) || // Replacing water with stationary water
((OldBlockType == E_BLOCK_STATIONARY_LAVA) && (a_BlockType == E_BLOCK_LAVA)) || // Replacing stationary water with water

View File

@ -1951,10 +1951,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
double FinalDamage = (((1 / AbsoluteEntityPos.x) + (1 / AbsoluteEntityPos.y) + (1 / AbsoluteEntityPos.z)) * 2) * m_ExplosionSize;
// Clip damage values
if (FinalDamage > a_Entity->GetMaxHealth())
FinalDamage = a_Entity->GetMaxHealth();
else if (FinalDamage < 0)
FinalDamage = 0;
FinalDamage = Clamp(FinalDamage, 0.0, (double)a_Entity->GetMaxHealth());
if (!a_Entity->IsTNT() && !a_Entity->IsFallingBlock()) // Don't apply damage to other TNT entities and falling blocks, they should be invincible
{

View File

@ -211,11 +211,11 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage
{
if (ShouldAppendChatPrefixes)
{
return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue.c_str(), a_AdditionalData.c_str(), cChatColor::White.c_str(), cChatColor::Italic.c_str());
return Printf("%s[MSG: %s] %s%s", cChatColor::LightBlue, a_AdditionalData.c_str(), cChatColor::White, cChatColor::Italic);
}
else
{
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue.c_str());
return Printf("%s: %s", a_AdditionalData.c_str(), cChatColor::LightBlue);
}
}
}
@ -534,9 +534,9 @@ void cClientHandle::HandlePing(void)
Printf(Reply, "%s%s%i%s%i",
Server.GetDescription().c_str(),
cChatColor::Delimiter.c_str(),
cChatColor::Delimiter,
Server.GetNumPlayers(),
cChatColor::Delimiter.c_str(),
cChatColor::Delimiter,
Server.GetMaxPlayers()
);
Kick(Reply);
@ -1171,7 +1171,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{
// Only compare ItemType, not meta (torches have different metas)
// The -1 check is there because sometimes the client sends -1 instead of the held item
// ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 )
// Ref.: http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502
LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)",
m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType
);

View File

@ -274,7 +274,7 @@ private:
/** The type used for storing the names of registered plugin channels. */
typedef std::set<AString> cChannels;
/** Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 ) */
/** Number of chunks the player can see in each direction */
int m_ViewDistance;
/** Server generates this many chunks AHEAD of player sight. */

View File

@ -24,6 +24,17 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2)
////////////////////////////////////////////////////////////////////////////////
// cCuboid:
cCuboid & cCuboid::operator=(cCuboid a_Other)
{
std::swap(p1, a_Other.p1);
std::swap(p2, a_Other.p2);
return *this;
}
void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2)
{
p1.x = a_X1;

View File

@ -20,6 +20,8 @@ public:
cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {}
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 & operator=(cCuboid a_Other);
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);

View File

@ -470,18 +470,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
{
int Y = a_BlockY;
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
if (Y < 0)
{
a_BlockY = 0;
}
else if (Y > 255)
{
a_BlockY = 255;
}
else
{
a_BlockY = (unsigned char)Y;
}
a_BlockY = Clamp<unsigned char>((unsigned char)Y, 0, 255);
}

View File

@ -40,7 +40,7 @@ Serialization will never put zero-level enchantments into the stringspec and wil
class cEnchantments
{
public:
/** Individual enchantment IDs, corresponding to their NBT IDs ( http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs )
/** Individual enchantment IDs, corresponding to their NBT IDs: http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs
*/
enum

View File

@ -4,11 +4,64 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
ArrowEntity.cpp
Boat.cpp
EnderCrystal.cpp
Entity.cpp
EntityEffect.cpp
ExpBottleEntity.cpp
ExpOrb.cpp
FallingBlock.cpp
FireChargeEntity.cpp
FireworkEntity.cpp
Floater.cpp
GhastFireballEntity.cpp
HangingEntity.cpp
ItemFrame.cpp
Minecart.cpp
Painting.cpp
Pawn.cpp
Pickup.cpp
Player.cpp
ProjectileEntity.cpp
SplashPotionEntity.cpp
TNTEntity.cpp
ThrownEggEntity.cpp
ThrownEnderPearlEntity.cpp
ThrownSnowballEntity.cpp
WitherSkullEntity.cpp)
add_library(Entities ${SOURCE})
SET (HDRS
ArrowEntity.h
Boat.h
EnderCrystal.h
Entity.h
EntityEffect.h
ExpBottleEntity.h
ExpOrb.h
FallingBlock.h
FireChargeEntity.h
FireworkEntity.h
Floater.h
GhastFireballEntity.h
HangingEntity.h
ItemFrame.h
Minecart.h
Painting.h
Pawn.h
Pickup.h
Player.h
ProjectileEntity.h
SplashPotionEntity.h
TNTEntity.h
ThrownEggEntity.h
ThrownEnderPearlEntity.h
ThrownSnowballEntity.h
WitherSkullEntity.h)
if(NOT MSVC)
add_library(Entities ${SRCS} ${HDRS})
target_link_libraries(Entities WorldStorage)
endif()

View File

@ -50,6 +50,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_IsSubmerged(false)
, m_AirLevel(0)
, m_AirTickTimer(0)
, m_TicksAlive(0)
, m_HeadYaw(0.0)
, m_Rot(0.0, 0.0, 0.0)
, m_Pos(a_X, a_Y, a_Z)
@ -328,10 +329,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// TODO: Apply damage to armor
if (m_Health < 0)
{
m_Health = 0;
}
m_Health = std::max(m_Health, 0);
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
{
@ -563,6 +561,8 @@ void cEntity::SetHealth(int a_Health)
void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
m_TicksAlive++;
if (m_InvulnerableTicks > 0)
{
m_InvulnerableTicks--;
@ -1324,10 +1324,7 @@ void cEntity::SetMaxHealth(int a_MaxHealth)
m_MaxHealth = a_MaxHealth;
// Reset health, if too high:
if (m_Health > a_MaxHealth)
{
m_Health = a_MaxHealth;
}
m_Health = std::min(m_Health, a_MaxHealth);
}

View File

@ -431,6 +431,9 @@ public:
/** Gets remaining air of a monster */
int GetAirLevel(void) const { return m_AirLevel; }
/** Gets number of ticks this entity has existed for */
long int GetTicksAlive(void) const { return m_TicksAlive; }
/** Gets the invulnerable ticks from the entity */
int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
@ -556,6 +559,9 @@ protected:
/** Portal delay timer and cooldown boolean data */
sPortalCooldownData m_PortalCooldownData;
/** The number of ticks this entity has been alive for */
long int m_TicksAlive;
private:
/** Measured in degrees, [-180, +180) */
double m_HeadYaw;

View File

@ -103,21 +103,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
{
char SubType = 0;
switch (m_Payload)
{
case mpNone: SubType = 0; break;
case mpChest: SubType = 1; break;
case mpFurnace: SubType = 2; break;
case mpTNT: SubType = 3; break;
case mpHopper: SubType = 5; break;
default:
{
ASSERT(!"Unknown payload, cannot spawn on client");
return;
}
}
a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart
a_ClientHandle.SendSpawnVehicle(*this, 10, (char)m_Payload); // 10 = Minecarts
a_ClientHandle.SendEntityMetadata(*this);
}

View File

@ -23,13 +23,14 @@ class cMinecart :
public:
CLASS_PROTODEF(cMinecart);
/** Minecart payload, values correspond to packet subtype */
enum ePayload
{
mpNone, // Empty minecart, ridable by player or mobs
mpChest, // Minecart-with-chest, can store a grid of 3*8 items
mpFurnace, // Minecart-with-furnace, can be powered
mpTNT, // Minecart-with-TNT, can be blown up with activator rail
mpHopper, // Minecart-with-hopper, can be hopper
mpNone = 0, // Empty minecart, ridable by player or mobs
mpChest = 1, // Minecart-with-chest, can store a grid of 3*8 items
mpFurnace = 2, // Minecart-with-furnace, can be powered
mpTNT = 3, // Minecart-with-TNT, can be blown up with activator rail
mpHopper = 5, // Minecart-with-hopper, can be hopper
// TODO: Spawner minecarts, (and possibly any block in a minecart with NBT editing)
} ;

View File

@ -374,10 +374,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta)
m_CurrentXp += a_Xp_delta;
// Make sure they didn't subtract too much
if (m_CurrentXp < 0)
{
m_CurrentXp = 0;
}
m_CurrentXp = std::max<short int>(m_CurrentXp, 0);
// Update total for score calculation
if (a_Xp_delta > 0)
@ -617,7 +614,8 @@ void cPlayer::FinishEating(void)
GetInventory().RemoveOneEquippedItem();
// if the food is mushroom soup, return a bowl to the inventory
if( Item.m_ItemType == E_ITEM_MUSHROOM_SOUP ) {
if (Item.m_ItemType == E_ITEM_MUSHROOM_SOUP)
{
cItem emptyBowl(E_ITEM_BOWL, 1, 0, "");
GetInventory().AddItem(emptyBowl, true, true);
}
@ -1518,7 +1516,7 @@ AString cPlayer::GetColor(void) const
{
if (m_Color != '-')
{
return cChatColor::Color + m_Color;
return cChatColor::Delimiter + m_Color;
}
if (m_Groups.size() < 1)

View File

@ -146,10 +146,12 @@ public:
(a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile
)
{
// TODO: Don't check creator only for the first 5 ticks
// so that arrows stuck in ground and dug up can hurt the player
// Don't check creator only for the first 5 ticks so that projectiles can collide with the creator
if (m_Projectile->GetTicksAlive() <= 5)
{
return false;
}
}
cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight());

View File

@ -2,11 +2,15 @@
#include "SplashPotionEntity.h"
#include "Pawn.h"
#include "../ClientHandle.h"
/// Converts an angle in radians into a byte representation used by the network protocol
#define ANGLE_TO_PROTO(X) (Byte)(X * 255 / 360)
////////////////////////////////////////////////////////////////////////////////
// cSplashPotionEntityCallback:
@ -29,25 +33,23 @@ public:
/** Called by cWorld::ForEachEntity(), adds the stored entity effect to the entity, if it is close enough. */
virtual bool Item(cEntity * a_Entity) override
{
double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
if (SplashDistance >= 20)
{
// Too far away
return false;
}
if (!a_Entity->IsPawn())
{
// Not an entity that can take effects
return false;
}
double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
if (SplashDistance >= 20)
{
// Too far away
return false;
}
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
// TODO: better equation
double Reduction = -0.25 * SplashDistance + 1.0;
if (Reduction < 0)
{
Reduction = 0;
}
Reduction = std::max(Reduction, 0.0);
((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction);
return false;
@ -72,12 +74,13 @@ cSplashPotionEntity::cSplashPotionEntity(
const Vector3d & a_Speed,
cEntityEffect::eType a_EntityEffectType,
cEntityEffect a_EntityEffect,
int a_PotionParticleType
int a_PotionColor
) :
super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
m_EntityEffectType(a_EntityEffectType),
m_EntityEffect(a_EntityEffect),
m_PotionParticleType(a_PotionParticleType)
m_PotionColor(a_PotionColor),
m_DestroyTimer(-1)
{
SetSpeed(a_Speed);
}
@ -89,7 +92,7 @@ cSplashPotionEntity::cSplashPotionEntity(
void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
Splash(a_HitPos);
Destroy();
m_DestroyTimer = 2;
}
@ -100,7 +103,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_
{
a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
Splash(a_HitPos);
Destroy(true);
m_DestroyTimer = 5;
}
@ -112,7 +115,17 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
m_World->ForEachEntity(Callback);
m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionParticleType);
m_World->BroadcastSoundParticleEffect(2002, (int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z), m_PotionColor);
}
void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client)
{
a_Client.SendSpawnObject(*this, 73, m_PotionColor, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch()));
a_Client.SendEntityMetadata(*this);
}

View File

@ -31,29 +31,51 @@ public:
const Vector3d & a_Speed,
cEntityEffect::eType a_EntityEffectType,
cEntityEffect a_EntityEffect,
int a_PotionParticleType
int a_PotionColor
);
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
int GetPotionParticleType(void) const { return m_PotionParticleType; }
int GetPotionColor(void) const { return m_PotionColor; }
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; }
void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
protected:
cEntityEffect::eType m_EntityEffectType;
cEntityEffect m_EntityEffect;
int m_PotionParticleType;
int m_PotionColor;
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
/** Splashes the potion, fires its particle effects and sounds
@param a_HitPos The position where the potion will splash */
void Splash(const Vector3d & a_HitPos);
virtual void SpawnOn(cClientHandle & a_Client) override;
private:
/** Time in ticks to wait for the hit animation to begin before destroying */
int m_DestroyTimer;
} ; // tolua_export

View File

@ -4,11 +4,62 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
BioGen.cpp
Caves.cpp
ChunkDesc.cpp
ChunkGenerator.cpp
CompoGen.cpp
ComposableGenerator.cpp
DistortedHeightmap.cpp
EndGen.cpp
FinishGen.cpp
GridStructGen.cpp
HeiGen.cpp
MineShafts.cpp
NetherFortGen.cpp
Noise3DGenerator.cpp
POCPieceGenerator.cpp
PieceGenerator.cpp
Prefab.cpp
PrefabPiecePool.cpp
RainbowRoadsGen.cpp
Ravines.cpp
StructGen.cpp
TestRailsGen.cpp
Trees.cpp
UnderwaterBaseGen.cpp
VillageGen.cpp)
add_library(Generating ${SOURCE})
SET (HDRS
BioGen.h
Caves.h
ChunkDesc.h
ChunkGenerator.h
CompoGen.h
ComposableGenerator.h
DistortedHeightmap.h
EndGen.h
FinishGen.h
GridStructGen.h
HeiGen.h
MineShafts.h
NetherFortGen.h
Noise3DGenerator.h
POCPieceGenerator.h
PieceGenerator.h
Prefab.h
PrefabPiecePool.h
RainbowRoadsGen.h
Ravines.h
StructGen.h
TestRailsGen.h
Trees.h
UnderwaterBaseGen.h
VillageGen.h)
if(NOT MSVC)
add_library(Generating ${SRCS} ${HDRS})
target_link_libraries(Generating OSSupport iniFile Blocks)
endif()

View File

@ -401,6 +401,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
{
m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed));
}
else if (NoCaseCompare(*itr, "TallGrass") == 0)
{
m_FinishGens.push_back(new cFinishGenTallGrass(Seed));
}
else if (NoCaseCompare(*itr, "TestRails") == 0)
{
m_FinishGens.push_back(new cTestRailsGen(Seed, 100, 1, 7, 50));

View File

@ -168,6 +168,65 @@ void cFinishGenNetherClumpFoliage::TryPlaceClump(cChunkDesc & a_ChunkDesc, int a
////////////////////////////////////////////////////////////////////////////////
// cFinishGenTallGrass:
void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int x = 0; x < cChunkDef::Width; x++)
{
int xx = x + a_ChunkDesc.GetChunkX() * cChunkDef::Width;
for (int z = 0; z < cChunkDef::Width; z++)
{
int zz = z + a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
int BiomeDensity = GetBiomeDensity(a_ChunkDesc.GetBiome(x, z));
// Choose if we want to place long grass here. If not then bail out:
if ((m_Noise.IntNoise2DInt(xx + m_Noise.IntNoise1DInt(xx), zz + m_Noise.IntNoise1DInt(zz)) / 7 % 100) > BiomeDensity)
{
continue;
}
// Get the top block + 1. This is the place where the grass would finaly be placed:
int y = a_ChunkDesc.GetHeight(x, z) + 1;
// Check if long grass can be placed:
if (
(a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) ||
((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT))
)
{
continue;
}
// Choose what long grass meta we should use:
int GrassType = m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 100;
if (GrassType < 60)
{
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 1);
}
else if (GrassType < 90)
{
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2);
}
else
{
// If double long grass we have to choose what type we should use:
if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR)
{
NIBBLETYPE Meta = (m_Noise.IntNoise2DInt(xx * 100, zz * 100) / 7 % 100) > 25 ? 2 : 3;
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_BIG_FLOWER, Meta);
a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8);
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
// cFinishGenSprinkleFoliage:

View File

@ -69,6 +69,43 @@ protected:
class cFinishGenTallGrass :
public cFinishGen
{
public:
cFinishGenTallGrass(int a_Seed) : m_Noise(a_Seed), m_Seed(a_Seed) {}
protected:
cNoise m_Noise;
int m_Seed;
// cFinishGen override:
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
int GetBiomeDensity(EMCSBiome a_Biome)
{
switch (a_Biome)
{
case biSavanna:
case biSavannaM:
case biSavannaPlateau:
case biSavannaPlateauM:
case biPlains:
{
return 70;
}
default:
{
return 20;
}
}
}
};
class cFinishGenSprinkleFoliage :
public cFinishGen
{

View File

@ -2367,9 +2367,9 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] =
"a: 24: 2\n" /* sandstone */
"b: 4: 0\n" /* cobblestone */
"c: 24: 0\n" /* sandstone */
"d: 12: 0\n" /* sand */
"e: 13: 0\n" /* gravel */
"f: 5: 0\n" /* wood */
"d: 13: 0\n" /* gravel */
"e: 5: 0\n" /* wood */
"f: 12: 0\n" /* sand */
"g: 64: 3\n" /* wooddoorblock */
"h: 85: 0\n" /* fence */
"i: 64: 0\n" /* wooddoorblock */
@ -2392,26 +2392,26 @@ const cPrefab::sDef g_AlchemistVillagePrefabs[] =
/* * 012345678901234 */
/* 0 */ "mmmabbbammmmmmm"
/* 1 */ "mmmmbbbmmmmmmmm"
/* 2 */ "acccccccccadddd"
/* 3 */ "cccccccccccdddd"
/* 4 */ "cccccccccccdddd"
/* 5 */ "cccccccccccdddd"
/* 6 */ "cccccccccccdddd"
/* 7 */ "cccccccccccdddd"
/* 8 */ "acccccccccadddd"
/* 2 */ "acccccccccacccc"
/* 3 */ "ccccccccccccccc"
/* 4 */ "ccccccccccccccc"
/* 5 */ "ccccccccccccccc"
/* 6 */ "ccccccccccccccc"
/* 7 */ "ccccccccccccccc"
/* 8 */ "acccccccccacccc"
// Level 1
/* z\x* 11111 */
/* * 012345678901234 */
/* 0 */ "mmmaeeeammmmmmm"
/* 1 */ "mmmmeeemmmmmmmm"
/* 2 */ "accccfccccadddd"
/* 3 */ "cfffffffffcdddd"
/* 4 */ "cfffffffffcdddd"
/* 5 */ "cffffffffffdddd"
/* 6 */ "cfffffffffcdddd"
/* 7 */ "cfffffffffcdddd"
/* 8 */ "acccccccccadddd"
/* 0 */ "mmmadddammmmmmm"
/* 1 */ "mmmmdddmmmmmmmm"
/* 2 */ "acccceccccaffff"
/* 3 */ "ceeeeeeeeecffff"
/* 4 */ "ceeeeeeeeecffff"
/* 5 */ "ceeeeeeeeeeffff"
/* 6 */ "ceeeeeeeeecffff"
/* 7 */ "ceeeeeeeeecffff"
/* 8 */ "acccccccccaffff"
// Level 2
/* z\x* 11111 */

View File

@ -4,11 +4,30 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
AlchemistVillagePrefabs.cpp
JapaneseVillagePrefabs.cpp
NetherFortPrefabs.cpp
PlainsVillagePrefabs.cpp
RainbowRoadPrefabs.cpp
SandFlatRoofVillagePrefabs.cpp
SandVillagePrefabs.cpp
TestRailsPrefabs.cpp
UnderwaterBasePrefabs.cpp)
add_library(Generating_Prefabs ${SOURCE})
SET (HDRS
AlchemistVillagePrefabs.h
JapaneseVillagePrefabs.h
NetherFortPrefabs.h
PlainsVillagePrefabs.h
RainbowRoadPrefabs.h
SandFlatRoofVillagePrefabs.h
SandVillagePrefabs.h
TestRailsPrefabs.h
UnderwaterBasePrefabs.h)
if(NOT MSVC)
add_library(Generating_Prefabs ${SRCS} ${HDRS})
target_link_libraries(Generating_Prefabs OSSupport iniFile Blocks)
endif()

View File

@ -134,11 +134,11 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] =
// The data has been exported from the gallery Plains, area index 166, ID 554, created by Aloe_vera
{
// Size:
11, 7, 13, // SizeX = 11, SizeY = 7, SizeZ = 13
11, 8, 13, // SizeX = 11, SizeY = 8, SizeZ = 13
// Hitbox (relative to bounding box):
0, 0, 0, // MinX, MinY, MinZ
10, 6, 12, // MaxX, MaxY, MaxZ
10, 7, 12, // MaxX, MaxY, MaxZ
// Block definitions:
".: 0: 0\n" /* air */
@ -150,6 +150,7 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] =
"f: 59: 7\n" /* crops */
"g: 83: 0\n" /* reedblock */
"h:113: 0\n" /* netherbrickfence */
"i: 50: 5\n" /* torch */
"m: 19: 0\n" /* sponge */,
// Block data:
@ -270,7 +271,24 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] =
/* 9 */ "..........."
/* 10 */ ".h.......h."
/* 11 */ "hhh.....hhh"
/* 12 */ ".h.......h.",
/* 12 */ ".h.......h."
// Level 7
/* z\x* 1 */
/* * 01234567890 */
/* 0 */ ".i.......i."
/* 1 */ "i.i.....i.i"
/* 2 */ ".i.......i."
/* 3 */ "..........."
/* 4 */ "..........."
/* 5 */ "..........."
/* 6 */ "..........."
/* 7 */ "..........."
/* 8 */ "..........."
/* 9 */ "..........."
/* 10 */ ".i.......i."
/* 11 */ "i.i.....i.i"
/* 12 */ ".i.......i.",
// Connectors:
"-1: 10, 2, 6: 5\n" /* Type -1, direction X+ */,
@ -2195,33 +2213,33 @@ const cPrefab::sDef g_JapaneseVillagePrefabs[] =
// Level 1
/* z\x* 0123456 */
/* 0 */ "bmmmmmm"
/* 1 */ "bmmmmmm"
/* 2 */ "bmmmmmm"
/* 3 */ "bmmmmmm"
/* 4 */ "bmmmmmm"
/* 5 */ "bmmmmmm"
/* 0 */ "bbbbbbb"
/* 1 */ "bbbbbbb"
/* 2 */ "bbbbbbb"
/* 3 */ "bbbabbb"
/* 4 */ "bbbbbbb"
/* 5 */ "bbbbbbb"
/* 6 */ "bbbbbbb"
// Level 2
/* z\x* 0123456 */
/* 0 */ "......."
/* 1 */ "..c.c.."
/* 0 */ "mm...mm"
/* 1 */ "m.c...m"
/* 2 */ ".dccdc."
/* 3 */ "..cefc."
/* 4 */ ".ccfgh."
/* 5 */ "..ccc.."
/* 6 */ "......."
/* 5 */ "m.ccc.m"
/* 6 */ "mm...mm"
// Level 3
/* z\x* 0123456 */
/* 0 */ "......."
/* 0 */ "m.....m"
/* 1 */ "......."
/* 2 */ "......."
/* 3 */ "...e..."
/* 4 */ "......."
/* 5 */ "......."
/* 6 */ "......."
/* 6 */ "m.....m"
// Level 4
/* z\x* 0123456 */

View File

@ -356,8 +356,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
"e: 8: 0\n" /* water */
"f: 50: 5\n" /* torch */
"g: 59: 7\n" /* crops */
"h: 59: 0\n" /* crops */
"i: 59: 1\n" /* crops */
"h: 59: 3\n" /* crops */
"i: 59: 5\n" /* crops */
"m: 19: 0\n" /* sponge */,
// Block data:
@ -368,7 +368,7 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 1 */ "aaaaaaaaaaaaaaa"
/* 2 */ "aaaaaaaaaaaaaaa"
/* 3 */ "aaaaaaaaaaaaaaa"
/* 4 */ "aaaaaaaaaaaaaaa"
/* 4 */ "aaaaaaabaaaaaaa"
/* 5 */ "aaaaaaabaaaaaaa"
/* 6 */ "aaaaaaabaaaaaaa"
/* 7 */ "aaaaaaabaaaaaaa"
@ -405,12 +405,12 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* * 012345678901234 */
/* 0 */ "f.....f.f.....f"
/* 1 */ ".gg.gg...gg.gg."
/* 2 */ ".gh.hg...gg.gg."
/* 3 */ ".gh.ih...gg.gg."
/* 4 */ ".gg.hg...gg.gg."
/* 5 */ ".gg.hg...gg.gg."
/* 6 */ ".ig.hg...gg.gg."
/* 7 */ ".hg.gh...gg.gg."
/* 2 */ ".gg.hg...gg.gg."
/* 3 */ ".gg.gi...gg.gg."
/* 4 */ ".gg.gg...gg.gg."
/* 5 */ ".gg.gg...gg.gg."
/* 6 */ ".gg.gg...gg.gg."
/* 7 */ ".gg.gg...gg.gg."
/* 8 */ "f.....f.f.....f"
// Level 4
@ -3603,8 +3603,8 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
// Block definitions:
".: 0: 0\n" /* air */
"a: 2: 0\n" /* grass */
"b: 3: 0\n" /* dirt */
"a: 3: 0\n" /* dirt */
"b: 2: 0\n" /* grass */
"c: 4: 0\n" /* cobblestone */
"d: 67: 0\n" /* stairs */
"e: 67: 2\n" /* stairs */
@ -3629,19 +3629,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
// Level 0
/* z\x* 1 */
/* * 01234567890 */
/* 0 */ "aaaabbbaaaa"
/* 1 */ "abbbbbbbbba"
/* 2 */ "abbbbbbbbba"
/* 3 */ "abbbbbbbbba"
/* 4 */ "abbbbbbbbba"
/* 5 */ "abbbbbbbbba"
/* 6 */ "abbbbbbbbba"
/* 7 */ "abbbbbbbbba"
/* 8 */ "aabbbbbbbaa"
/* 9 */ "aabbbbbbbaa"
/* 10 */ "aabbbbbbbaa"
/* 11 */ "aabbbbbbbaa"
/* 12 */ "aabbbbbbbaa"
/* 0 */ "aaaaaaaaaaa"
/* 1 */ "aaaaaaaaaaa"
/* 2 */ "aaaaaaaaaaa"
/* 3 */ "aaaaaaaaaaa"
/* 4 */ "aaaaaaaaaab"
/* 5 */ "baaaaaaaaab"
/* 6 */ "aaaaaaaaaaa"
/* 7 */ "baaaaaaaaaa"
/* 8 */ "baaaaaaaaaa"
/* 9 */ "baaaaaaaaab"
/* 10 */ "aaaaaaaaaaa"
/* 11 */ "aaaaaaaaaba"
/* 12 */ "aaaaaaaaaba"
// Level 1
/* z\x* 1 */
@ -3654,11 +3654,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 5 */ "mcccccccccm"
/* 6 */ "mcccccccccm"
/* 7 */ "mcccccccccm"
/* 8 */ "mmbbbbbbbmm"
/* 9 */ "mmbbbbbbbmm"
/* 10 */ "mmbbbbbbbmm"
/* 11 */ "mmbbbbbbbmm"
/* 12 */ "mmbbbbbbbmm"
/* 8 */ "mmaaaaaaamm"
/* 9 */ "mmaaaaaaamm"
/* 10 */ "mmaaaaaaamm"
/* 11 */ "mmaaaaaaamm"
/* 12 */ "mmaaaaaaamm"
// Level 2
/* z\x* 1 */
@ -3671,11 +3671,11 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 5 */ ".cggggcccc."
/* 6 */ ".cggggcccc."
/* 7 */ ".ccccccccc."
/* 8 */ "..aaaaaaa.."
/* 9 */ "..aaaaaaa.."
/* 10 */ "..aaaaaaa.."
/* 11 */ "..aaaaaaa.."
/* 12 */ "..aaaaaaa.."
/* 8 */ "..bbbbbbb.."
/* 9 */ "mmbbbbbbbmm"
/* 10 */ "mmbbbbbbbmm"
/* 11 */ "mmbbbbbbbmm"
/* 12 */ "mmbbbbbbbmm"
// Level 3
/* z\x* 1 */
@ -3689,10 +3689,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 6 */ ".i.......i."
/* 7 */ ".hiiijiiih."
/* 8 */ "..l.....l.."
/* 9 */ "..l.....l.."
/* 10 */ "..l.....l.."
/* 11 */ "..l.....l.."
/* 12 */ "..lllllll.."
/* 9 */ "mml.....lmm"
/* 10 */ "mml.....lmm"
/* 11 */ "mml.....lmm"
/* 12 */ "mmlllllllmm"
// Level 4
/* z\x* 1 */
@ -3706,10 +3706,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 6 */ ".o.......o."
/* 7 */ ".hooipiooh."
/* 8 */ "..........."
/* 9 */ "..........."
/* 10 */ "..........."
/* 11 */ "..........."
/* 12 */ "..........."
/* 9 */ "mm.......mm"
/* 10 */ "mm.......mm"
/* 11 */ "mm.......mm"
/* 12 */ "mm.......mm"
// Level 5
/* z\x* 1 */
@ -3723,10 +3723,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 6 */ ".i.......i."
/* 7 */ "uiiiiiiiiiu"
/* 8 */ "kkkkkkkkkkk"
/* 9 */ "..........."
/* 10 */ "..........."
/* 11 */ "..........."
/* 12 */ "..........."
/* 9 */ "mm.......mm"
/* 10 */ "mm.......mm"
/* 11 */ "mm.......mm"
/* 12 */ "mm.......mm"
// Level 6
/* z\x* 1 */
@ -3740,10 +3740,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 6 */ "uiiiiiiiiiu"
/* 7 */ "kkkkkkkkkkk"
/* 8 */ "..........."
/* 9 */ "..........."
/* 10 */ "..........."
/* 11 */ "..........."
/* 12 */ "..........."
/* 9 */ "mm.......mm"
/* 10 */ "mm.......mm"
/* 11 */ "mm.......mm"
/* 12 */ "mm.......mm"
// Level 7
/* z\x* 1 */
@ -3757,10 +3757,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 6 */ "kkkkkkkkkkk"
/* 7 */ "..........."
/* 8 */ "..........."
/* 9 */ "..........."
/* 10 */ "..........."
/* 11 */ "..........."
/* 12 */ "..........."
/* 9 */ "mm.......mm"
/* 10 */ "mm.......mm"
/* 11 */ "mm.......mm"
/* 12 */ "mm.......mm"
// Level 8
/* z\x* 1 */
@ -3774,10 +3774,10 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 6 */ "..........."
/* 7 */ "..........."
/* 8 */ "..........."
/* 9 */ "..........."
/* 10 */ "..........."
/* 11 */ "..........."
/* 12 */ "...........",
/* 9 */ "mm.......mm"
/* 10 */ "mm.......mm"
/* 11 */ "mm.......mm"
/* 12 */ "mm.......mm",
// Connectors:
"-1: 5, 2, 0: 2\n" /* Type -1, direction Z- */,
@ -4237,30 +4237,29 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
// Block definitions:
".: 0: 0\n" /* air */
"a: 4: 0\n" /* cobblestone */
"b: 2: 0\n" /* grass */
"c: 67: 0\n" /* stairs */
"d: 67: 2\n" /* stairs */
"e: 67: 1\n" /* stairs */
"f: 5: 0\n" /* wood */
"g: 67: 3\n" /* stairs */
"h: 17: 0\n" /* tree */
"i: 64: 7\n" /* wooddoorblock */
"j: 64: 5\n" /* wooddoorblock */
"k:102: 0\n" /* glasspane */
"l: 64:12\n" /* wooddoorblock */
"b: 67: 0\n" /* stairs */
"c: 67: 2\n" /* stairs */
"d: 67: 1\n" /* stairs */
"e: 5: 0\n" /* wood */
"f: 67: 3\n" /* stairs */
"g: 17: 0\n" /* tree */
"h: 64: 7\n" /* wooddoorblock */
"i: 64: 5\n" /* wooddoorblock */
"j:102: 0\n" /* glasspane */
"k: 64:12\n" /* wooddoorblock */
"l: 53: 2\n" /* woodstairs */
"m: 19: 0\n" /* sponge */
"n: 53: 2\n" /* woodstairs */
"o: 53: 1\n" /* woodstairs */
"p: 53: 7\n" /* woodstairs */
"q: 53: 6\n" /* woodstairs */
"r: 53: 3\n" /* woodstairs */
"s: 53: 0\n" /* woodstairs */
"t: 53: 5\n" /* woodstairs */
"u: 53: 4\n" /* woodstairs */
"v: 50: 3\n" /* torch */
"w: 50: 2\n" /* torch */
"x: 50: 4\n" /* torch */
"y: 50: 1\n" /* torch */,
"n: 53: 1\n" /* woodstairs */
"o: 53: 7\n" /* woodstairs */
"p: 53: 6\n" /* woodstairs */
"q: 53: 3\n" /* woodstairs */
"r: 53: 0\n" /* woodstairs */
"s: 53: 5\n" /* woodstairs */
"t: 53: 4\n" /* woodstairs */
"u: 50: 3\n" /* torch */
"v: 50: 2\n" /* torch */
"w: 50: 4\n" /* torch */
"x: 50: 1\n" /* torch */,
// Block data:
// Level 0
@ -4274,134 +4273,134 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 5 */ "maaaaaaaaaaaaaam"
/* 6 */ "maaaaaaaaaaaaaam"
/* 7 */ "maaaaaaaaaaaaaam"
/* 8 */ "bbbbbaaaaaaaaaam"
/* 9 */ "bbbbbbbbaaaaaaam"
/* 10 */ "bbbbbbbbaaaaaaam"
/* 11 */ "bbbbbbbbaaaaaaam"
/* 12 */ "bbbbbbbbaaaaaaam"
/* 13 */ "bbbbbbbbaaaaaaam"
/* 14 */ "bbbbbbbbaaaaaaam"
/* 15 */ "bbbbbbbbmmmmmmmm"
/* 8 */ "mmmmmaaaaaaaaaam"
/* 9 */ "mmmmmmmmaaaaaaam"
/* 10 */ "mmmmmmmmaaaaaaam"
/* 11 */ "mmmmmmmmaaaaaaam"
/* 12 */ "mmmmmmmmaaaaaaam"
/* 13 */ "mmmmmmmmaaaaaaam"
/* 14 */ "mmmmmmmmaaaaaaam"
/* 15 */ "mmmmmmmmmmmmmmmm"
// Level 1
/* z\x* 111111 */
/* * 0123456789012345 */
/* 0 */ "........cde....."
/* 0 */ "........bcd....."
/* 1 */ ".aaaaaaaaaaaaaa."
/* 2 */ ".affffffffffffa."
/* 3 */ ".affffffffffffa."
/* 4 */ ".affffffffffffa."
/* 5 */ ".affffffffffffa."
/* 6 */ ".affffffffffffa."
/* 7 */ ".aaaaaaaafffffa."
/* 8 */ ".....cgeafffffa."
/* 9 */ "........afffffa."
/* 10 */ "........afffffa."
/* 11 */ "........afffffa."
/* 12 */ "........afffffa."
/* 13 */ "........afffffa."
/* 14 */ "........aaaaaaa."
/* 15 */ "................"
/* 2 */ ".aeeeeeeeeeeeea."
/* 3 */ ".aeeeeeeeeeeeea."
/* 4 */ ".aeeeeeeeeeeeea."
/* 5 */ ".aeeeeeeeeeeeea."
/* 6 */ ".aeeeeeeeeeeeea."
/* 7 */ ".aaaaaaaaeeeeea."
/* 8 */ ".....bfdaeeeeea."
/* 9 */ "mmmm....aeeeeea."
/* 10 */ "mmmmmmm.aeeeeea."
/* 11 */ "mmmmmmm.aeeeeea."
/* 12 */ "mmmmmmm.aeeeeea."
/* 13 */ "mmmmmmm.aeeeeea."
/* 14 */ "mmmmmmm.aaaaaaa."
/* 15 */ "mmmmmmm........."
// Level 2
/* z\x* 111111 */
/* * 0123456789012345 */
/* 0 */ "................"
/* 1 */ ".hffffffhihfffh."
/* 2 */ ".f............f."
/* 3 */ ".f............f."
/* 4 */ ".f............f."
/* 5 */ ".f............f."
/* 6 */ ".f............f."
/* 7 */ ".hffffjfh.....f."
/* 8 */ "........f.....f."
/* 9 */ "........f.....f."
/* 10 */ "........f.....f."
/* 11 */ "........f.....f."
/* 12 */ "........f.....f."
/* 13 */ "........f.....f."
/* 14 */ "........hfffffh."
/* 15 */ "................"
/* 1 */ ".geeeeeeghgeeeg."
/* 2 */ ".e............e."
/* 3 */ ".e............e."
/* 4 */ ".e............e."
/* 5 */ ".e............e."
/* 6 */ ".e............e."
/* 7 */ ".geeeeieg.....e."
/* 8 */ "........e.....e."
/* 9 */ "mmmm....e.....e."
/* 10 */ "mmmmmmm.e.....e."
/* 11 */ "mmmmmmm.e.....e."
/* 12 */ "mmmmmmm.e.....e."
/* 13 */ "mmmmmmm.e.....e."
/* 14 */ "mmmmmmm.geeeeeg."
/* 15 */ "mmmmmmm........."
// Level 3
/* z\x* 111111 */
/* * 0123456789012345 */
/* 0 */ "................"
/* 1 */ ".hfkkfkkhlhkkfh."
/* 2 */ ".k............f."
/* 3 */ ".k............k."
/* 4 */ ".k............k."
/* 5 */ ".k............f."
/* 6 */ ".k............k."
/* 7 */ ".hfkkflfh.....k."
/* 8 */ "........f.....f."
/* 9 */ "........k.....k."
/* 10 */ "........k.....k."
/* 11 */ "........f.....f."
/* 12 */ "........k.....k."
/* 13 */ "........k.....k."
/* 14 */ "........hkkkkkh."
/* 15 */ "................"
/* 1 */ ".gejjejjgkgjjeg."
/* 2 */ ".j............e."
/* 3 */ ".j............j."
/* 4 */ ".j............j."
/* 5 */ ".j............e."
/* 6 */ ".j............j."
/* 7 */ ".gejjekeg.....j."
/* 8 */ "........e.....e."
/* 9 */ "mmmm....j.....j."
/* 10 */ "mmmmmmm.j.....j."
/* 11 */ "mmmmmmm.e.....e."
/* 12 */ "mmmmmmm.j.....j."
/* 13 */ "mmmmmmm.j.....j."
/* 14 */ "mmmmmmm.gjjjjjg."
/* 15 */ "mmmmmmm........."
// Level 4
/* z\x* 111111 */
/* * 0123456789012345 */
/* 0 */ "nnnnnnnnnnnnnnno"
/* 1 */ "phffffffhfhfffho"
/* 2 */ ".f............fo"
/* 3 */ ".f............fo"
/* 4 */ ".f............fo"
/* 5 */ ".f............fo"
/* 6 */ ".f............fo"
/* 7 */ "qhffffffh.....fo"
/* 8 */ "rrrrrrrsf.....fo"
/* 9 */ ".......sf.....fo"
/* 10 */ ".......sf.....fo"
/* 11 */ ".......sf.....fo"
/* 12 */ ".......sf.....fo"
/* 13 */ ".......sf.....fo"
/* 14 */ ".......shfffffho"
/* 15 */ ".......st.....uo"
/* 0 */ "llllllllllllllln"
/* 1 */ "ogeeeeeegegeeegn"
/* 2 */ ".e............en"
/* 3 */ ".e............en"
/* 4 */ ".e............en"
/* 5 */ ".e............en"
/* 6 */ ".e............en"
/* 7 */ "pgeeeeeeg.....en"
/* 8 */ "qqqqqqqre.....en"
/* 9 */ "mmmm...re.....en"
/* 10 */ "mmmmmmmre.....en"
/* 11 */ "mmmmmmmre.....en"
/* 12 */ "mmmmmmmre.....en"
/* 13 */ "mmmmmmmre.....en"
/* 14 */ "mmmmmmmrgeeeeegn"
/* 15 */ "mmmmmmmrs.....tn"
// Level 5
/* z\x* 111111 */
/* * 0123456789012345 */
/* 0 */ "................"
/* 1 */ "nnnnnnnnnnnnnnn."
/* 2 */ "pfffffffffffffo."
/* 3 */ ".f.........v.fo."
/* 4 */ ".f..........wfo."
/* 5 */ ".f......x....fo."
/* 6 */ "qfffffffff...fo."
/* 7 */ "rrrrrrrrsfy..fo."
/* 8 */ "........sf...fo."
/* 9 */ "........sf...fo."
/* 10 */ "........sf...fo."
/* 11 */ "........sf...fo."
/* 12 */ "........sf...fo."
/* 13 */ "........sf...fo."
/* 14 */ "........sfffffo."
/* 15 */ "........st...uo."
/* 1 */ "lllllllllllllll."
/* 2 */ "oeeeeeeeeeeeeen."
/* 3 */ ".e.........u.en."
/* 4 */ ".e..........ven."
/* 5 */ ".e......w....en."
/* 6 */ "peeeeeeeee...en."
/* 7 */ "qqqqqqqqrex..en."
/* 8 */ "........re...en."
/* 9 */ "mmmm....re...en."
/* 10 */ "mmmmmmm.re...en."
/* 11 */ "mmmmmmm.re...en."
/* 12 */ "mmmmmmm.re...en."
/* 13 */ "mmmmmmm.re...en."
/* 14 */ "mmmmmmm.reeeeen."
/* 15 */ "mmmmmmm.rs...tn."
// Level 6
/* z\x* 111111 */
/* * 0123456789012345 */
/* 0 */ "................"
/* 1 */ "................"
/* 2 */ "nnnnnnnnnnnnno.."
/* 3 */ "pffffffffffffo.."
/* 4 */ ".fy.........fo.."
/* 5 */ "qffffffffff.fo.."
/* 6 */ "rrrrrrrrrsf.fo.."
/* 7 */ ".........sf.fo.."
/* 8 */ ".........sf.fo.."
/* 9 */ ".........sf.fo.."
/* 10 */ ".........sf.fo.."
/* 11 */ ".........sf.fo.."
/* 12 */ ".........sf.fo.."
/* 13 */ ".........sfxfo.."
/* 14 */ ".........sfffo.."
/* 15 */ ".........st.uo.."
/* 2 */ "llllllllllllln.."
/* 3 */ "oeeeeeeeeeeeen.."
/* 4 */ ".ex.........en.."
/* 5 */ "peeeeeeeeee.en.."
/* 6 */ "qqqqqqqqqre.en.."
/* 7 */ ".........re.en.."
/* 8 */ ".........re.en.."
/* 9 */ "mmmm.....re.en.."
/* 10 */ "mmmmmmm..re.en.."
/* 11 */ "mmmmmmm..re.en.."
/* 12 */ "mmmmmmm..re.en.."
/* 13 */ "mmmmmmm..rewen.."
/* 14 */ "mmmmmmm..reeen.."
/* 15 */ "mmmmmmm..rs.tn.."
// Level 7
/* z\x* 111111 */
@ -4409,19 +4408,19 @@ const cPrefab::sDef g_PlainsVillagePrefabs[] =
/* 0 */ "................"
/* 1 */ "................"
/* 2 */ "................"
/* 3 */ "nnnnnnnnnnnnn..."
/* 4 */ "ffffffffffffo..."
/* 5 */ "rrrrrrrrrrsfo..."
/* 6 */ "..........sfo..."
/* 7 */ "..........sfo..."
/* 8 */ "..........sfo..."
/* 9 */ "..........sfo..."
/* 10 */ "..........sfo..."
/* 11 */ "..........sfo..."
/* 12 */ "..........sfo..."
/* 13 */ "..........sfo..."
/* 14 */ "..........sfo..."
/* 15 */ "..........sfo...",
/* 3 */ "lllllllllllll..."
/* 4 */ "eeeeeeeeeeeen..."
/* 5 */ "qqqqqqqqqqren..."
/* 6 */ "..........ren..."
/* 7 */ "..........ren..."
/* 8 */ "..........ren..."
/* 9 */ "mmmm......ren..."
/* 10 */ "mmmmmmm...ren..."
/* 11 */ "mmmmmmm...ren..."
/* 12 */ "mmmmmmm...ren..."
/* 13 */ "mmmmmmm...ren..."
/* 14 */ "mmmmmmm...ren..."
/* 15 */ "mmmmmmm...ren...",
// Connectors:
"-1: 9, 1, 0: 2\n" /* Type -1, direction Z- */,

View File

@ -10,13 +10,6 @@
// DEBUG:
int gTotalLargeJungleTrees = 0;
int gOversizeLargeJungleTrees = 0;
typedef struct
{
@ -113,6 +106,7 @@ inline void PushCoordBlocks(int a_BlockX, int a_Height, int a_BlockZ, sSetBlockV
inline void PushCornerBlocks(int a_BlockX, int a_Height, int a_BlockZ, int a_Seq, cNoise & a_Noise, int a_Chance, sSetBlockVector & a_Blocks, int a_CornersDist, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta)
{
for (size_t i = 0; i < ARRAYCOUNT(Corners); i++)

View File

@ -153,7 +153,7 @@ bool cGroupManager::LoadGroups()
AString Color = IniFile.GetValue(KeyName, "Color", "-");
if ((Color != "-") && (Color.length() >= 1))
{
Group->SetColor(cChatColor::Color + Color[0]);
Group->SetColor(cChatColor::Delimiter + Color[0]);
}
else
{

View File

@ -4,9 +4,26 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
EnvelopeParser.cpp
HTTPConnection.cpp
HTTPFormParser.cpp
HTTPMessage.cpp
HTTPServer.cpp
MultipartParser.cpp
NameValueParser.cpp
SslHTTPConnection.cpp)
add_library(HTTPServer ${SOURCE})
SET (HDRS
EnvelopeParser.h
HTTPConnection.h
HTTPFormParser.h
HTTPMessage.h
HTTPServer.h
MultipartParser.h
NameValueParser.h
SslHTTPConnection.h)
if(NOT MSVC)
add_library(HTTPServer ${SRCS} ${HDRS})
endif()

View File

@ -151,6 +151,24 @@ int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a
int cInventory::RemoveItem(const cItem & a_ItemStack)
{
int RemovedItems = m_HotbarSlots.RemoveItem(a_ItemStack);
if (RemovedItems < a_ItemStack.m_ItemCount)
{
cItem Temp(a_ItemStack);
Temp.m_ItemCount -= RemovedItems;
RemovedItems += m_InventorySlots.RemoveItem(Temp);
}
return RemovedItems;
}
bool cInventory::RemoveOneEquippedItem(void)
{
if (m_HotbarSlots.GetSlot(m_EquippedSlotNum).IsEmpty())

View File

@ -86,6 +86,10 @@ public:
*/
int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst);
/** Removes the specified item from the inventory, as many as possible, up to a_ItemStack.m_ItemCount.
Returns the number of items that were removed. */
int RemoveItem(const cItem & a_ItemStack);
/** Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed */
bool RemoveOneEquippedItem(void);

View File

@ -345,6 +345,39 @@ int cItemGrid::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks, int a_P
int cItemGrid::RemoveItem(const cItem & a_ItemStack)
{
int NumLeft = a_ItemStack.m_ItemCount;
for (int i = 0; i < m_NumSlots; i++)
{
if (NumLeft <= 0)
{
break;
}
if (m_Slots[i].IsEqual(a_ItemStack))
{
int NumToRemove = std::min(NumLeft, (int)m_Slots[i].m_ItemCount);
NumLeft -= NumToRemove;
m_Slots[i].m_ItemCount -= NumToRemove;
if (m_Slots[i].m_ItemCount <= 0)
{
m_Slots[i].Empty();
}
TriggerListeners(i);
}
}
return (a_ItemStack.m_ItemCount - NumLeft);
}
int cItemGrid::ChangeSlotCount(int a_SlotNum, int a_AddToCount)
{
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))

View File

@ -97,6 +97,10 @@ public:
*/
int AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks = true, int a_PrioritarySlot = -1);
/** Removes the specified item from the grid, as many as possible, up to a_ItemStack.m_ItemCount.
Returns the number of items that were removed. */
int RemoveItem(const cItem & a_ItemStack);
/** Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot.
If the slot is empty, ignores the call.
Returns the new count.

View File

@ -4,9 +4,53 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
ItemHandler.cpp)
add_library(Items ${SOURCE})
SET (HDRS
ItemArmor.h
ItemBed.h
ItemBoat.h
ItemBow.h
ItemBrewingStand.h
ItemBucket.h
ItemCake.h
ItemCauldron.h
ItemCloth.h
ItemComparator.h
ItemDoor.h
ItemDye.h
ItemEmptyMap.h
ItemFishingRod.h
ItemFlowerPot.h
ItemFood.h
ItemHandler.h
ItemHoe.h
ItemItemFrame.h
ItemLeaves.h
ItemLighter.h
ItemLilypad.h
ItemMap.h
ItemMilk.h
ItemMinecart.h
ItemMobHead.h
ItemNetherWart.h
ItemPainting.h
ItemPickaxe.h
ItemPotion.h
ItemRedstoneDust.h
ItemRedstoneRepeater.h
ItemSapling.h
ItemSeeds.h
ItemShears.h
ItemShovel.h
ItemSign.h
ItemSpawnEgg.h
ItemString.h
ItemSugarcane.h
ItemSword.h
ItemThrowable.h)
if(NOT MSVC)
add_library(Items ${SRCS} ${HDRS})
endif()

View File

@ -17,8 +17,8 @@ public:
}
/** Returns the potion particle type (used by the client for visuals), based on the potion's damage value */
static int GetPotionParticleType(short a_ItemDamage)
/** Returns the potion color (used by the client for visuals), based on the potion's damage value */
static int GetPotionColor(short a_ItemDamage)
{
// Lowest six bits
return (a_ItemDamage & 0x3f);
@ -156,7 +156,7 @@ public:
cSplashPotionEntity * Projectile = new cSplashPotionEntity(
a_Player, Pos.x, Pos.y, Pos.z, Speed,
GetEntityEffectType(PotionDamage), cEntityEffect(GetEntityEffectDuration(PotionDamage),
GetEntityEffectIntensity(PotionDamage)), GetPotionParticleType(PotionDamage)
GetEntityEffectIntensity(PotionDamage)), GetPotionColor(PotionDamage)
);
if (Projectile == NULL)
{

View File

@ -3,7 +3,8 @@
#include "ItemHandler.h"
#include "../World.h"
#include "../Blocks/BlockSign.h"
#include "../Blocks/BlockSignPost.h"
#include "../Blocks/BlockWallSign.h"
@ -34,12 +35,12 @@ public:
{
if (a_BlockFace == BLOCK_FACE_TOP)
{
a_BlockMeta = cBlockSignHandler::RotationToMetaData(a_Player->GetYaw());
a_BlockMeta = cBlockSignPostHandler::RotationToMetaData(a_Player->GetYaw());
a_BlockType = E_BLOCK_SIGN_POST;
}
else
{
a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace);
a_BlockMeta = cBlockWallSignHandler::DirectionToMetaData(a_BlockFace);
a_BlockType = E_BLOCK_WALLSIGN;
}
return true;

View File

@ -212,6 +212,26 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk)
return true;
}
if ((m_CurrentY < 0) || (m_CurrentY >= cChunkDef::Height))
{
// We've gone out of the world, that's the end of this trace
double IntersectX, IntersectZ;
CalcXZIntersection(m_CurrentY, IntersectX, IntersectZ);
if (m_Callbacks->OnOutOfWorld(IntersectX, m_CurrentY, IntersectZ))
{
// The callback terminated the trace
return false;
}
m_Callbacks->OnNoMoreHits();
return true;
}
// Update the current chunk
if (a_Chunk != NULL)
{
a_Chunk = a_Chunk->GetNeighborChunk(m_CurrentX, m_CurrentZ);
}
if (a_Chunk->IsValid())
{
BLOCKTYPE BlockType;
@ -233,26 +253,6 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk)
return false;
}
}
// Update the current chunk
if (a_Chunk != NULL)
{
a_Chunk = a_Chunk->GetNeighborChunk(m_CurrentX, m_CurrentZ);
}
if ((m_CurrentY < 0) || (m_CurrentY >= cChunkDef::Height))
{
// We've gone out of the world, that's the end of this trace
double IntersectX, IntersectZ;
CalcXZIntersection(m_CurrentY, IntersectX, IntersectZ);
if (m_Callbacks->OnOutOfWorld(IntersectX, m_CurrentY, IntersectZ))
{
// The callback terminated the trace
return false;
}
m_Callbacks->OnNoMoreHits();
return true;
}
}
}

View File

@ -55,7 +55,8 @@ public :
// return the mobs that are within the range of distance of the closest player they are
// that means that if a mob is 30 m from a player and 150 m from another one. It will be
// in the range [0..50] but not in [100..200]
struct sIterablePair{
struct sIterablePair
{
tDistanceToMonster::const_iterator m_Begin;
tDistanceToMonster::const_iterator m_End;
int m_Count;

View File

@ -4,9 +4,75 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
AggressiveMonster.cpp
Bat.cpp
Blaze.cpp
CaveSpider.cpp
Chicken.cpp
Cow.cpp
Creeper.cpp
EnderDragon.cpp
Enderman.cpp
Ghast.cpp
Giant.cpp
Horse.cpp
IronGolem.cpp
MagmaCube.cpp
Monster.cpp
Mooshroom.cpp
PassiveAggressiveMonster.cpp
PassiveMonster.cpp
Pig.cpp
Sheep.cpp
Skeleton.cpp
Slime.cpp
SnowGolem.cpp
Spider.cpp
Squid.cpp
Villager.cpp
Witch.cpp
Wither.cpp
Wolf.cpp
Zombie.cpp
ZombiePigman.cpp)
add_library(Mobs ${SOURCE})
SET (HDRS
AggressiveMonster.h
Bat.h
Blaze.h
CaveSpider.h
Chicken.h
Cow.h
Creeper.h
EnderDragon.h
Enderman.h
Ghast.h
Giant.h
Horse.h
IncludeAllMonsters.h
IronGolem.h
MagmaCube.h
Monster.h
Mooshroom.h
Ocelot.h
PassiveAggressiveMonster.h
PassiveMonster.h
Pig.h
Sheep.h
Silverfish.h
Skeleton.h
Slime.h
SnowGolem.h
Spider.h
Squid.h
Villager.h
Witch.h
Wither.h
Wolf.h
Zombie.h
ZombiePigman.h)
if(NOT MSVC)
add_library(Mobs ${SRCS} ${HDRS})
endif()

View File

@ -414,11 +414,7 @@ void cMonster::HandleFalling()
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
int PosY = POSY_TOINT;
if (PosY < 0)
PosY = 0;
else if (PosY > cChunkDef::Height)
PosY = cChunkDef::Height;
PosY = Clamp(PosY, 0, cChunkDef::Height);
if (!cBlockInfo::IsSolid(m_World->GetBlock((int)floor(a_PosX), PosY, (int)floor(a_PosZ))))
{
@ -684,16 +680,6 @@ void cMonster::GetMonsterConfig(const AString & a_Name)
bool cMonster::IsUndead(void)
{
switch (GetMobType())
{
case mtZombie:
case mtZombiePigman:
case mtSkeleton:
case mtWither:
{
return true;
}
}
return false;
}
@ -842,13 +828,13 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
}
case mtSlime:
{
toReturn = new cSlime(Random.NextInt(2) + 1);
toReturn = new cSlime(1 << Random.NextInt(3)); // Size 1, 2 or 4
break;
}
case mtSkeleton:
{
// TODO: Actual detection of spawning in Nether
toReturn = new cSkeleton(Random.NextInt(1) == 0 ? false : true);
toReturn = new cSkeleton((Random.NextInt(1) == 0) ? false : true);
break;
}
case mtVillager:

View File

@ -107,7 +107,7 @@ public:
void GetMonsterConfig(const AString & a_Name);
/** Returns whether this mob is undead (skeleton, zombie, etc.) */
bool IsUndead(void);
virtual bool IsUndead(void);
virtual void EventLosePlayer(void);
virtual void CheckEventLostPlayer(void);

View File

@ -22,6 +22,8 @@ public:
virtual void Attack(float a_Dt) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual bool IsUndead(void) override { return true; }
bool IsWither(void) const { return m_bIsWither; };
private:

View File

@ -2,16 +2,25 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Slime.h"
#include "FastRandom.h"
#include "World.h"
/// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest
cSlime::cSlime(int a_Size) :
super("Slime", mtSlime, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size),
super("Slime",
mtSlime,
Printf("mob.slime.%s", GetSizeName(a_Size).c_str()),
Printf("mob.slime.%s", GetSizeName(a_Size).c_str()),
0.6 * a_Size,
0.6 * a_Size
),
m_Size(a_Size)
{
SetMaxHealth(a_Size * a_Size);
SetAttackDamage(a_Size);
}
@ -25,7 +34,9 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
if (GetSize() == 1)
// Only slimes with the size 1 can drop slimeballs.
if (m_Size == 1)
{
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL);
}
@ -34,3 +45,62 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSlime::Attack(float a_Dt)
{
if (m_Size > 1)
{
// Only slimes larger than size 1 attack a player.
super::Attack(a_Dt);
}
}
void cSlime::KilledBy(TakeDamageInfo & a_TDI)
{
if (GetHealth() > 0)
{
return;
}
if (m_Size != 1)
{
cFastRandom Random;
int SpawnAmount = 2 + Random.NextInt(3);
for (int i = 0; i < SpawnAmount; ++i)
{
double AddX = (i % 2 - 0.5) * m_Size / 4.0;
double AddZ = (i / 2 - 0.5) * m_Size / 4.0;
cSlime * NewSlime = new cSlime(m_Size / 2);
NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ);
NewSlime->SetYaw(Random.NextFloat(1.0f) * 360.0f);
m_World->SpawnMobFinalize(NewSlime);
}
}
super::KilledBy(a_TDI);
}
const AString cSlime::GetSizeName(int a_Size) const
{
if (a_Size > 1)
{
return "big";
}
else
{
return "small";
}
}

View File

@ -13,17 +13,26 @@ class cSlime :
typedef cAggressiveMonster super;
public:
/// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest
/** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */
cSlime(int a_Size);
CLASS_PROTODEF(cSlime);
// cAggressiveMonster overrides:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Attack(float a_Dt) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
int GetSize(void) const { return m_Size; }
/** Returns the text describing the slime's size, as used by the client's resource subsystem for sounds.
Returns either "big" or "small". */
const AString GetSizeName(int a_Size) const;
protected:
/// Size of the slime, 1 .. 3, with 1 being the smallest
/** Size of the slime, with 1 being the smallest.
Vanilla uses sizes 1, 2 and 4 only. */
int m_Size;
} ;

View File

@ -31,6 +31,8 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual bool IsUndead(void) override { return true; }
private:
/** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */

View File

@ -19,6 +19,8 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void MoveToPosition(const Vector3d & a_Position) override;
virtual bool IsUndead(void) override { return true; }
bool IsVillagerZombie(void) const { return m_IsVillagerZombie; }
bool IsConverting (void) const { return m_IsConverting; }

View File

@ -18,6 +18,8 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual bool IsUndead(void) override { return true; }
} ;

View File

@ -519,7 +519,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS
const int BaseY = FAST_FLOOR(a_Y);
const int BaseZ = FAST_FLOOR(a_Z);
const NOISE_DATATYPE points1[4][4] = {
const NOISE_DATATYPE points1[4][4] =
{
{ IntNoise3D(BaseX - 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ - 1), },
{ IntNoise3D(BaseX - 1, BaseY, BaseZ - 1), IntNoise3D(BaseX, BaseY, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY, BaseZ - 1), },
{ IntNoise3D(BaseX - 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ - 1), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ - 1), },
@ -532,7 +533,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS
const NOISE_DATATYPE x1interp3 = CubicInterpolate( points1[2][0], points1[2][1], points1[2][2], points1[2][3], FracX);
const NOISE_DATATYPE x1interp4 = CubicInterpolate( points1[3][0], points1[3][1], points1[3][2], points1[3][3], FracX);
const NOISE_DATATYPE points2[4][4] = {
const NOISE_DATATYPE points2[4][4] =
{
{ IntNoise3D(BaseX - 1, BaseY - 1, BaseZ), IntNoise3D(BaseX, BaseY - 1, BaseZ), IntNoise3D(BaseX + 1, BaseY - 1, BaseZ), IntNoise3D(BaseX + 2, BaseY - 1, BaseZ), },
{ IntNoise3D(BaseX - 1, BaseY, BaseZ), IntNoise3D(BaseX, BaseY, BaseZ), IntNoise3D(BaseX + 1, BaseY, BaseZ), IntNoise3D(BaseX + 2, BaseY, BaseZ), },
{ IntNoise3D(BaseX - 1, BaseY + 1, BaseZ), IntNoise3D(BaseX, BaseY + 1, BaseZ), IntNoise3D(BaseX + 1, BaseY + 1, BaseZ), IntNoise3D(BaseX + 2, BaseY + 1, BaseZ), },
@ -544,7 +546,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS
const NOISE_DATATYPE x2interp3 = CubicInterpolate( points2[2][0], points2[2][1], points2[2][2], points2[2][3], FracX);
const NOISE_DATATYPE x2interp4 = CubicInterpolate( points2[3][0], points2[3][1], points2[3][2], points2[3][3], FracX);
const NOISE_DATATYPE points3[4][4] = {
const NOISE_DATATYPE points3[4][4] =
{
{ IntNoise3D( BaseX-1, BaseY-1, BaseZ+1), IntNoise3D( BaseX, BaseY-1, BaseZ+1), IntNoise3D( BaseX+1, BaseY-1, BaseZ+1), IntNoise3D( BaseX+2, BaseY-1, BaseZ + 1), },
{ IntNoise3D( BaseX-1, BaseY, BaseZ+1), IntNoise3D( BaseX, BaseY, BaseZ+1), IntNoise3D( BaseX+1, BaseY, BaseZ+1), IntNoise3D( BaseX+2, BaseY, BaseZ + 1), },
{ IntNoise3D( BaseX-1, BaseY+1, BaseZ+1), IntNoise3D( BaseX, BaseY+1, BaseZ+1), IntNoise3D( BaseX+1, BaseY+1, BaseZ+1), IntNoise3D( BaseX+2, BaseY+1, BaseZ + 1), },
@ -556,7 +559,8 @@ NOISE_DATATYPE cNoise::CubicNoise3D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y, NOIS
const NOISE_DATATYPE x3interp3 = CubicInterpolate( points3[2][0], points3[2][1], points3[2][2], points3[2][3], FracX);
const NOISE_DATATYPE x3interp4 = CubicInterpolate( points3[3][0], points3[3][1], points3[3][2], points3[3][3], FracX);
const NOISE_DATATYPE points4[4][4] = {
const NOISE_DATATYPE points4[4][4] =
{
{ IntNoise3D( BaseX-1, BaseY-1, BaseZ+2), IntNoise3D( BaseX, BaseY-1, BaseZ+2), IntNoise3D( BaseX+1, BaseY-1, BaseZ+2), IntNoise3D( BaseX+2, BaseY-1, BaseZ+2), },
{ IntNoise3D( BaseX-1, BaseY, BaseZ+2), IntNoise3D( BaseX, BaseY, BaseZ+2), IntNoise3D( BaseX+1, BaseY, BaseZ+2), IntNoise3D( BaseX+2, BaseY, BaseZ+2), },
{ IntNoise3D( BaseX-1, BaseY+1, BaseZ+2), IntNoise3D( BaseX, BaseY+1, BaseZ+2), IntNoise3D( BaseX+1, BaseY+1, BaseZ+2), IntNoise3D( BaseX+2, BaseY+1, BaseZ+2), },

View File

@ -3,13 +3,42 @@ cmake_minimum_required (VERSION 2.6)
project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
add_library(OSSupport ${SOURCE})
SET (SRCS
CriticalSection.cpp
Errors.cpp
Event.cpp
File.cpp
GZipFile.cpp
IsThread.cpp
ListenThread.cpp
Semaphore.cpp
Sleep.cpp
Socket.cpp
SocketThreads.cpp
Thread.cpp
Timer.cpp)
SET (HDRS
CriticalSection.h
Errors.h
Event.h
File.h
GZipFile.h
IsThread.h
ListenThread.h
Queue.h
Semaphore.h
Sleep.h
Socket.h
SocketThreads.h
Thread.h
Timer.h)
if(NOT MSVC)
add_library(OSSupport ${SRCS} ${HDRS})
if(UNIX)
target_link_libraries(OSSupport pthread)
endif()
endif()

View File

@ -25,15 +25,6 @@ cSocket::cSocket(xSocket a_Socket)
cSocket::~cSocket()
{
// Do NOT close the socket; this class is an API wrapper, not a RAII!
}
cSocket::operator cSocket::xSocket() const
{
return m_Socket;

View File

@ -41,7 +41,6 @@ public:
cSocket(void) : m_Socket(INVALID_SOCKET) {}
cSocket(xSocket a_Socket);
~cSocket();
bool IsValid(void) const { return IsValidSocket(m_Socket); }
void CloseSocket(void);

View File

@ -3,7 +3,7 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
set(SOURCES
set(SRCS
AesCfb128Decryptor.cpp
AesCfb128Encryptor.cpp
BlockingSslClientSocket.cpp
@ -18,7 +18,7 @@ set(SOURCES
X509Cert.cpp
)
set(HEADERS
set(HDRS
AesCfb128Decryptor.h
AesCfb128Encryptor.h
BlockingSslClientSocket.h
@ -33,8 +33,10 @@ set(HEADERS
X509Cert.h
)
add_library(PolarSSL++ ${SOURCES} ${HEADERS})
if(NOT MSVC)
add_library(PolarSSL++ ${SRCS} ${HDRS})
if (UNIX)
target_link_libraries(PolarSSL++ polarssl)
endif()
endif()

View File

@ -20,7 +20,9 @@
/** This is the data of the root certs for Starfield Technologies, the CA that signed sessionserver.mojang.com's cert:
Downloaded from http://certs.starfieldtech.com/repository/ */
static const AString gStarfieldCACert(
static const AString StarfieldCACert()
{
return AString(
// G2 cert
"-----BEGIN CERTIFICATE-----\n"
"MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n"
@ -71,6 +73,7 @@ static const AString gStarfieldCACert(
"WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n"
"-----END CERTIFICATE-----\n"
);
}
@ -263,7 +266,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
Request += "\r\n";
AString Response;
if (!SecureGetFromAddress(gStarfieldCACert, m_Server, Request, Response))
if (!SecureGetFromAddress(StarfieldCACert(), m_Server, Request, Response))
{
return false;
}
@ -343,7 +346,7 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a
Request += "\r\n";
AString Response;
if (!ConnectSecurelyToAddress(gStarfieldCACert, m_Server, Request, Response))
if (!ConnectSecurelyToAddress(StarfieldCACert(), m_Server, Request, Response))
{
return false;
}

View File

@ -4,9 +4,29 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
Authenticator.cpp
ChunkDataSerializer.cpp
Protocol125.cpp
Protocol132.cpp
Protocol14x.cpp
Protocol15x.cpp
Protocol16x.cpp
Protocol17x.cpp
ProtocolRecognizer.cpp)
add_library(Protocol ${SOURCE})
SET (HDRS
Authenticator.h
ChunkDataSerializer.h
Protocol.h
Protocol125.h
Protocol132.h
Protocol14x.h
Protocol15x.h
Protocol16x.h
Protocol17x.h
ProtocolRecognizer.h)
if(NOT MSVC)
add_library(Protocol ${SRCS} ${HDRS})
endif()

View File

@ -103,7 +103,8 @@ public:
protected:
/// Results of packet-parsing:
enum {
enum
{
PARSE_OK = 1,
PARSE_ERROR = -1,
PARSE_UNKNOWN = -2,

View File

@ -1021,9 +1021,9 @@ void cProtocolRecognizer::SendLengthlessServerPing(void)
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3099#Server_List_Ping_.280xFE.29
Printf(Reply, "%s%s%i%s%i",
Server->GetDescription().c_str(),
cChatColor::Delimiter.c_str(),
cChatColor::Delimiter,
Server->GetNumPlayers(),
cChatColor::Delimiter.c_str(),
cChatColor::Delimiter,
Server->GetMaxPlayers()
);
break;

View File

@ -30,8 +30,6 @@
#include <mach/mach.h>
#endif
extern bool g_TERMINATE_EVENT_RAISED;
@ -79,7 +77,7 @@ void cRoot::InputThread(void * a_Params)
cLogCommandOutputCallback Output;
while (!self.m_bStop && !self.m_bRestart && !g_TERMINATE_EVENT_RAISED && std::cin.good())
while (!self.m_bStop && !self.m_bRestart && !m_TerminateEventRaised && std::cin.good())
{
AString Command;
std::getline(std::cin, Command);
@ -89,7 +87,7 @@ void cRoot::InputThread(void * a_Params)
}
}
if (g_TERMINATE_EVENT_RAISED || !std::cin.good())
if (m_TerminateEventRaised || !std::cin.good())
{
// We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running; stop the server:
self.m_bStop = true;
@ -205,12 +203,12 @@ void cRoot::Start(void)
EnableMenuItem(hmenu, SC_CLOSE, MF_ENABLED); // Re-enable close button
#endif
while (!m_bStop && !m_bRestart && !g_TERMINATE_EVENT_RAISED) // These are modified by external threads
while (!m_bStop && !m_bRestart && !m_TerminateEventRaised) // These are modified by external threads
{
cSleep::MilliSleep(1000);
}
if (g_TERMINATE_EVENT_RAISED)
if (m_TerminateEventRaised)
{
m_bStop = true;
}

View File

@ -40,6 +40,8 @@ namespace Json
class cRoot
{
public:
static bool m_TerminateEventRaised;
static cRoot * Get() { return s_Root; }
// tolua_end

View File

@ -45,7 +45,8 @@ AString cObjective::TypeToString(eType a_Type)
cObjective::eType cObjective::StringToType(const AString & a_Name)
{
static struct {
static struct
{
eType m_Type;
const char * m_String;
} TypeMap [] =

View File

@ -30,7 +30,8 @@
#include <sstream>
#include <iostream>
extern "C" {
extern "C"
{
#include "zlib/zlib.h"
}
@ -221,12 +222,14 @@ bool cServer::InitServer(cIniFile & a_SettingsIni)
bool HasAnyPorts = false;
AString Ports = a_SettingsIni.GetValueSet("Server", "Port", "25565");
m_ListenThreadIPv4.SetReuseAddr(true);
if (m_ListenThreadIPv4.Initialize(Ports))
{
HasAnyPorts = true;
}
Ports = a_SettingsIni.GetValueSet("Server", "PortsIPv6", "25565");
m_ListenThreadIPv6.SetReuseAddr(true);
if (m_ListenThreadIPv6.Initialize(Ports))
{
HasAnyPorts = true;
@ -395,7 +398,7 @@ void cServer::TickClients(float a_Dt)
{
if ((*itr)->IsDestroyed())
{
// Remove the client later, when CS is not held, to avoid deadlock ( http://forum.mc-server.org/showthread.php?tid=374 )
// Remove the client later, when CS is not held, to avoid deadlock: http://forum.mc-server.org/showthread.php?tid=374
RemoveClients.push_back(*itr);
itr = m_Clients.erase(itr);
continue;

View File

@ -4,9 +4,34 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
DelayedFluidSimulator.cpp
FireSimulator.cpp
FloodyFluidSimulator.cpp
FluidSimulator.cpp
IncrementalRedstoneSimulator.cpp
RedstoneSimulator.cpp
SandSimulator.cpp
Simulator.cpp
SimulatorManager.cpp
VanillaFluidSimulator.cpp
VaporizeFluidSimulator.cpp)
add_library(Simulator ${SOURCE})
SET (HDRS
DelayedFluidSimulator.h
FireSimulator.h
FloodyFluidSimulator.h
FluidSimulator.h
IncrementalRedstoneSimulator.h
NoopFluidSimulator.h
NoopRedstoneSimulator.h
RedstoneSimulator.h
SandSimulator.h
Simulator.h
SimulatorManager.h
VanillaFluidSimulator.h
VaporizeFluidSimulator.h)
if(NOT MSVC)
add_library(Simulator ${SRCS} ${HDRS})
endif()

View File

@ -7,7 +7,8 @@
cStatInfo cStatInfo::ms_Info[statCount] = {
cStatInfo cStatInfo::ms_Info[statCount] =
{
// The order must match the order of enum eStatistic
// http://minecraft.gamepedia.com/Achievements

View File

@ -510,7 +510,8 @@ temp variable, some decrements & conditionals. The switches
are equivalent to the following loop:
{
int tmpBytesToRead = extraBytesToRead + 1;
do {
do
{
ch += *source++;
--tmpBytesToRead;
if (tmpBytesToRead) ch <<= 6;
@ -784,7 +785,8 @@ AString Base64Decode(const AString & a_Base64String)
AString Base64Encode(const AString & a_Input)
{
static const char BASE64[64] = {
static const char BASE64[64] =
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',

View File

@ -4,9 +4,15 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
SlotArea.cpp
Window.cpp)
add_library(UI ${SOURCE})
SET (HDRS
SlotArea.h
Window.h
WindowOwner.h)
if(NOT MSVC)
add_library(UI ${SRCS} ${HDRS})
endif()

View File

@ -579,11 +579,6 @@ void cWorld::Start(void)
int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather);
m_TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay);
if (GetDimension() == dimOverworld)
{
m_NetherWorldName = IniFile.GetValueSet("LinkedWorlds", "NetherWorldName", DEFAULT_NETHER_NAME);
m_EndWorldName = IniFile.GetValueSet("LinkedWorlds", "EndWorldName", DEFAULT_END_NAME);
}
else
{
m_OverworldName = IniFile.GetValueSet("LinkedWorlds", "OverworldName", GetLinkedOverworldName());

View File

@ -4,11 +4,34 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
file(GLOB SOURCE
"*.cpp"
"*.h"
)
SET (SRCS
EnchantmentSerializer.cpp
FastNBT.cpp
FireworksSerializer.cpp
MapSerializer.cpp
NBTChunkSerializer.cpp
SchematicFileSerializer.cpp
ScoreboardSerializer.cpp
StatSerializer.cpp
WSSAnvil.cpp
WSSCompact.cpp
WorldStorage.cpp)
add_library(WorldStorage ${SOURCE})
SET (HDRS
EnchantmentSerializer.h
FastNBT.h
FireworksSerializer.h
MapSerializer.h
NBTChunkSerializer.h
SchematicFileSerializer.h
ScoreboardSerializer.h
StatSerializer.h
WSSAnvil.h
WSSCompact.h
WorldStorage.h)
if(NOT MSVC)
add_library(WorldStorage ${SRCS} ${HDRS})
target_link_libraries(WorldStorage OSSupport)
endif()

View File

@ -614,7 +614,8 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration());
m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
m_Writer.AddInt("PotionName", Potion->GetPotionParticleType());
m_Writer.AddInt("PotionName", Potion->GetPotionColor());
break;
}
case cProjectileEntity::pkGhastFireball:
{

View File

@ -1681,7 +1681,7 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN
SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType"));
SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier));
SplashPotion->SetPotionParticleType(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
// Store the new splash potion in the entities list:
a_Entities.push_back(SplashPotion.release());

View File

@ -448,15 +448,21 @@ cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_
switch (m_ChunkVersion)
{
case 1:
{
m_ChunkSize.Set(16, 128, 16);
break;
}
case 2:
case 3:
{
m_ChunkSize.Set(16, 256, 16);
break;
}
default:
{
LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion);
return;
}
};
short NumChunks = 0;

View File

@ -101,7 +101,8 @@ protected:
}
} ;
struct FuncTable {
struct FuncTable
{
static void Delete(sChunkLoad) {};
static void Combine(sChunkLoad & a_orig, const sChunkLoad a_new)
{

View File

@ -11,9 +11,9 @@
#include <dbghelp.h>
#endif // _MSC_VER
// Here, we have some ALL CAPS variables, to give the impression that this is deeeep, gritty programming :P
bool g_TERMINATE_EVENT_RAISED = false; // If something has told the server to stop; checked periodically in cRoot
bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so our CTRL handler can then tell Windows to close the console
bool cRoot::m_TerminateEventRaised = false; // If something has told the server to stop; checked periodically in cRoot
static bool g_ServerTerminated = false; // Set to true when the server terminates, so our CTRL handler can then tell the OS to close the console
@ -52,7 +52,7 @@ bool g_ShouldLogCommOut;
void NonCtrlHandler(int a_Signal)
{
LOGD("Terminate event raised from std::signal");
g_TERMINATE_EVENT_RAISED = true;
cRoot::m_TerminateEventRaised = true;
switch (a_Signal)
{
@ -155,12 +155,12 @@ LONG WINAPI LastChanceExceptionFilter(__in struct _EXCEPTION_POINTERS * a_Except
// Handle CTRL events in windows, including console window close
BOOL CtrlHandler(DWORD fdwCtrlType)
{
g_TERMINATE_EVENT_RAISED = true;
cRoot::m_TerminateEventRaised = true;
LOGD("Terminate event raised from the Windows CtrlHandler");
if (fdwCtrlType == CTRL_CLOSE_EVENT) // Console window closed via 'x' button, Windows will try to close immediately, therefore...
{
while (!g_SERVER_TERMINATED) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly
while (!g_ServerTerminated) { cSleep::MilliSleep(100); } // Delay as much as possible to try to get the server to shut down cleanly
}
return TRUE;
@ -296,7 +296,7 @@ int main( int argc, char **argv )
DeinitLeakFinder();
#endif
g_SERVER_TERMINATED = true;
g_ServerTerminated = true;
return EXIT_SUCCESS;
}