summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile18
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua349
-rw-r--r--MCServer/Plugins/APIDump/main.lua53
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua52
-rw-r--r--MCServer/items.ini2
-rw-r--r--VC2008/MCServer.vcproj4
-rw-r--r--source/AllToLua.pkg3
-rw-r--r--source/Bindings.cpp893
-rw-r--r--source/Bindings.h2
-rw-r--r--source/BlockEntities/BlockEntity.cpp44
-rw-r--r--source/BlockEntities/BlockEntity.h5
-rw-r--r--source/BlockEntities/ChestEntity.cpp10
-rw-r--r--source/BlockEntities/ChestEntity.h4
-rw-r--r--source/BlockEntities/DispenserEntity.cpp10
-rw-r--r--source/BlockEntities/DispenserEntity.h3
-rw-r--r--source/BlockEntities/DropperEntity.cpp10
-rw-r--r--source/BlockEntities/DropperEntity.h3
-rw-r--r--source/BlockEntities/FurnaceEntity.cpp23
-rw-r--r--source/BlockEntities/FurnaceEntity.h3
-rw-r--r--source/BlockEntities/HopperEntity.cpp11
-rw-r--r--source/BlockEntities/HopperEntity.h3
-rw-r--r--source/BlockEntities/JukeboxEntity.cpp34
-rw-r--r--source/BlockEntities/JukeboxEntity.h31
-rw-r--r--source/BlockEntities/NoteEntity.cpp27
-rw-r--r--source/BlockEntities/NoteEntity.h33
-rw-r--r--source/BlockEntities/SignEntity.cpp67
-rw-r--r--source/BlockEntities/SignEntity.h40
-rw-r--r--source/BlockID.cpp23
-rw-r--r--source/Blocks/BlockCrops.h6
-rw-r--r--source/Chunk.cpp91
-rw-r--r--source/ClientHandle.cpp12
-rw-r--r--source/ClientHandle.h1
-rw-r--r--source/Entities/Player.cpp107
-rw-r--r--source/Entities/Player.h33
-rw-r--r--source/Generating/Caves.cpp104
-rw-r--r--source/Generating/ChunkDesc.cpp47
-rw-r--r--source/Generating/ChunkDesc.h7
-rw-r--r--source/Generating/ChunkGenerator.cpp36
-rw-r--r--source/Generating/DistortedHeightmap.cpp24
-rw-r--r--source/Generating/EndGen.cpp30
-rw-r--r--source/Generating/MineShafts.cpp123
-rw-r--r--source/Generating/Noise3DGenerator.cpp57
-rw-r--r--source/LineBlockTracer.cpp6
-rw-r--r--source/LinearUpscale.h18
-rw-r--r--source/Log.cpp2
-rw-r--r--source/Mobs/Giant.cpp1
-rw-r--r--source/PluginManager.cpp48
-rw-r--r--source/Protocol/Protocol.h3
-rw-r--r--source/Protocol/Protocol125.cpp15
-rw-r--r--source/Protocol/Protocol125.h1
-rw-r--r--source/Protocol/Protocol17x.cpp12
-rw-r--r--source/Protocol/Protocol17x.h1
-rw-r--r--source/Protocol/ProtocolRecognizer.cpp10
-rw-r--r--source/Protocol/ProtocolRecognizer.h1
-rw-r--r--source/Root.cpp2
55 files changed, 1453 insertions, 1105 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 338470592..d8afc0525 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -46,8 +46,9 @@ ifeq ($(release),1)
################
# release build - fastest run-time, no gdb support
################
-CC_OPTIONS = -s -g -O3 -DNDEBUG
-CXX_OPTIONS = -s -g -O3 -DNDEBUG
+
+CC_OPTIONS = -g -O3 -DNDEBUG
+CXX_OPTIONS = -g -O3 -DNDEBUG
LNK_OPTIONS = -pthread -O3
BUILDDIR = build/release/
@@ -56,6 +57,7 @@ ifeq ($(profile),1)
################
# profile build - a release build with symbols and profiling engine built in
################
+
CC_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
CXX_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
LNK_OPTIONS = -pthread -ggdb -O3 -pg
@@ -66,6 +68,7 @@ ifeq ($(pedantic),1)
################
# pedantic build - basically a debug build with lots of warnings
################
+
CC_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
CXX_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
LNK_OPTIONS = -pthread -ggdb
@@ -76,6 +79,7 @@ else
# debug build - fully traceable by gdb in C++ code, slowest
# Since C code is used only for supporting libraries (zlib, lua), it is still O3-optimized
################
+
CC_OPTIONS = -s -ggdb -g -D_DEBUG -O3
CXX_OPTIONS = -s -ggdb -g -D_DEBUG
LNK_OPTIONS = -pthread -g -ggdb
@@ -84,6 +88,10 @@ endif
endif
endif
+##################################################
+# Always be warning.
+
+CXX_OPTIONS += -Wall
###################################################
# Fix Crypto++ warnings in clang
@@ -103,7 +111,7 @@ endif
UNAME := $(shell uname -s)
ifeq ($(UNAME),Linux)
- LNK_LIBS = -lstdc++ -ldl
+ LNK_LIBS = -lstdc++ -ldl -lm
else
LNK_LIBS = -lstdc++ -lltdl
endif
@@ -140,7 +148,6 @@ endif
###################################################
# INCLUDE directories for MCServer
-#
INCLUDE = -I.\
-Isource\
@@ -162,9 +169,6 @@ INCLUDE = -I.\
###################################################
# Build MCServer
-#
-
-# 2012_11_08 _X: Removed: squirrel_3_0_1_stable
SOURCES := $(shell find CryptoPP lua-5.1.4 jsoncpp-src-0.5.0 zlib-1.2.7 source tolua++-1.0.93 iniFile expat '(' -name '*.cpp' -o -name '*.c' ')')
SOURCES := $(filter-out %minigzip.c %lua.c %tolua.c %toluabind.c %LeakFinder.cpp %StackWalker.cpp %example.c,$(SOURCES))
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 321f50732..450bc9f28 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -403,20 +403,12 @@ g_APIDesc =
in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate
in any way.</p>
<p>
- The chest entity can be created by the plugins only in the {{OnChunkGenerating}} and
- {{OnChunkGenerated}} hooks, as part of the new chunk being generated. Plugins may generate chests
- with contents in this way.</p>
- <p>
To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with
either DoWithChestAt() or ForEachChestInChunk() function. See the code example below
]],
Inherits = "cBlockEntityWithItems",
- Functions =
- {
- constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cChestEntity", Notes = "Creates a new cChestEntity object. To be used only in the chunk generating hooks {{OnChunkGenerating}} and {{OnChunkGenerated}}." },
- },
Constants =
{
ContentsHeight = { Notes = "Height of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" },
@@ -466,6 +458,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
{ Params = "MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta", Return = "", Notes = "Fills those blocks of the cuboid (specified in relative coords) that are considered non-floor (air, water) with the specified block type and meta. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." },
},
GetBiome = { Params = "RelX, RelZ", Return = "EMCSBiome", Notes = "Returns the biome at the specified relative coords" },
+ GetBlockEntity = { Params = "RelX, RelY, RelZ", Return = "{{cBlockEntity}} descendant", Notes = "Returns the block entity for the block at the specified coords. Creates it if it doesn't exist. Returns nil if the block has no block entity capability." },
GetBlockMeta = { Params = "RelX, RelY, RelZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified relative coords" },
GetBlockType = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" },
GetBlockTypeMeta = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" },
@@ -504,7 +497,42 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
Constants =
{
},
- },
+ AdditionalInfo =
+ {
+ {
+ Header = "Manipulating block entities",
+ Contents = [[
+ To manipulate block entities while the chunk is generated, first use SetBlockTypeMeta() to set
+ the correct block type and meta at the position. Then use the GetBlockEntity() to create and
+ return the correct block entity instance. Finally, use {{tolua}}.cast() to cast to the proper
+ type.</p>
+ Note that you don't need to check if a block entity has previously existed at the place, because
+ GetBlockEntity() will automatically re-create the correct type for you.</p>
+ <p>
+ The following code is taken from the Debuggers plugin, it creates a sign at each chunk's [0, 0]
+ coords, with the text being the chunk coords:
+<pre class="prettyprint lang-lua">
+function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
+ -- Get the topmost block coord:
+ local Height = a_ChunkDesc:GetHeight(0, 0);
+
+ -- Create a sign there:
+ a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0);
+ local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0);
+ if (BlockEntity ~= nil) then
+ LOG("Setting sign lines...");
+ local SignEntity = tolua.cast(BlockEntity, "cSignEntity");
+ SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)");
+ end
+
+ -- Update the heightmap:
+ a_ChunkDesc:SetHeight(0, 0, Height + 1);
+end
+</pre>
+ ]],
+ },
+ }, -- AdditionalInfo
+ }, -- cChunkDesc
cClientHandle =
{
@@ -642,40 +670,31 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
cDispenserEntity =
{
- Desc = [[This class represents a dispenser block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with a {{cDropperEntity|dropper}} entity.
-</p>
- <p>An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks).
-]],
- Functions =
- {
- constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cDispenserEntity", Notes = "Creates a new cDispenserEntity at the specified coords" },
- },
- Constants =
- {
- },
+ Desc = [[
+ This class represents a dispenser block entity in the world. Most of this block entity's
+ functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents
+ the behavior common with a {{cDropperEntity|dropper}} entity.
+ ]],
Inherits = "cDropSpenserEntity",
},
cDropperEntity =
{
- Desc = [[This class represents a dropper block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with the {{cDispenserEntity|dispenser}} entity.
-</p>
- <p>An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks).
-]],
- Functions =
- {
- constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cDropperEntity", Notes = "Creates a new cDropperEntity at the specified coords" },
- },
- Constants =
- {
- },
+ Desc = [[
+ This class represents a dropper block entity in the world. Most of this block entity's functionality
+ is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior
+ common with the {{cDispenserEntity|dispenser}} entity.</p>
+ <p>
+ An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks).
+ ]],
Inherits = "cDropSpenserEntity",
- },
+ }, -- cDropperEntity
cDropSpenserEntity =
{
- Desc = [[This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}.
-]],
+ Desc = [[
+ This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}.
+ ]],
Functions =
{
Activate = { Params = "", Return = "", Notes = "Sets the block entity to dropspense an item in the next tick" },
@@ -687,9 +706,8 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" },
ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" },
},
-
Inherits = "cBlockEntityWithItems";
- },
+ }, -- cDropSpenserEntity
cEnchantments =
{
@@ -738,6 +756,8 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
enchInfinity = { Notes = "" },
enchKnockback = { Notes = "" },
enchLooting = { Notes = "" },
+ enchLuckOfTheSea = { Notes = "" },
+ enchLure = { Notes = "" },
enchPower = { Notes = "" },
enchProjectileProtection = { Notes = "" },
enchProtection = { Notes = "" },
@@ -913,7 +933,6 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
cFile:Delete("/usr/bin/virus.exe");
</pre></p>
]],
-
Functions =
{
Copy = { Params = "SrcFileName, DstFileName", Return = "bool", Notes = "Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists." },
@@ -925,8 +944,7 @@ cFile:Delete("/usr/bin/virus.exe");
IsFolder = { Params = "Path", Return = "bool", Notes = "Returns true if the specified path points to an existing folder." },
Rename = { Params = "OrigPath, NewPath", Return = "bool", Notes = "Renames a file or a folder. Returns true if successful. Undefined result if NewPath already exists." },
},
-
- },
+ }, -- cFile
cFireChargeEntity =
{
@@ -938,11 +956,11 @@ cFile:Delete("/usr/bin/virus.exe");
cFurnaceEntity =
{
- Desc = [[This class represents a furnace block entity in the world. An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks)
-]],
+ Desc = [[
+ This class represents a furnace block entity in the world.
+ ]],
Functions =
{
- constructor = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "cFurnaceEntity", Notes = "Creates a new cFurnaceEntity at the specified coords and the specified block type / meta" },
GetCookTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current item finishes cooking, in ticks" },
GetFuelBurnTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current fuel is depleted, in ticks" },
GetFuelSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the fuel slot" },
@@ -996,14 +1014,10 @@ cFile:Delete("/usr/bin/virus.exe");
cHopperEntity =
{
Desc = [[
- This class represents a hopper block entity in the world.</p>
- <p>
- Plugins may use this class during chunk generation ({{OnChunkGenerated|HOOK_CHUNK_GENERATED}} and
- {{OnChunkGenerating|HOOK_CHUNK_GENERATING}}) to add hoppers to the generated chunk.
+ This class represents a hopper block entity in the world.
]],
Functions =
{
- constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cHopperEntity", Notes = "Creates and returns a new hopper at the specified coords." },
GetOutputBlockPos = { Params = "BlockMeta", Return = "bool, BlockX, BlockY, BlockZ", Notes = "Returns whether the hopper is attached, and if so, the block coords of the block receiving the output items, based on the given meta." },
},
Constants =
@@ -1255,6 +1269,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins,
DamageItem = { Params = "[Amount]", Return = "bool", Notes = "Adds the specified damage. Returns true when damage reaches max value and the item should be destroyed (but doesn't destroy the item)" },
Empty = { Params = "", Return = "", Notes = "Resets the instance to an empty item" },
GetMaxDamage = { Params = "", Return = "number", Notes = "Returns the maximum value for damage that this item can get before breaking; zero if damage is not accounted for for this item type" },
+ GetMaxStackSize = { Params = "", Return = "number", Notes = "Returns the maximum stack size for this item." },
IsDamageable = { Params = "", Return = "bool", Notes = "Returns true if this item does account for its damage" },
IsEmpty = { Params = "", Return = "bool", Notes = "Returns true if this object represents an empty item (zero count or invalid ID)" },
IsEqual = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is the same as the one stored in the object (type, damage and enchantments)" },
@@ -1452,6 +1467,22 @@ end
},
}, -- cItems
+ cJukeboxEntity =
+ {
+ Desc = [[
+ This class represents a jukebox in the world. It can play the records, either when the
+ {{cPlayer|player}} uses the record on the jukebox, or when a plugin instructs it to play.
+ ]],
+ Inherits = "cBlockEntity",
+ Functions =
+ {
+ EjectRecord = { Params = "", Return = "", Notes = "Ejects the current record as a {{cPickup|pickup}}. No action if there's no current record. To remove record without generating the pickup, use SetRecord(0)" },
+ GetRecord = { Params = "", Return = "number", Notes = "Returns the record currently present. Zero for no record, E_ITEM_*_DISC for records." },
+ PlayRecord = { Params = "", Return = "", Notes = "Plays the currently present record. No action if there's no current record." },
+ SetRecord = { Params = "number", Return = "", Notes = "Sets the currently present record. Use zero for no record, or E_ITEM_*_DISC for records." },
+ },
+ }, -- cJukeboxEntity
+
cLineBlockTracer =
{
Desc = [[Objects of this class provide an easy-to-use interface to tracing lines through individual
@@ -1683,7 +1714,26 @@ a_Player:OpenWindow(Window);
mtZombiePigman = { Notes = "" },
},
Inherits = "cPawn",
- },
+ }, -- cMonster
+
+ cNoteEntity =
+ {
+ Desc = [[
+ This class represents a note block entity in the world. It takes care of the note block's pitch,
+ and also can play the sound, either when the {{cPlayer|player}} right-clicks it, redstone activates
+ it, or upon a plugin's request.</p>
+ <p>
+ The pitch is stored as an integer between 0 and 24.
+ ]],
+ Functions =
+ {
+ GetPitch = { Params = "", Return = "number", Notes = "Returns the current pitch set for the block" },
+ IncrementPitch = { Params = "", Return = "", Notes = "Adds 1 to the current pitch. Wraps around to 0 when the pitch cannot go any higher." },
+ MakeSound = { Params = "", Return = "", Notes = "Plays the sound for all {{cClientHandle|clients}} near this block." },
+ SetPitch = { Params = "Pitch", Return = "", Notes = "Sets a new pitch for the block." },
+ },
+ Inherits = "cBlockEntity",
+ }, -- cNoteEntity
cPawn =
{
@@ -1852,7 +1902,7 @@ a_Player:OpenWindow(Window);
<pre class="prettyprint lang-lua">
cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
</pre></p>
-]],
+ ]],
Functions =
{
AddHook =
@@ -1872,7 +1922,6 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
},
DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." },
ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." },
- ExecuteConsoleCommand = { Params = "CommandStr", Return = "bool", Notes = "Executes the command as if given on the server console. Returns true if executed." },
FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" },
ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" },
ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature: <pre class=\"prettyprint lang-lua\">function(Command, Permission, HelpString)</pre>. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." },
@@ -2000,8 +2049,8 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
GetVirtualRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of virtual RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." },
GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object." },
GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world. It returns nil if there is no world with the given name." },
- QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread The command's output will be sent to console " .. '"stop" and "restart" commands have special handling.' },
- SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds." },
+ QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread. The command's output will be sent to console." },
+ SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds. Note that the saving is queued on each world's tick thread and this functions returns before the chunks are actually saved." },
SetPrimaryServerVersion = { Params = "Protocol Version", Return = "", Notes = "Sets the servers PrimaryServerVersion to the given protocol number." }
},
Constants =
@@ -2030,35 +2079,22 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
Constants =
{
},
- },
+ }, -- cServer
cSignEntity =
{
Desc = [[
A sign entity represents a sign in the world. This class is only used when generating chunks, so
- that the plugins may generate signs within new chunks.
+ that the plugins may generate signs within new chunks. See the code example in {{cChunkDesc}}.
]],
Functions =
{
+ GetLine = { Params = "LineIndex", Return = "string", Notes = "Returns the specified line. LineIndex is expected between 0 and 3. Returns empty string and logs to server console when LineIndex is invalid." },
+ SetLine = { Params = "LineIndex, LineText", Return = "", Notes = "Sets the specified line. LineIndex is expected between 0 and 3. Logs to server console when LineIndex is invalid." },
+ SetLines = { Params = "Line1, Line2, Line3, Line4", Return = "", Notes = "Sets all the sign's lines at once." },
},
- Constants =
- {
- },
-
Inherits = "cBlockEntity";
- },
-
- cStringMap =
- {
- Desc = [[cStringMap is an object that maps strings with strings, it's also known as a dictionary
-]],
- Functions =
- {
- },
- Constants =
- {
- },
- },
+ }, -- cSignEntity
cThrownEggEntity =
{
@@ -2238,7 +2274,6 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
},
GetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block skylight of the block at the specified coords, or 0 if the appropriate chunk is not loaded." },
GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BlockValid, BlockType, BlockMeta", Notes = "Returns the block type and metadata for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true." },
- GetClassStatic = { Params = "", Return = "string", Notes = "Returns the name of the class, \"cWorld\"." },
GetDimension = { Params = "", Return = "eDimension", Notes = "Returns the dimension of the world - dimOverworld, dimNether or dimEnd." },
GetGameMode = { Params = "", Return = "eGameMode", Notes = "Returns the gamemode of the world - gmSurvival, gmCreative or gmAdventure." },
GetGeneratorQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks that are queued in the chunk generator." },
@@ -2443,6 +2478,112 @@ end
},
}, -- ItemCategory
+ lxp =
+ {
+ Desc = [[
+ This class provides an interface to the XML parser,
+ {{http://matthewwild.co.uk/projects/luaexpat/|LuaExpat}}. It provides a SAX interface with an
+ incremental XML parser.</p>
+ <p>
+ With an event-based API like SAX the XML document can be fed to the parser in chunks, and the
+ parsing begins as soon as the parser receives the first document chunk. LuaExpat reports parsing
+ events (such as the start and end of elements) directly to the application through callbacks. The
+ parsing of huge documents can benefit from this piecemeal operation.</p>
+ <p>
+ See the online
+ {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}} for details
+ on how to work with this parser. The code examples below should provide some basic help, too.
+ ]],
+ Functions =
+ {
+ new = {Params = "CallbacksTable, [SeparatorChar]", Return = "XMLParser object", Notes = "Creates a new XML parser object, with the specified callbacks table and optional separator character."},
+ },
+ Constants =
+ {
+ _COPYRIGHT = { Notes = "" },
+ _DESCRIPTION = { Notes = "" },
+ _VERSION = { Notes = "" },
+ },
+ AdditionalInfo =
+ {
+ {
+ Header = "Parser callbacks",
+ Contents = [[
+ The callbacks table passed to the new() function specifies the Lua functions that the parser
+ calls upon various events. The following table lists the most common functions used, for a
+ complete list see the online
+ {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}}.</p>
+ <table>
+ <tr><th>Function name</th><th>Parameters</th><th>Notes</th></tr>
+ <tr><td>CharacterData</td><td>Parser, string</td><td>Called when the parser recognizes a raw string inside the element</td></tr>
+ <tr><td>EndElement</td><td>Parser, ElementName</td><td>Called when the parser detects the ending of an XML element</td></tr>
+ <tr><td>StartElement</td><td>Parser, ElementName, AttributesTable</td><td>Called when the parser detects the start of an XML element. The AttributesTable is a Lua table containing all the element's attributes, both in the array section (in the order received) and in the dictionary section.</td></tr>
+ </table>
+ ]],
+ },
+ {
+ Header = "XMLParser object",
+ Contents = [[
+ The XMLParser object returned by lxp.new provides the functions needed to parse the XML. The
+ following list provides the most commonly used ones, for a complete list see the online
+ {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}}.
+ <ul>
+ <li>close() - closes the parser, freeing all memory used by it.</li>
+ <li>getCallbacks() - returns the callbacks table for this parser.</li>
+ <li>parse(string) - parses more document data. the string contains the next part (or possibly all) of the document. Returns non-nil for success or nil, msg, line, col, pos for error.</li>
+ <li>stop() - aborts parsing (can be called from within the parser callbacks).</li>
+ </ul>
+ ]],
+ },
+ {
+ Header = "Code example",
+ Contents = [[
+ The following code reads an entire XML file and outputs its logical structure into the console:
+<pre class="prettyprint lang-lua">
+local Depth = 0;
+
+-- Define the callbacks:
+local Callbacks = {
+ CharacterData = function(a_Parser, a_String)
+ LOG(string.rep(" ", Depth) .. "* " .. a_String);
+ end
+
+ EndElement = function(a_Parser, a_ElementName)
+ Depth = Depth - 1;
+ LOG(string.rep(" ", Depth) .. "- " .. a_ElementName);
+ end
+
+ StartElement = function(a_Parser, a_ElementName, a_Attribs)
+ LOG(string.rep(" ", Depth) .. "+ " .. a_ElementName);
+ Depth = Depth + 1;
+ end
+}
+
+-- Create the parser:
+local Parser = lxp.new(Callbacks);
+
+-- Parse the XML file:
+local f = io.open("file.xml", "rb");
+while (true) do
+ local block = f:read(128 * 1024); -- Use a 128KiB buffer for reading
+ if (block == nil) then
+ -- End of file
+ break;
+ end
+ Parser:parse(block);
+end
+
+-- Signalize to the parser that no more data is coming
+Parser:parse();
+
+-- Close the parser:
+Parser:close();
+</pre>
+ ]],
+ },
+ }, -- AdditionalInfo
+ }, -- lxp
+
TakeDamageInfo =
{
Desc = [[
@@ -2525,7 +2666,10 @@ end
Vector3d =
{
Desc = [[
- A Vector3d object uses double precision floating point values to describe a point in 3D space.
+ A Vector3d object uses double precision floating point values to describe a point in 3D space.</p>
+ <p>
+ See also {{Vector3f}} for single-precision floating point 3D coords and {{Vector3i}} for integer
+ 3D coords.
]],
Functions =
{
@@ -2566,25 +2710,72 @@ end
Vector3f =
{
- Desc = [[A Vector3f object uses floating point values to describe a point in space. Vector3f is part of the {{vector3|vector3}} family.
-]],
+ Desc = [[
+ A Vector3f object uses floating point values to describe a point in space.</p>
+ <p>
+ See also {{Vector3d}} for double-precision floating point 3D coords and {{Vector3i}} for integer
+ 3D coords.
+ ]],
Functions =
{
+ constructor =
+ {
+ { Params = "", Return = "Vector3f", Notes = "Creates a new Vector3f object with zero coords" },
+ { Params = "x, y, z", Return = "Vector3f", Notes = "Creates a new Vector3f object with the specified coords" },
+ { Params = "Vector3f", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified vector" },
+ { Params = "{{Vector3d}}", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified {{Vector3d}}" },
+ { Params = "{{Vector3i}}", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified {{Vector3i}}" },
+ },
+ operator_mul =
+ {
+ { Params = "number", Return = "Vector3f", Notes = "Returns a new Vector3f object that has each of its coords multiplied by the specified number" },
+ { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that has each of its coords multiplied by the respective coord of the specified vector." },
+ },
+ operator_plus = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the vector sum of this vector and the specified vector." },
+ operator_sub = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the vector differrence between this vector and the specified vector." },
+ Cross = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the cross product of this vector and the specified vector." },
+ Dot = { Params = "Vector3f", Return = "number", Notes = "Returns the dot product of this vector and the specified vector." },
+ Equals = { Params = "Vector3f", Return = "bool", Notes = "Returns true if the specified vector is exactly equal to this vector." },
+ Length = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector" },
+ Normalize = { Params = "", Return = "", Notes = "Normalizes this vector (makes it 1 unit long while keeping the direction). FIXME: Fails for zero vectors." },
+ NormalizeCopy = { Params = "", Return = "Vector3f", Notes = "Returns a copy of this vector that is normalized (1 unit long while keeping the same direction). FIXME: Fails for zero vectors." },
+ Set = { Params = "x, y, z", Return = "", Notes = "Sets all the coords of the vector at once." },
+ SqrLength = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector, squared. This operation is slightly less computationally expensive than Length(), while it conserves some properties of Length(), such as comparison." },
},
- Constants =
+ Variables =
{
+ x = { Type = "number", Notes = "The X coord of the vector." },
+ y = { Type = "number", Notes = "The Y coord of the vector." },
+ z = { Type = "number", Notes = "The Z coord of the vector." },
},
}, -- Vector3f
Vector3i =
{
- Desc = [[A Vector3i object uses integer values to describe a point in space. Vector3i is part of the {{vector3|vector3}} family.
-]],
+ Desc = [[
+ A Vector3i object uses integer values to describe a point in space.</p>
+ <p>
+ See also {{Vector3d}} for double-precision floating point 3D coords and {{Vector3f}} for
+ single-precision floating point 3D coords.
+ ]],
Functions =
{
+ constructor =
+ {
+ { Params = "", Return = "Vector3i", Notes = "Creates a new Vector3i object with zero coords." },
+ { Params = "x, y, z", Return = "Vector3i", Notes = "Creates a new Vector3i object with the specified coords." },
+ { Params = "{{Vector3d}}", Return = "Vector3i", Notes = "Creates a new Vector3i object with coords copied and floor()-ed from the specified {{Vector3d}}." },
+ },
+ Equals = { Params = "Vector3i", Return = "bool", Notes = "Returns true if this vector is exactly the same as the specified vector." },
+ Length = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector." },
+ Set = { Params = "x, y, z", Return = "", Notes = "Sets all the coords of the vector at once" },
+ SqrLength = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector, squared. This operation is slightly less computationally expensive than Length(), while it conserves some properties of Length(), such as comparison." },
},
- Constants =
+ Variables =
{
+ x = { Type = "number", Notes = "The X coord of the vector." },
+ y = { Type = "number", Notes = "The Y coord of the vector." },
+ z = { Type = "number", Notes = "The Z coord of the vector." },
},
}, -- Vector3i
diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua
index d84926b53..fa9d29423 100644
--- a/MCServer/Plugins/APIDump/main.lua
+++ b/MCServer/Plugins/APIDump/main.lua
@@ -373,13 +373,18 @@ function ReadDescriptions(a_API)
return false;
end
- -- Returns true if the function (specified by its fully qualified name) is to be ignored
- local function IsFunctionIgnored(a_FnName)
+ -- Returns true if the function is to be ignored
+ local function IsFunctionIgnored(a_ClassName, a_FnName)
if (g_APIDesc.IgnoreFunctions == nil) then
return false;
end
+ if (((g_APIDesc.Classes[a_ClassName] or {}).Functions or {})[a_FnName] ~= nil) then
+ -- The function is documented, don't ignore
+ return false;
+ end
+ local FnName = a_ClassName .. "." .. a_FnName;
for i, name in ipairs(g_APIDesc.IgnoreFunctions) do
- if (a_FnName:match(name)) then
+ if (FnName:match(name)) then
return true;
end
end
@@ -482,7 +487,7 @@ function ReadDescriptions(a_API)
if (FnDesc == nil) then
-- No description for this API function
AddFunction(func.Name);
- if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then
+ if not(IsFunctionIgnored(cls.Name, FnName)) then
table.insert(cls.UndocumentedFunctions, FnName);
end
else
@@ -505,7 +510,7 @@ function ReadDescriptions(a_API)
else -- if (APIDesc.Functions ~= nil)
for j, func in ipairs(cls.Functions) do
local FnName = func.DocID or func.Name;
- if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then
+ if not(IsFunctionIgnored(cls.Name, FnName)) then
table.insert(cls.UndocumentedFunctions, FnName);
end
end
@@ -567,7 +572,7 @@ function ReadDescriptions(a_API)
g_Stats.NumUndocumentedClasses = g_Stats.NumUndocumentedClasses + 1;
for j, func in ipairs(cls.Functions) do
local FnName = func.DocID or func.Name;
- if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then
+ if not(IsFunctionIgnored(cls.Name, FnName)) then
table.insert(cls.UndocumentedFunctions, FnName);
end
end -- for j, func - cls.Functions[]
@@ -586,7 +591,7 @@ function ReadDescriptions(a_API)
-- Remove ignored functions:
local NewFunctions = {};
for j, fn in ipairs(cls.Functions) do
- if (not(IsFunctionIgnored(cls.Name .. "." .. fn.Name))) then
+ if (not(IsFunctionIgnored(cls.Name, fn.Name))) then
table.insert(NewFunctions, fn);
end
end -- for j, fn
@@ -735,14 +740,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
end
if (a_InheritedName ~= nil) then
- cf:write(" <h2>Functions inherited from " .. a_InheritedName .. "</h2>\n");
+ cf:write(" <h2>Functions inherited from ", a_InheritedName, "</h2>\n");
end
cf:write(" <table>\n <tr>\n <th>Name</th>\n <th>Parameters</th>\n <th>Return value</th>\n <th>Notes</th>\n </tr>\n");
for i, func in ipairs(a_Functions) do
cf:write(" <tr>\n <td>" .. func.Name .. "</td>\n");
- cf:write(" <td>" .. LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)).. "</td>\n");
- cf:write(" <td>" .. LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)).. "</td>\n");
- cf:write(" <td>" .. LinkifyString(func.Notes or "<i>(undocumented)</i>", (a_InheritedName or a_ClassAPI.Name)) .. "</td>\n </tr>\n");
+ cf:write(" <td>", LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)), "</td>\n");
+ cf:write(" <td>", LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)), "</td>\n");
+ cf:write(" <td>", LinkifyString(func.Notes or "<i>(undocumented)</i>", (a_InheritedName or a_ClassAPI.Name)), "</td>\n </tr>\n");
end
cf:write(" </table>\n\n");
end
@@ -753,14 +758,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
end
if (a_InheritedName ~= nil) then
- cf:write(" <h2>Constants inherited from " .. a_InheritedName .. "</h2>\n");
+ cf:write(" <h2>Constants inherited from ", a_InheritedName, "</h2>\n");
end
cf:write(" <table>\n <tr>\n <th>Name</th>\n <th>Value</th>\n <th>Notes</th>\n </tr>\n");
for i, cons in ipairs(a_Constants) do
- cf:write(" <tr>\n <td>" .. cons.Name .. "</td>\n");
- cf:write(" <td>" .. cons.Value .. "</td>\n");
- cf:write(" <td>" .. LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "</td>\n </tr>\n");
+ cf:write(" <tr>\n <td>", cons.Name, "</td>\n");
+ cf:write(" <td>", cons.Value, "</td>\n");
+ cf:write(" <td>", LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name), "</td>\n </tr>\n");
end
cf:write(" </table>\n\n");
end
@@ -771,14 +776,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
end
if (a_InheritedName ~= nil) then
- cf:write(" <h2>Member variables inherited from " .. a_InheritedName .. "</h2>\n");
+ cf:write(" <h2>Member variables inherited from ", a_InheritedName, "</h2>\n");
end
cf:write(" <table>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Notes</th>\n </tr>\n");
for i, var in ipairs(a_Variables) do
- cf:write(" <tr>\n <td>" .. var.Name .. "</td>\n");
- cf:write(" <td>" .. LinkifyString(var.Type or "<i>(undocumented)</i>", a_InheritedName or a_ClassAPI.Name) .. "</td>\n");
- cf:write(" <td>" .. LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "</td>\n </tr>\n");
+ cf:write(" <tr>\n <td>", var.Name, "</td>\n");
+ cf:write(" <td>", LinkifyString(var.Type or "<i>(undocumented)</i>", a_InheritedName or a_ClassAPI.Name), "</td>\n");
+ cf:write(" <td>", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), "</td>\n </tr>\n");
end
cf:write(" </table>\n\n");
end
@@ -789,7 +794,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
end
cf:write("<ul>");
for i, desc in ipairs(a_Descendants) do
- cf:write("<li><a href=\"".. desc.Name .. ".html\">" .. desc.Name .. "</a>");
+ cf:write("<li><a href=\"", desc.Name, ".html\">", desc.Name, "</a>");
WriteDescendants(desc.Descendants);
cf:write("</li>\n");
end
@@ -809,7 +814,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
cf:write([[<!DOCTYPE html>
<html>
<head>
- <title>MCServer API - ]] .. a_ClassAPI.Name .. [[ Class</title>
+ <title>MCServer API - ]], a_ClassAPI.Name, [[ Class</title>
<link rel="stylesheet" type="text/css" href="main.css" />
<link rel="stylesheet" type="text/css" href="prettify.css" />
<script src="prettify.js"></script>
@@ -818,7 +823,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
<body>
<div id="content">
<header>
- <h1>]] .. a_ClassAPI.Name .. [[</h1>
+ <h1>]], a_ClassAPI.Name, [[</h1>
<hr />
</header>
<h1>Contents</h1>
@@ -852,7 +857,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
end
if (a_ClassAPI.AdditionalInfo ~= nil) then
for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do
- cf:write(" <li><a href=\"#additionalinfo_" .. i .. "\">" .. (additional.Header or "<i>(No header)</i>").. "</a></li>\n");
+ cf:write(" <li><a href=\"#additionalinfo_", i, "\">", (additional.Header or "<i>(No header)</i>"), "</a></li>\n");
end
end
cf:write(" </ul>\n\n");
@@ -915,7 +920,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
-- Write the additional infos:
if (a_ClassAPI.AdditionalInfo ~= nil) then
for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do
- cf:write(" <a name=\"additionalinfo_" .. i .. "\"><h1>" .. additional.Header .. "</h1></a>\n");
+ cf:write(" <a name=\"additionalinfo_", i, "\"><h1>", additional.Header, "</h1></a>\n");
cf:write(LinkifyString(additional.Contents, ClassName));
end
end
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index 04a15a002..9350606cc 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -26,6 +26,7 @@ function Initialize(Plugin)
cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChat);
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity);
cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick);
+ cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated);
PluginManager = cRoot:Get():GetPluginManager();
PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities");
@@ -44,6 +45,8 @@ function Initialize(Plugin)
PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off");
PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player");
PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player");
+ PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player");
+ PluginManager:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp");
-- Enable the following line for BlockArea / Generator interface testing:
-- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
@@ -499,32 +502,38 @@ end
-function OnChunkGenerated(World, ChunkX, ChunkZ, ChunkDesc)
- -- Test ChunkDesc / BlockArea interaction
- local BlockArea = cBlockArea();
- ChunkDesc:ReadBlockArea(BlockArea, 0, 15, 50, 70, 0, 15);
-
- -- BlockArea:SaveToSchematicFile("ChunkBlocks_" .. ChunkX .. "_" .. ChunkZ .. ".schematic");
-
- ChunkDesc:WriteBlockArea(BlockArea, 5, 115, 5);
- return false;
+function OnChat(a_Player, a_Message)
+ return false, "blabla " .. a_Message;
end
-function OnChat(a_Player, a_Message)
- return false, "blabla " .. a_Message;
+function OnPlayerRightClickingEntity(a_Player, a_Entity)
+ LOG("Player " .. a_Player:GetName() .. " right-clicking entity ID " .. a_Entity:GetUniqueID() .. ", a " .. a_Entity:GetClass());
+ return false;
end
-function OnPlayerRightClickingEntity(a_Player, a_Entity)
- LOG("Player " .. a_Player:GetName() .. " right-clicking entity ID " .. a_Entity:GetUniqueID() .. ", a " .. a_Entity:GetClass());
- return false;
+function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
+ -- Get the topmost block coord:
+ local Height = a_ChunkDesc:GetHeight(0, 0);
+
+ -- Create a sign there:
+ a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0);
+ local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0);
+ if (BlockEntity ~= nil) then
+ LOG("Setting sign lines...");
+ local SignEntity = tolua.cast(BlockEntity, "cSignEntity");
+ SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)");
+ end
+
+ -- Update the heightmap:
+ a_ChunkDesc:SetHeight(0, 0, Height + 1);
end
@@ -839,3 +848,18 @@ end
+function HandleAddExperience(a_Split, a_Player)
+ a_Player:DeltaExperience(200);
+
+ return true;
+end
+
+
+
+
+
+function HandleRemoveXp(a_Split, a_Player)
+ a_Player:SetCurrentExperience(0);
+
+ return true;
+end
diff --git a/MCServer/items.ini b/MCServer/items.ini
index 42ab22fa3..c09b32f17 100644
--- a/MCServer/items.ini
+++ b/MCServer/items.ini
@@ -119,7 +119,7 @@ redwool=35:14
blackwool=35:15
dandelion=37
-; Obselete, use a specific flower name instead (or flower)
+; Renamed in 1.7, use "poppy" instead; kept for compatibility reasons, will be removed later on.
rose=38
flower=38
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index 83ca11be9..93a34d90a 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -2672,6 +2672,10 @@
Name="BlockEntities"
>
<File
+ RelativePath="..\source\BlockEntities\BlockEntity.cpp"
+ >
+ </File>
+ <File
RelativePath="..\source\BlockEntities\BlockEntity.h"
>
</File>
diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg
index 676b8632b..ee594be1a 100644
--- a/source/AllToLua.pkg
+++ b/source/AllToLua.pkg
@@ -47,6 +47,9 @@ $cfile "BlockEntities/DispenserEntity.h"
$cfile "BlockEntities/DropperEntity.h"
$cfile "BlockEntities/FurnaceEntity.h"
$cfile "BlockEntities/HopperEntity.h"
+$cfile "BlockEntities/JukeboxEntity.h"
+$cfile "BlockEntities/NoteEntity.h"
+$cfile "BlockEntities/SignEntity.h"
$cfile "WebAdmin.h"
$cfile "WebPlugin.h"
$cfile "Root.h"
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 236802d4e..9fdd28383 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 11/14/13 16:18:41.
+** Generated automatically by tolua++-1.0.92 on 11/16/13 21:58:48.
*/
#ifndef __cplusplus
@@ -46,6 +46,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
#include "BlockEntities/DropperEntity.h"
#include "BlockEntities/FurnaceEntity.h"
#include "BlockEntities/HopperEntity.h"
+#include "BlockEntities/JukeboxEntity.h"
+#include "BlockEntities/NoteEntity.h"
+#include "BlockEntities/SignEntity.h"
#include "WebAdmin.h"
#include "WebPlugin.h"
#include "Root.h"
@@ -67,72 +70,37 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
/* function to release collected object via destructor */
#ifdef __cplusplus
-static int tolua_collect_cItem (lua_State* tolua_S)
-{
- cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
- Mtolua_delete(self);
- return 0;
-}
-
-static int tolua_collect_Vector3f (lua_State* tolua_S)
-{
- Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
- Mtolua_delete(self);
- return 0;
-}
-
-static int tolua_collect_cChestEntity (lua_State* tolua_S)
-{
- cChestEntity* self = (cChestEntity*) tolua_tousertype(tolua_S,1,0);
- Mtolua_delete(self);
- return 0;
-}
-
-static int tolua_collect_cDispenserEntity (lua_State* tolua_S)
-{
- cDispenserEntity* self = (cDispenserEntity*) tolua_tousertype(tolua_S,1,0);
- Mtolua_delete(self);
- return 0;
-}
-
-static int tolua_collect_cCuboid (lua_State* tolua_S)
-{
- cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
- Mtolua_delete(self);
- return 0;
-}
-
-static int tolua_collect_cBlockEntity (lua_State* tolua_S)
+static int tolua_collect_sWebAdminPage (lua_State* tolua_S)
{
- cBlockEntity* self = (cBlockEntity*) tolua_tousertype(tolua_S,1,0);
+ sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
-static int tolua_collect_cBlockArea (lua_State* tolua_S)
+static int tolua_collect_cBoundingBox (lua_State* tolua_S)
{
- cBlockArea* self = (cBlockArea*) tolua_tousertype(tolua_S,1,0);
+ cBoundingBox* self = (cBoundingBox*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
-static int tolua_collect_cEnchantments (lua_State* tolua_S)
+static int tolua_collect_cItem (lua_State* tolua_S)
{
- cEnchantments* self = (cEnchantments*) tolua_tousertype(tolua_S,1,0);
+ cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
-static int tolua_collect_cLuaWindow (lua_State* tolua_S)
+static int tolua_collect_Vector3f (lua_State* tolua_S)
{
- cLuaWindow* self = (cLuaWindow*) tolua_tousertype(tolua_S,1,0);
+ Vector3f* self = (Vector3f*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
-static int tolua_collect_cDropperEntity (lua_State* tolua_S)
+static int tolua_collect_cIniFile (lua_State* tolua_S)
{
- cDropperEntity* self = (cDropperEntity*) tolua_tousertype(tolua_S,1,0);
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
@@ -151,9 +119,9 @@ static int tolua_collect_cItems (lua_State* tolua_S)
return 0;
}
-static int tolua_collect_cCraftingGrid (lua_State* tolua_S)
+static int tolua_collect_cBlockArea (lua_State* tolua_S)
{
- cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
+ cBlockArea* self = (cBlockArea*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
@@ -165,23 +133,23 @@ static int tolua_collect_cTracer (lua_State* tolua_S)
return 0;
}
-static int tolua_collect_cBoundingBox (lua_State* tolua_S)
+static int tolua_collect_cCraftingGrid (lua_State* tolua_S)
{
- cBoundingBox* self = (cBoundingBox*) tolua_tousertype(tolua_S,1,0);
+ cCraftingGrid* self = (cCraftingGrid*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
-static int tolua_collect_sWebAdminPage (lua_State* tolua_S)
+static int tolua_collect_cCuboid (lua_State* tolua_S)
{
- sWebAdminPage* self = (sWebAdminPage*) tolua_tousertype(tolua_S,1,0);
+ cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
-static int tolua_collect_cHopperEntity (lua_State* tolua_S)
+static int tolua_collect_cBlockEntity (lua_State* tolua_S)
{
- cHopperEntity* self = (cHopperEntity*) tolua_tousertype(tolua_S,1,0);
+ cBlockEntity* self = (cBlockEntity*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
@@ -193,16 +161,16 @@ static int tolua_collect_Vector3i (lua_State* tolua_S)
return 0;
}
-static int tolua_collect_cFurnaceEntity (lua_State* tolua_S)
+static int tolua_collect_cEnchantments (lua_State* tolua_S)
{
- cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ cEnchantments* self = (cEnchantments*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
-static int tolua_collect_cIniFile (lua_State* tolua_S)
+static int tolua_collect_cLuaWindow (lua_State* tolua_S)
{
- cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ cLuaWindow* self = (cLuaWindow*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
@@ -237,6 +205,7 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cPluginManager");
tolua_usertype(tolua_S,"Vector3f");
tolua_usertype(tolua_S,"cCraftingRecipes");
+ tolua_usertype(tolua_S,"cJukeboxEntity");
tolua_usertype(tolua_S,"cChestEntity");
tolua_usertype(tolua_S,"cDispenserEntity");
tolua_usertype(tolua_S,"cGhastFireballEntity");
@@ -254,34 +223,36 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cHopperEntity");
tolua_usertype(tolua_S,"std::vector<AString>");
tolua_usertype(tolua_S,"cBlockEntityWithItems");
- tolua_usertype(tolua_S,"HTTPFormData");
- tolua_usertype(tolua_S,"cTracer");
- tolua_usertype(tolua_S,"cArrowEntity");
- tolua_usertype(tolua_S,"cDropSpenserEntity");
tolua_usertype(tolua_S,"cWindow");
- tolua_usertype(tolua_S,"cBlockArea");
tolua_usertype(tolua_S,"cCraftingGrid");
- tolua_usertype(tolua_S,"cPlayer");
+ tolua_usertype(tolua_S,"cItem");
+ tolua_usertype(tolua_S,"cBlockArea");
+ tolua_usertype(tolua_S,"cArrowEntity");
+ tolua_usertype(tolua_S,"cDropSpenserEntity");
tolua_usertype(tolua_S,"cGroup");
+ tolua_usertype(tolua_S,"cTracer");
+ tolua_usertype(tolua_S,"cBoundingBox");
+ tolua_usertype(tolua_S,"cNoteEntity");
+ tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cCriticalSection");
tolua_usertype(tolua_S,"HTTPTemplateRequest");
+ tolua_usertype(tolua_S,"cPlayer");
tolua_usertype(tolua_S,"cServer");
- tolua_usertype(tolua_S,"cBoundingBox");
- tolua_usertype(tolua_S,"Vector3i");
+ tolua_usertype(tolua_S,"cSignEntity");
tolua_usertype(tolua_S,"cFile");
tolua_usertype(tolua_S,"cItems");
tolua_usertype(tolua_S,"cClientHandle");
tolua_usertype(tolua_S,"cIniFile");
- tolua_usertype(tolua_S,"cChatColor");
tolua_usertype(tolua_S,"cWebPlugin");
+ tolua_usertype(tolua_S,"cChatColor");
tolua_usertype(tolua_S,"cPawn");
tolua_usertype(tolua_S,"cThrownEggEntity");
tolua_usertype(tolua_S,"cGroupManager");
tolua_usertype(tolua_S,"cWebAdmin");
- tolua_usertype(tolua_S,"cItem");
- tolua_usertype(tolua_S,"cProjectileEntity");
tolua_usertype(tolua_S,"HTTPRequest");
+ tolua_usertype(tolua_S,"cProjectileEntity");
+ tolua_usertype(tolua_S,"HTTPFormData");
tolua_usertype(tolua_S,"cItemGrid::cListener");
tolua_usertype(tolua_S,"cDropperEntity");
}
@@ -7679,9 +7650,9 @@ static int tolua_AllToLua_cEntity_IsInvisible00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetExperience of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetExperience00
-static int tolua_AllToLua_cPlayer_SetExperience00(lua_State* tolua_S)
+/* method: SetCurrentExperience of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetCurrentExperience00
+static int tolua_AllToLua_cPlayer_SetCurrentExperience00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -7695,27 +7666,27 @@ static int tolua_AllToLua_cPlayer_SetExperience00(lua_State* tolua_S)
#endif
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
- int a_XpTotal = ((int) tolua_tonumber(tolua_S,2,0));
+ short a_XpTotal = ((short) tolua_tonumber(tolua_S,2,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetExperience'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetCurrentExperience'", NULL);
#endif
{
- bool tolua_ret = (bool) self->SetExperience(a_XpTotal);
+ bool tolua_ret = (bool) self->SetCurrentExperience(a_XpTotal);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetExperience'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetCurrentExperience'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: AddExperience of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_AddExperience00
-static int tolua_AllToLua_cPlayer_AddExperience00(lua_State* tolua_S)
+/* method: DeltaExperience of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_DeltaExperience00
+static int tolua_AllToLua_cPlayer_DeltaExperience00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -7729,27 +7700,59 @@ static int tolua_AllToLua_cPlayer_AddExperience00(lua_State* tolua_S)
#endif
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
- int a_Xp_delta = ((int) tolua_tonumber(tolua_S,2,0));
+ short a_Xp_delta = ((short) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeltaExperience'", NULL);
+#endif
+ {
+ short tolua_ret = (short) self->DeltaExperience(a_Xp_delta);
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DeltaExperience'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: GetXpLifetimeTotal of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetXpLifetimeTotal00
+static int tolua_AllToLua_cPlayer_GetXpLifetimeTotal00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddExperience'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetXpLifetimeTotal'", NULL);
#endif
{
- int tolua_ret = (int) self->AddExperience(a_Xp_delta);
+ short tolua_ret = (short) self->GetXpLifetimeTotal();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'AddExperience'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetXpLifetimeTotal'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: XpGetTotal of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_XpGetTotal00
-static int tolua_AllToLua_cPlayer_XpGetTotal00(lua_State* tolua_S)
+/* method: GetCurrentXp of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetCurrentXp00
+static int tolua_AllToLua_cPlayer_GetCurrentXp00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -7763,25 +7766,25 @@ static int tolua_AllToLua_cPlayer_XpGetTotal00(lua_State* tolua_S)
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'XpGetTotal'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetCurrentXp'", NULL);
#endif
{
- int tolua_ret = (int) self->XpGetTotal();
+ short tolua_ret = (short) self->GetCurrentXp();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'XpGetTotal'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetCurrentXp'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: XpGetLevel of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_XpGetLevel00
-static int tolua_AllToLua_cPlayer_XpGetLevel00(lua_State* tolua_S)
+/* method: GetXpLevel of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetXpLevel00
+static int tolua_AllToLua_cPlayer_GetXpLevel00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -7795,25 +7798,25 @@ static int tolua_AllToLua_cPlayer_XpGetLevel00(lua_State* tolua_S)
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'XpGetLevel'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetXpLevel'", NULL);
#endif
{
- int tolua_ret = (int) self->XpGetLevel();
+ short tolua_ret = (short) self->GetXpLevel();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'XpGetLevel'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetXpLevel'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: XpGetPercentage of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_XpGetPercentage00
-static int tolua_AllToLua_cPlayer_XpGetPercentage00(lua_State* tolua_S)
+/* method: GetXpPercentage of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetXpPercentage00
+static int tolua_AllToLua_cPlayer_GetXpPercentage00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -7827,17 +7830,17 @@ static int tolua_AllToLua_cPlayer_XpGetPercentage00(lua_State* tolua_S)
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'XpGetPercentage'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetXpPercentage'", NULL);
#endif
{
- float tolua_ret = (float) self->XpGetPercentage();
+ float tolua_ret = (float) self->GetXpPercentage();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'XpGetPercentage'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetXpPercentage'.",&tolua_err);
return 0;
#endif
}
@@ -18059,399 +18062,374 @@ static int tolua_AllToLua_cBlockEntityWithItems_GetContents00(lua_State* tolua_S
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new of class cChestEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cChestEntity_new00
-static int tolua_AllToLua_cChestEntity_new00(lua_State* tolua_S)
+/* method: AddDropSpenserDir of class cDropSpenserEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cDropSpenserEntity_AddDropSpenserDir00
+static int tolua_AllToLua_cDropSpenserEntity_AddDropSpenserDir00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cChestEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"cDropSpenserEntity",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
+ cDropSpenserEntity* self = (cDropSpenserEntity*) tolua_tousertype(tolua_S,1,0);
int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ unsigned char a_Direction = (( unsigned char) tolua_tonumber(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddDropSpenserDir'", NULL);
+#endif
{
- cChestEntity* tolua_ret = (cChestEntity*) Mtolua_new((cChestEntity)(a_BlockX,a_BlockY,a_BlockZ));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cChestEntity");
+ self->AddDropSpenserDir(a_BlockX,a_BlockY,a_BlockZ,a_Direction);
+ tolua_pushnumber(tolua_S,(lua_Number)a_BlockX);
+ tolua_pushnumber(tolua_S,(lua_Number)a_BlockY);
+ tolua_pushnumber(tolua_S,(lua_Number)a_BlockZ);
}
}
- return 1;
+ return 3;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'AddDropSpenserDir'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new_local of class cChestEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cChestEntity_new00_local
-static int tolua_AllToLua_cChestEntity_new00_local(lua_State* tolua_S)
+/* method: Activate of class cDropSpenserEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cDropSpenserEntity_Activate00
+static int tolua_AllToLua_cDropSpenserEntity_Activate00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cChestEntity",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"cDropSpenserEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ cDropSpenserEntity* self = (cDropSpenserEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Activate'", NULL);
+#endif
{
- cChestEntity* tolua_ret = (cChestEntity*) Mtolua_new((cChestEntity)(a_BlockX,a_BlockY,a_BlockZ));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cChestEntity");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ self->Activate();
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'Activate'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: AddDropSpenserDir of class cDropSpenserEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cDropSpenserEntity_AddDropSpenserDir00
-static int tolua_AllToLua_cDropSpenserEntity_AddDropSpenserDir00(lua_State* tolua_S)
+/* method: SetRedstonePower of class cDropSpenserEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cDropSpenserEntity_SetRedstonePower00
+static int tolua_AllToLua_cDropSpenserEntity_SetRedstonePower00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cDropSpenserEntity",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,6,&tolua_err)
+ !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cDropSpenserEntity* self = (cDropSpenserEntity*) tolua_tousertype(tolua_S,1,0);
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
- unsigned char a_Direction = (( unsigned char) tolua_tonumber(tolua_S,5,0));
+ bool a_IsPowered = ((bool) tolua_toboolean(tolua_S,2,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddDropSpenserDir'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetRedstonePower'", NULL);
#endif
{
- self->AddDropSpenserDir(a_BlockX,a_BlockY,a_BlockZ,a_Direction);
- tolua_pushnumber(tolua_S,(lua_Number)a_BlockX);
- tolua_pushnumber(tolua_S,(lua_Number)a_BlockY);
- tolua_pushnumber(tolua_S,(lua_Number)a_BlockZ);
+ self->SetRedstonePower(a_IsPowered);
}
}
- return 3;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'AddDropSpenserDir'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetRedstonePower'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: Activate of class cDropSpenserEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cDropSpenserEntity_Activate00
-static int tolua_AllToLua_cDropSpenserEntity_Activate00(lua_State* tolua_S)
+/* method: GetInputSlot of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetInputSlot00
+static int tolua_AllToLua_cFurnaceEntity_GetInputSlot00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cDropSpenserEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cDropSpenserEntity* self = (cDropSpenserEntity*) tolua_tousertype(tolua_S,1,0);
+ const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Activate'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetInputSlot'", NULL);
#endif
{
- self->Activate();
+ const cItem& tolua_ret = (const cItem&) self->GetInputSlot();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
}
}
- return 0;
+ return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'Activate'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetInputSlot'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetRedstonePower of class cDropSpenserEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cDropSpenserEntity_SetRedstonePower00
-static int tolua_AllToLua_cDropSpenserEntity_SetRedstonePower00(lua_State* tolua_S)
+/* method: GetFuelSlot of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetFuelSlot00
+static int tolua_AllToLua_cFurnaceEntity_GetFuelSlot00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cDropSpenserEntity",0,&tolua_err) ||
- !tolua_isboolean(tolua_S,2,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cDropSpenserEntity* self = (cDropSpenserEntity*) tolua_tousertype(tolua_S,1,0);
- bool a_IsPowered = ((bool) tolua_toboolean(tolua_S,2,0));
+ const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetRedstonePower'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetFuelSlot'", NULL);
#endif
{
- self->SetRedstonePower(a_IsPowered);
+ const cItem& tolua_ret = (const cItem&) self->GetFuelSlot();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
}
}
- return 0;
+ return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetRedstonePower'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetFuelSlot'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new of class cDispenserEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cDispenserEntity_new00
-static int tolua_AllToLua_cDispenserEntity_new00(lua_State* tolua_S)
+/* method: GetOutputSlot of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetOutputSlot00
+static int tolua_AllToLua_cFurnaceEntity_GetOutputSlot00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cDispenserEntity",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetOutputSlot'", NULL);
+#endif
{
- cDispenserEntity* tolua_ret = (cDispenserEntity*) Mtolua_new((cDispenserEntity)(a_BlockX,a_BlockY,a_BlockZ));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cDispenserEntity");
+ const cItem& tolua_ret = (const cItem&) self->GetOutputSlot();
+ tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetOutputSlot'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new_local of class cDispenserEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cDispenserEntity_new00_local
-static int tolua_AllToLua_cDispenserEntity_new00_local(lua_State* tolua_S)
+/* method: SetInputSlot of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_SetInputSlot00
+static int tolua_AllToLua_cFurnaceEntity_SetInputSlot00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cDispenserEntity",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"cFurnaceEntity",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetInputSlot'", NULL);
+#endif
{
- cDispenserEntity* tolua_ret = (cDispenserEntity*) Mtolua_new((cDispenserEntity)(a_BlockX,a_BlockY,a_BlockZ));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cDispenserEntity");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ self->SetInputSlot(*a_Item);
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetInputSlot'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new of class cDropperEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cDropperEntity_new00
-static int tolua_AllToLua_cDropperEntity_new00(lua_State* tolua_S)
+/* method: SetFuelSlot of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_SetFuelSlot00
+static int tolua_AllToLua_cFurnaceEntity_SetFuelSlot00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cDropperEntity",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"cFurnaceEntity",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetFuelSlot'", NULL);
+#endif
{
- cDropperEntity* tolua_ret = (cDropperEntity*) Mtolua_new((cDropperEntity)(a_BlockX,a_BlockY,a_BlockZ));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cDropperEntity");
+ self->SetFuelSlot(*a_Item);
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetFuelSlot'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new_local of class cDropperEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cDropperEntity_new00_local
-static int tolua_AllToLua_cDropperEntity_new00_local(lua_State* tolua_S)
+/* method: SetOutputSlot of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_SetOutputSlot00
+static int tolua_AllToLua_cFurnaceEntity_SetOutputSlot00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cDropperEntity",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"cFurnaceEntity",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetOutputSlot'", NULL);
+#endif
{
- cDropperEntity* tolua_ret = (cDropperEntity*) Mtolua_new((cDropperEntity)(a_BlockX,a_BlockY,a_BlockZ));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cDropperEntity");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ self->SetOutputSlot(*a_Item);
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetOutputSlot'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_new00
-static int tolua_AllToLua_cFurnaceEntity_new00(lua_State* tolua_S)
+/* method: GetTimeCooked of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetTimeCooked00
+static int tolua_AllToLua_cFurnaceEntity_GetTimeCooked00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cFurnaceEntity",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,6,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,7,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
- unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,5,0));
- unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,6,0));
+ const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetTimeCooked'", NULL);
+#endif
{
- cFurnaceEntity* tolua_ret = (cFurnaceEntity*) Mtolua_new((cFurnaceEntity)(a_BlockX,a_BlockY,a_BlockZ,a_BlockType,a_BlockMeta));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cFurnaceEntity");
+ int tolua_ret = (int) self->GetTimeCooked();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetTimeCooked'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new_local of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_new00_local
-static int tolua_AllToLua_cFurnaceEntity_new00_local(lua_State* tolua_S)
+/* method: GetCookTimeLeft of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetCookTimeLeft00
+static int tolua_AllToLua_cFurnaceEntity_GetCookTimeLeft00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cFurnaceEntity",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,6,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,7,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
- unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,5,0));
- unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,6,0));
+ const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetCookTimeLeft'", NULL);
+#endif
{
- cFurnaceEntity* tolua_ret = (cFurnaceEntity*) Mtolua_new((cFurnaceEntity)(a_BlockX,a_BlockY,a_BlockZ,a_BlockType,a_BlockMeta));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cFurnaceEntity");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ int tolua_ret = (int) self->GetCookTimeLeft();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetCookTimeLeft'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetInputSlot of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetInputSlot00
-static int tolua_AllToLua_cFurnaceEntity_GetInputSlot00(lua_State* tolua_S)
+/* method: GetFuelBurnTimeLeft of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetFuelBurnTimeLeft00
+static int tolua_AllToLua_cFurnaceEntity_GetFuelBurnTimeLeft00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -18465,25 +18443,25 @@ static int tolua_AllToLua_cFurnaceEntity_GetInputSlot00(lua_State* tolua_S)
{
const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetInputSlot'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetFuelBurnTimeLeft'", NULL);
#endif
{
- const cItem& tolua_ret = (const cItem&) self->GetInputSlot();
- tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
+ int tolua_ret = (int) self->GetFuelBurnTimeLeft();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetInputSlot'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetFuelBurnTimeLeft'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetFuelSlot of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetFuelSlot00
-static int tolua_AllToLua_cFurnaceEntity_GetFuelSlot00(lua_State* tolua_S)
+/* method: HasFuelTimeLeft of class cFurnaceEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_HasFuelTimeLeft00
+static int tolua_AllToLua_cFurnaceEntity_HasFuelTimeLeft00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
@@ -18497,345 +18475,384 @@ static int tolua_AllToLua_cFurnaceEntity_GetFuelSlot00(lua_State* tolua_S)
{
const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetFuelSlot'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HasFuelTimeLeft'", NULL);
#endif
{
- const cItem& tolua_ret = (const cItem&) self->GetFuelSlot();
- tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
+ bool tolua_ret = (bool) self->HasFuelTimeLeft();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetFuelSlot'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'HasFuelTimeLeft'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetOutputSlot of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetOutputSlot00
-static int tolua_AllToLua_cFurnaceEntity_GetOutputSlot00(lua_State* tolua_S)
+/* method: GetRecord of class cJukeboxEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cJukeboxEntity_GetRecord00
+static int tolua_AllToLua_cJukeboxEntity_GetRecord00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"cJukeboxEntity",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ cJukeboxEntity* self = (cJukeboxEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetOutputSlot'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRecord'", NULL);
#endif
{
- const cItem& tolua_ret = (const cItem&) self->GetOutputSlot();
- tolua_pushusertype(tolua_S,(void*)&tolua_ret,"const cItem");
+ int tolua_ret = (int) self->GetRecord();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetOutputSlot'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetRecord'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetInputSlot of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_SetInputSlot00
-static int tolua_AllToLua_cFurnaceEntity_SetInputSlot00(lua_State* tolua_S)
+/* method: SetRecord of class cJukeboxEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cJukeboxEntity_SetRecord00
+static int tolua_AllToLua_cJukeboxEntity_SetRecord00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cFurnaceEntity",0,&tolua_err) ||
- (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) ||
+ !tolua_isusertype(tolua_S,1,"cJukeboxEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
- const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0));
+ cJukeboxEntity* self = (cJukeboxEntity*) tolua_tousertype(tolua_S,1,0);
+ int a_Record = ((int) tolua_tonumber(tolua_S,2,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetInputSlot'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetRecord'", NULL);
#endif
{
- self->SetInputSlot(*a_Item);
+ self->SetRecord(a_Record);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetInputSlot'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetRecord'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetFuelSlot of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_SetFuelSlot00
-static int tolua_AllToLua_cFurnaceEntity_SetFuelSlot00(lua_State* tolua_S)
+/* method: PlayRecord of class cJukeboxEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cJukeboxEntity_PlayRecord00
+static int tolua_AllToLua_cJukeboxEntity_PlayRecord00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cFurnaceEntity",0,&tolua_err) ||
- (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"cJukeboxEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
- const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0));
+ cJukeboxEntity* self = (cJukeboxEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetFuelSlot'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'PlayRecord'", NULL);
#endif
{
- self->SetFuelSlot(*a_Item);
+ self->PlayRecord();
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetFuelSlot'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'PlayRecord'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetOutputSlot of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_SetOutputSlot00
-static int tolua_AllToLua_cFurnaceEntity_SetOutputSlot00(lua_State* tolua_S)
+/* method: EjectRecord of class cJukeboxEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cJukeboxEntity_EjectRecord00
+static int tolua_AllToLua_cJukeboxEntity_EjectRecord00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cFurnaceEntity",0,&tolua_err) ||
- (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"cJukeboxEntity",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cFurnaceEntity* self = (cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
- const cItem* a_Item = ((const cItem*) tolua_tousertype(tolua_S,2,0));
+ cJukeboxEntity* self = (cJukeboxEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetOutputSlot'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'EjectRecord'", NULL);
#endif
{
- self->SetOutputSlot(*a_Item);
+ self->EjectRecord();
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetOutputSlot'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'EjectRecord'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetTimeCooked of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetTimeCooked00
-static int tolua_AllToLua_cFurnaceEntity_GetTimeCooked00(lua_State* tolua_S)
+/* method: GetPitch of class cNoteEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cNoteEntity_GetPitch00
+static int tolua_AllToLua_cNoteEntity_GetPitch00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"cNoteEntity",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ cNoteEntity* self = (cNoteEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetTimeCooked'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPitch'", NULL);
#endif
{
- int tolua_ret = (int) self->GetTimeCooked();
+ char tolua_ret = (char) self->GetPitch();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetTimeCooked'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetPitch'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetCookTimeLeft of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetCookTimeLeft00
-static int tolua_AllToLua_cFurnaceEntity_GetCookTimeLeft00(lua_State* tolua_S)
+/* method: SetPitch of class cNoteEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cNoteEntity_SetPitch00
+static int tolua_AllToLua_cNoteEntity_SetPitch00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"cNoteEntity",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ cNoteEntity* self = (cNoteEntity*) tolua_tousertype(tolua_S,1,0);
+ char a_Pitch = ((char) tolua_tonumber(tolua_S,2,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetCookTimeLeft'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPitch'", NULL);
#endif
{
- int tolua_ret = (int) self->GetCookTimeLeft();
- tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ self->SetPitch(a_Pitch);
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetCookTimeLeft'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetPitch'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetFuelBurnTimeLeft of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_GetFuelBurnTimeLeft00
-static int tolua_AllToLua_cFurnaceEntity_GetFuelBurnTimeLeft00(lua_State* tolua_S)
+/* method: IncrementPitch of class cNoteEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cNoteEntity_IncrementPitch00
+static int tolua_AllToLua_cNoteEntity_IncrementPitch00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"cNoteEntity",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ cNoteEntity* self = (cNoteEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetFuelBurnTimeLeft'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IncrementPitch'", NULL);
#endif
{
- int tolua_ret = (int) self->GetFuelBurnTimeLeft();
- tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ self->IncrementPitch();
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetFuelBurnTimeLeft'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'IncrementPitch'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: HasFuelTimeLeft of class cFurnaceEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cFurnaceEntity_HasFuelTimeLeft00
-static int tolua_AllToLua_cFurnaceEntity_HasFuelTimeLeft00(lua_State* tolua_S)
+/* method: MakeSound of class cNoteEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cNoteEntity_MakeSound00
+static int tolua_AllToLua_cNoteEntity_MakeSound00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"const cFurnaceEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"cNoteEntity",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- const cFurnaceEntity* self = (const cFurnaceEntity*) tolua_tousertype(tolua_S,1,0);
+ cNoteEntity* self = (cNoteEntity*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HasFuelTimeLeft'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'MakeSound'", NULL);
#endif
{
- bool tolua_ret = (bool) self->HasFuelTimeLeft();
- tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ self->MakeSound();
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'HasFuelTimeLeft'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'MakeSound'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new of class cHopperEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cHopperEntity_new00
-static int tolua_AllToLua_cHopperEntity_new00(lua_State* tolua_S)
+/* method: SetLines of class cSignEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cSignEntity_SetLines00
+static int tolua_AllToLua_cSignEntity_SetLines00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cHopperEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"cSignEntity",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,4,0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,5,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,6,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cSignEntity* self = (cSignEntity*) tolua_tousertype(tolua_S,1,0);
+ const AString a_Line1 = ((const AString) tolua_tocppstring(tolua_S,2,0));
+ const AString a_Line2 = ((const AString) tolua_tocppstring(tolua_S,3,0));
+ const AString a_Line3 = ((const AString) tolua_tocppstring(tolua_S,4,0));
+ const AString a_Line4 = ((const AString) tolua_tocppstring(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLines'", NULL);
+#endif
+ {
+ self->SetLines(a_Line1,a_Line2,a_Line3,a_Line4);
+ tolua_pushcppstring(tolua_S,(const char*)a_Line1);
+ tolua_pushcppstring(tolua_S,(const char*)a_Line2);
+ tolua_pushcppstring(tolua_S,(const char*)a_Line3);
+ tolua_pushcppstring(tolua_S,(const char*)a_Line4);
+ }
+ }
+ return 4;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetLines'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: SetLine of class cSignEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cSignEntity_SetLine00
+static int tolua_AllToLua_cSignEntity_SetLine00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cSignEntity",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_iscppstring(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ cSignEntity* self = (cSignEntity*) tolua_tousertype(tolua_S,1,0);
+ int a_Index = ((int) tolua_tonumber(tolua_S,2,0));
+ const AString a_Line = ((const AString) tolua_tocppstring(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLine'", NULL);
+#endif
{
- cHopperEntity* tolua_ret = (cHopperEntity*) Mtolua_new((cHopperEntity)(a_BlockX,a_BlockY,a_BlockZ));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cHopperEntity");
+ self->SetLine(a_Index,a_Line);
+ tolua_pushcppstring(tolua_S,(const char*)a_Line);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetLine'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: new_local of class cHopperEntity */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cHopperEntity_new00_local
-static int tolua_AllToLua_cHopperEntity_new00_local(lua_State* tolua_S)
+/* method: GetLine of class cSignEntity */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cSignEntity_GetLine00
+static int tolua_AllToLua_cSignEntity_GetLine00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertable(tolua_S,1,"cHopperEntity",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cSignEntity",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
- !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,5,&tolua_err)
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
- int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
- int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
+ const cSignEntity* self = (const cSignEntity*) tolua_tousertype(tolua_S,1,0);
+ int a_Index = ((int) tolua_tonumber(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLine'", NULL);
+#endif
{
- cHopperEntity* tolua_ret = (cHopperEntity*) Mtolua_new((cHopperEntity)(a_BlockX,a_BlockY,a_BlockZ));
- tolua_pushusertype(tolua_S,(void*)tolua_ret,"cHopperEntity");
- tolua_register_gc(tolua_S,lua_gettop(tolua_S));
+ AString tolua_ret = (AString) self->GetLine(a_Index);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetLine'.",&tolua_err);
return 0;
#endif
}
@@ -27889,6 +27906,44 @@ tolua_lerror:
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetBlockEntity of class cChunkDesc */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_GetBlockEntity00
+static int tolua_AllToLua_cChunkDesc_GetBlockEntity00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cChunkDesc",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cChunkDesc* self = (cChunkDesc*) tolua_tousertype(tolua_S,1,0);
+ int a_RelX = ((int) tolua_tonumber(tolua_S,2,0));
+ int a_RelY = ((int) tolua_tonumber(tolua_S,3,0));
+ int a_RelZ = ((int) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockEntity'", NULL);
+#endif
+ {
+ cBlockEntity* tolua_ret = (cBlockEntity*) self->GetBlockEntity(a_RelX,a_RelY,a_RelZ);
+ tolua_pushusertype(tolua_S,(void*)tolua_ret,"cBlockEntity");
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetBlockEntity'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: new of class cCraftingGrid */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_new00
static int tolua_AllToLua_cCraftingGrid_new00(lua_State* tolua_S)
@@ -30394,11 +30449,13 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"EATING_TICKS",cPlayer::EATING_TICKS);
tolua_constant(tolua_S,"MAX_AIR_LEVEL",cPlayer::MAX_AIR_LEVEL);
tolua_constant(tolua_S,"DROWNING_TICKS",cPlayer::DROWNING_TICKS);
- tolua_function(tolua_S,"SetExperience",tolua_AllToLua_cPlayer_SetExperience00);
- tolua_function(tolua_S,"AddExperience",tolua_AllToLua_cPlayer_AddExperience00);
- tolua_function(tolua_S,"XpGetTotal",tolua_AllToLua_cPlayer_XpGetTotal00);
- tolua_function(tolua_S,"XpGetLevel",tolua_AllToLua_cPlayer_XpGetLevel00);
- tolua_function(tolua_S,"XpGetPercentage",tolua_AllToLua_cPlayer_XpGetPercentage00);
+ tolua_constant(tolua_S,"MIN_EXPERIENCE",cPlayer::MIN_EXPERIENCE);
+ tolua_function(tolua_S,"SetCurrentExperience",tolua_AllToLua_cPlayer_SetCurrentExperience00);
+ tolua_function(tolua_S,"DeltaExperience",tolua_AllToLua_cPlayer_DeltaExperience00);
+ tolua_function(tolua_S,"GetXpLifetimeTotal",tolua_AllToLua_cPlayer_GetXpLifetimeTotal00);
+ tolua_function(tolua_S,"GetCurrentXp",tolua_AllToLua_cPlayer_GetCurrentXp00);
+ tolua_function(tolua_S,"GetXpLevel",tolua_AllToLua_cPlayer_GetXpLevel00);
+ tolua_function(tolua_S,"GetXpPercentage",tolua_AllToLua_cPlayer_GetXpPercentage00);
tolua_function(tolua_S,"GetEyeHeight",tolua_AllToLua_cPlayer_GetEyeHeight00);
tolua_function(tolua_S,"GetEyePosition",tolua_AllToLua_cPlayer_GetEyePosition00);
tolua_function(tolua_S,"IsOnGround",tolua_AllToLua_cPlayer_IsOnGround00);
@@ -30887,17 +30944,10 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetSlot",tolua_AllToLua_cBlockEntityWithItems_SetSlot01);
tolua_function(tolua_S,"GetContents",tolua_AllToLua_cBlockEntityWithItems_GetContents00);
tolua_endmodule(tolua_S);
- #ifdef __cplusplus
- tolua_cclass(tolua_S,"cChestEntity","cChestEntity","cBlockEntityWithItems",tolua_collect_cChestEntity);
- #else
tolua_cclass(tolua_S,"cChestEntity","cChestEntity","cBlockEntityWithItems",NULL);
- #endif
tolua_beginmodule(tolua_S,"cChestEntity");
tolua_constant(tolua_S,"ContentsHeight",cChestEntity::ContentsHeight);
tolua_constant(tolua_S,"ContentsWidth",cChestEntity::ContentsWidth);
- tolua_function(tolua_S,"new",tolua_AllToLua_cChestEntity_new00);
- tolua_function(tolua_S,"new_local",tolua_AllToLua_cChestEntity_new00_local);
- tolua_function(tolua_S,".call",tolua_AllToLua_cChestEntity_new00_local);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cDropSpenserEntity","cDropSpenserEntity","cBlockEntityWithItems",NULL);
tolua_beginmodule(tolua_S,"cDropSpenserEntity");
@@ -30907,40 +30957,19 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"Activate",tolua_AllToLua_cDropSpenserEntity_Activate00);
tolua_function(tolua_S,"SetRedstonePower",tolua_AllToLua_cDropSpenserEntity_SetRedstonePower00);
tolua_endmodule(tolua_S);
- #ifdef __cplusplus
- tolua_cclass(tolua_S,"cDispenserEntity","cDispenserEntity","cDropSpenserEntity",tolua_collect_cDispenserEntity);
- #else
tolua_cclass(tolua_S,"cDispenserEntity","cDispenserEntity","cDropSpenserEntity",NULL);
- #endif
tolua_beginmodule(tolua_S,"cDispenserEntity");
- tolua_function(tolua_S,"new",tolua_AllToLua_cDispenserEntity_new00);
- tolua_function(tolua_S,"new_local",tolua_AllToLua_cDispenserEntity_new00_local);
- tolua_function(tolua_S,".call",tolua_AllToLua_cDispenserEntity_new00_local);
tolua_endmodule(tolua_S);
- #ifdef __cplusplus
- tolua_cclass(tolua_S,"cDropperEntity","cDropperEntity","cDropSpenserEntity",tolua_collect_cDropperEntity);
- #else
tolua_cclass(tolua_S,"cDropperEntity","cDropperEntity","cDropSpenserEntity",NULL);
- #endif
tolua_beginmodule(tolua_S,"cDropperEntity");
- tolua_function(tolua_S,"new",tolua_AllToLua_cDropperEntity_new00);
- tolua_function(tolua_S,"new_local",tolua_AllToLua_cDropperEntity_new00_local);
- tolua_function(tolua_S,".call",tolua_AllToLua_cDropperEntity_new00_local);
tolua_endmodule(tolua_S);
- #ifdef __cplusplus
- tolua_cclass(tolua_S,"cFurnaceEntity","cFurnaceEntity","cBlockEntityWithItems",tolua_collect_cFurnaceEntity);
- #else
tolua_cclass(tolua_S,"cFurnaceEntity","cFurnaceEntity","cBlockEntityWithItems",NULL);
- #endif
tolua_beginmodule(tolua_S,"cFurnaceEntity");
tolua_constant(tolua_S,"fsInput",cFurnaceEntity::fsInput);
tolua_constant(tolua_S,"fsFuel",cFurnaceEntity::fsFuel);
tolua_constant(tolua_S,"fsOutput",cFurnaceEntity::fsOutput);
tolua_constant(tolua_S,"ContentsWidth",cFurnaceEntity::ContentsWidth);
tolua_constant(tolua_S,"ContentsHeight",cFurnaceEntity::ContentsHeight);
- tolua_function(tolua_S,"new",tolua_AllToLua_cFurnaceEntity_new00);
- tolua_function(tolua_S,"new_local",tolua_AllToLua_cFurnaceEntity_new00_local);
- tolua_function(tolua_S,".call",tolua_AllToLua_cFurnaceEntity_new00_local);
tolua_function(tolua_S,"GetInputSlot",tolua_AllToLua_cFurnaceEntity_GetInputSlot00);
tolua_function(tolua_S,"GetFuelSlot",tolua_AllToLua_cFurnaceEntity_GetFuelSlot00);
tolua_function(tolua_S,"GetOutputSlot",tolua_AllToLua_cFurnaceEntity_GetOutputSlot00);
@@ -30952,18 +30981,31 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetFuelBurnTimeLeft",tolua_AllToLua_cFurnaceEntity_GetFuelBurnTimeLeft00);
tolua_function(tolua_S,"HasFuelTimeLeft",tolua_AllToLua_cFurnaceEntity_HasFuelTimeLeft00);
tolua_endmodule(tolua_S);
- #ifdef __cplusplus
- tolua_cclass(tolua_S,"cHopperEntity","cHopperEntity","cBlockEntityWithItems",tolua_collect_cHopperEntity);
- #else
tolua_cclass(tolua_S,"cHopperEntity","cHopperEntity","cBlockEntityWithItems",NULL);
- #endif
tolua_beginmodule(tolua_S,"cHopperEntity");
tolua_constant(tolua_S,"ContentsHeight",cHopperEntity::ContentsHeight);
tolua_constant(tolua_S,"ContentsWidth",cHopperEntity::ContentsWidth);
tolua_constant(tolua_S,"TICKS_PER_TRANSFER",cHopperEntity::TICKS_PER_TRANSFER);
- tolua_function(tolua_S,"new",tolua_AllToLua_cHopperEntity_new00);
- tolua_function(tolua_S,"new_local",tolua_AllToLua_cHopperEntity_new00_local);
- tolua_function(tolua_S,".call",tolua_AllToLua_cHopperEntity_new00_local);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cJukeboxEntity","cJukeboxEntity","cBlockEntity",NULL);
+ tolua_beginmodule(tolua_S,"cJukeboxEntity");
+ tolua_function(tolua_S,"GetRecord",tolua_AllToLua_cJukeboxEntity_GetRecord00);
+ tolua_function(tolua_S,"SetRecord",tolua_AllToLua_cJukeboxEntity_SetRecord00);
+ tolua_function(tolua_S,"PlayRecord",tolua_AllToLua_cJukeboxEntity_PlayRecord00);
+ tolua_function(tolua_S,"EjectRecord",tolua_AllToLua_cJukeboxEntity_EjectRecord00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cNoteEntity","cNoteEntity","cBlockEntity",NULL);
+ tolua_beginmodule(tolua_S,"cNoteEntity");
+ tolua_function(tolua_S,"GetPitch",tolua_AllToLua_cNoteEntity_GetPitch00);
+ tolua_function(tolua_S,"SetPitch",tolua_AllToLua_cNoteEntity_SetPitch00);
+ tolua_function(tolua_S,"IncrementPitch",tolua_AllToLua_cNoteEntity_IncrementPitch00);
+ tolua_function(tolua_S,"MakeSound",tolua_AllToLua_cNoteEntity_MakeSound00);
+ tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cSignEntity","cSignEntity","cBlockEntity",NULL);
+ tolua_beginmodule(tolua_S,"cSignEntity");
+ tolua_function(tolua_S,"SetLines",tolua_AllToLua_cSignEntity_SetLines00);
+ tolua_function(tolua_S,"SetLine",tolua_AllToLua_cSignEntity_SetLine00);
+ tolua_function(tolua_S,"GetLine",tolua_AllToLua_cSignEntity_GetLine00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"HTTPFormData","HTTPFormData","",NULL);
tolua_beginmodule(tolua_S,"HTTPFormData");
@@ -31345,6 +31387,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"FloorRelCuboid",tolua_AllToLua_cChunkDesc_FloorRelCuboid01);
tolua_function(tolua_S,"RandomFillRelCuboid",tolua_AllToLua_cChunkDesc_RandomFillRelCuboid00);
tolua_function(tolua_S,"RandomFillRelCuboid",tolua_AllToLua_cChunkDesc_RandomFillRelCuboid01);
+ tolua_function(tolua_S,"GetBlockEntity",tolua_AllToLua_cChunkDesc_GetBlockEntity00);
tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cCraftingGrid","cCraftingGrid","",tolua_collect_cCraftingGrid);
diff --git a/source/Bindings.h b/source/Bindings.h
index 687e47cd5..996207055 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 11/14/13 16:18:41.
+** Generated automatically by tolua++-1.0.92 on 11/16/13 21:58:48.
*/
/* Exported function */
diff --git a/source/BlockEntities/BlockEntity.cpp b/source/BlockEntities/BlockEntity.cpp
new file mode 100644
index 000000000..41a488717
--- /dev/null
+++ b/source/BlockEntities/BlockEntity.cpp
@@ -0,0 +1,44 @@
+
+// BlockEntity.cpp
+
+// Implements the cBlockEntity class that is the common ancestor for all block entities
+
+#include "Globals.h"
+#include "BlockEntity.h"
+#include "ChestEntity.h"
+#include "DispenserEntity.h"
+#include "DropperEntity.h"
+#include "FurnaceEntity.h"
+#include "HopperEntity.h"
+#include "JukeboxEntity.h"
+#include "NoteEntity.h"
+#include "SignEntity.h"
+
+
+
+
+
+cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
+{
+ switch (a_BlockType)
+ {
+ case E_BLOCK_CHEST: return new cChestEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_DISPENSER: return new cDispenserEntity(a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_DROPPER: return new cDropperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_LIT_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
+ case E_BLOCK_FURNACE: return new cFurnaceEntity (a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_World);
+ case E_BLOCK_HOPPER: return new cHopperEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_SIGN_POST: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_WALLSIGN: return new cSignEntity (a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_NOTE_BLOCK: return new cNoteEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ case E_BLOCK_JUKEBOX: return new cJukeboxEntity (a_BlockX, a_BlockY, a_BlockZ, a_World);
+ }
+ LOGD("%s: Requesting creation of an unknown block entity - block type %d (%s)",
+ __FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
+ );
+ return NULL;
+}
+
+
+
+
diff --git a/source/BlockEntities/BlockEntity.h b/source/BlockEntities/BlockEntity.h
index ab7d7f5dc..a2de3160a 100644
--- a/source/BlockEntities/BlockEntity.h
+++ b/source/BlockEntities/BlockEntity.h
@@ -47,6 +47,11 @@ public:
m_World = a_World;
}
+ /// Creates a new block entity for the specified block type
+ /// If a_World is valid, then the entity is created bound to that world
+ /// Returns NULL for unknown block types
+ static cBlockEntity * CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World = NULL);
+
// tolua_begin
// Position, in absolute block coordinates:
diff --git a/source/BlockEntities/ChestEntity.cpp b/source/BlockEntities/ChestEntity.cpp
index 59193829d..ca2626bc9 100644
--- a/source/BlockEntities/ChestEntity.cpp
+++ b/source/BlockEntities/ChestEntity.cpp
@@ -11,16 +11,6 @@
-cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
- super(E_BLOCK_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, NULL)
-{
- cBlockEntityWindowOwner::SetBlockEntity(this);
-}
-
-
-
-
-
cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(E_BLOCK_CHEST, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World)
{
diff --git a/source/BlockEntities/ChestEntity.h b/source/BlockEntities/ChestEntity.h
index c6676894f..4f2c21e91 100644
--- a/source/BlockEntities/ChestEntity.h
+++ b/source/BlockEntities/ChestEntity.h
@@ -34,10 +34,6 @@ public:
ContentsWidth = 9,
} ;
-
- /// Constructor used while generating a chunk; sets m_World to NULL
- cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
-
// tolua_end
/// Constructor used for normal operation
diff --git a/source/BlockEntities/DispenserEntity.cpp b/source/BlockEntities/DispenserEntity.cpp
index 7edaa8a14..374f3d6e3 100644
--- a/source/BlockEntities/DispenserEntity.cpp
+++ b/source/BlockEntities/DispenserEntity.cpp
@@ -10,16 +10,6 @@
-cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
- super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, NULL)
-{
- SetBlockEntity(this); // cBlockEntityWindowOwner
-}
-
-
-
-
-
cDispenserEntity::cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(E_BLOCK_DISPENSER, a_BlockX, a_BlockY, a_BlockZ, a_World)
{
diff --git a/source/BlockEntities/DispenserEntity.h b/source/BlockEntities/DispenserEntity.h
index 5e3327f18..fdfe4e5b4 100644
--- a/source/BlockEntities/DispenserEntity.h
+++ b/source/BlockEntities/DispenserEntity.h
@@ -15,9 +15,6 @@ class cDispenserEntity :
public:
- /// Constructor used while generating a chunk; sets m_World to NULL
- cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
-
// tolua_end
/// Constructor used for normal operation
diff --git a/source/BlockEntities/DropperEntity.cpp b/source/BlockEntities/DropperEntity.cpp
index 61127cec1..5d4a8ad97 100644
--- a/source/BlockEntities/DropperEntity.cpp
+++ b/source/BlockEntities/DropperEntity.cpp
@@ -12,16 +12,6 @@
-cDropperEntity::cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
- super(E_BLOCK_DROPPER, a_BlockX, a_BlockY, a_BlockZ, NULL)
-{
- SetBlockEntity(this); // cBlockEntityWindowOwner
-}
-
-
-
-
-
cDropperEntity::cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(E_BLOCK_DROPPER, a_BlockX, a_BlockY, a_BlockZ, a_World)
{
diff --git a/source/BlockEntities/DropperEntity.h b/source/BlockEntities/DropperEntity.h
index af74e7f7c..8e07bc6f8 100644
--- a/source/BlockEntities/DropperEntity.h
+++ b/source/BlockEntities/DropperEntity.h
@@ -23,9 +23,6 @@ class cDropperEntity :
public:
- /// Constructor used while generating a chunk; sets m_World to NULL
- cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
-
// tolua_end
/// Constructor used for normal operation
diff --git a/source/BlockEntities/FurnaceEntity.cpp b/source/BlockEntities/FurnaceEntity.cpp
index 2f548d003..ec5ebe8b9 100644
--- a/source/BlockEntities/FurnaceEntity.cpp
+++ b/source/BlockEntities/FurnaceEntity.cpp
@@ -23,27 +23,6 @@ enum
-cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
- super(E_BLOCK_FURNACE, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, NULL),
- m_BlockType(a_BlockType),
- m_BlockMeta(a_BlockMeta),
- m_CurrentRecipe(NULL),
- m_IsCooking(false),
- m_NeedCookTime(0),
- m_TimeCooked(0),
- m_FuelBurnTime(0),
- m_TimeBurned(0),
- m_LastProgressFuel(0),
- m_LastProgressCook(0)
-{
- SetBlockEntity(this); // cBlockEntityWindowOwner
- m_Contents.AddListener(*this);
-}
-
-
-
-
-
cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World) :
super(E_BLOCK_FURNACE, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
m_BlockType(a_BlockType),
@@ -57,7 +36,7 @@ cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTY
m_LastProgressFuel(0),
m_LastProgressCook(0)
{
- SetBlockEntity(this); // cBlockEntityWindowOwner
+ cBlockEntityWindowOwner::SetBlockEntity(this);
m_Contents.AddListener(*this);
}
diff --git a/source/BlockEntities/FurnaceEntity.h b/source/BlockEntities/FurnaceEntity.h
index 038f60600..9464fd175 100644
--- a/source/BlockEntities/FurnaceEntity.h
+++ b/source/BlockEntities/FurnaceEntity.h
@@ -39,9 +39,6 @@ public:
ContentsHeight = 1,
};
- /// Constructor used while generating a chunk; sets m_World to NULL
- cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
-
// tolua_end
/// Constructor used for normal operation
diff --git a/source/BlockEntities/HopperEntity.cpp b/source/BlockEntities/HopperEntity.cpp
index c3d7ed3ba..41849b1b3 100644
--- a/source/BlockEntities/HopperEntity.cpp
+++ b/source/BlockEntities/HopperEntity.cpp
@@ -16,17 +16,6 @@
-cHopperEntity::cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ) :
- super(E_BLOCK_HOPPER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, NULL),
- m_LastMoveItemsInTick(0),
- m_LastMoveItemsOutTick(0)
-{
-}
-
-
-
-
-
cHopperEntity::cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(E_BLOCK_HOPPER, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
m_LastMoveItemsInTick(0),
diff --git a/source/BlockEntities/HopperEntity.h b/source/BlockEntities/HopperEntity.h
index 1a7650581..3eaa05b7c 100644
--- a/source/BlockEntities/HopperEntity.h
+++ b/source/BlockEntities/HopperEntity.h
@@ -30,9 +30,6 @@ public:
TICKS_PER_TRANSFER = 8, ///< How many ticks at minimum between two item transfers to or from the hopper
} ;
- /// Constructor used while generating a chunk; sets m_World to NULL
- cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ);
-
// tolua_end
/// Constructor used for normal operation
diff --git a/source/BlockEntities/JukeboxEntity.cpp b/source/BlockEntities/JukeboxEntity.cpp
index 1288719f6..aca376dd3 100644
--- a/source/BlockEntities/JukeboxEntity.cpp
+++ b/source/BlockEntities/JukeboxEntity.cpp
@@ -9,9 +9,9 @@
-cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
- : cBlockEntity(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, a_World)
- , m_Record( 0 )
+cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ super(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, a_World),
+ m_Record(0)
{
}
@@ -21,11 +21,7 @@ cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld
cJukeboxEntity::~cJukeboxEntity()
{
- if (m_Record >= 2256 && m_Record <= 2267)
- {
- EjectRecord();
- m_Record = 0;
- }
+ EjectRecord();
}
@@ -44,10 +40,9 @@ void cJukeboxEntity::UsedBy(cPlayer * a_Player)
PlayRecord();
}
}
- else if (m_Record >= 2256 && m_Record <= 2267)
+ else
{
EjectRecord();
- m_Record = 0;
}
}
@@ -55,7 +50,7 @@ void cJukeboxEntity::UsedBy(cPlayer * a_Player)
-void cJukeboxEntity::PlayRecord( void )
+void cJukeboxEntity::PlayRecord(void)
{
m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, m_Record);
}
@@ -64,19 +59,26 @@ void cJukeboxEntity::PlayRecord( void )
-void cJukeboxEntity::EjectRecord( void )
+void cJukeboxEntity::EjectRecord(void)
{
+ if ((m_Record < E_ITEM_FIRST_DISC) || (m_Record > E_ITEM_LAST_DISC))
+ {
+ // There's no record here
+ return;
+ }
+
cItems Drops;
Drops.push_back(cItem(m_Record, 1, 0));
m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 8);
m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, 0);
+ m_Record = 0;
}
-int cJukeboxEntity::GetRecord( void )
+int cJukeboxEntity::GetRecord(void)
{
return m_Record;
}
@@ -85,7 +87,7 @@ int cJukeboxEntity::GetRecord( void )
-void cJukeboxEntity::SetRecord( int a_Record )
+void cJukeboxEntity::SetRecord(int a_Record)
{
m_Record = a_Record;
}
@@ -94,7 +96,7 @@ void cJukeboxEntity::SetRecord( int a_Record )
-bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value )
+bool cJukeboxEntity::LoadFromJson(const Json::Value & a_Value)
{
m_PosX = a_Value.get("x", 0).asInt();
m_PosY = a_Value.get("y", 0).asInt();
@@ -109,7 +111,7 @@ bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value )
-void cJukeboxEntity::SaveToJson( Json::Value & a_Value )
+void cJukeboxEntity::SaveToJson(Json::Value & a_Value)
{
a_Value["x"] = m_PosX;
a_Value["y"] = m_PosY;
diff --git a/source/BlockEntities/JukeboxEntity.h b/source/BlockEntities/JukeboxEntity.h
index 38574c945..fcafdc479 100644
--- a/source/BlockEntities/JukeboxEntity.h
+++ b/source/BlockEntities/JukeboxEntity.h
@@ -17,26 +17,39 @@ namespace Json
+// tolua_begin
+
class cJukeboxEntity :
public cBlockEntity
{
+ typedef cBlockEntity super;
public:
+
+ // tolua_end
+
cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cJukeboxEntity();
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson( Json::Value& a_Value ) override;
-
- int GetRecord( void );
- void SetRecord( int a_Record );
- void PlayRecord( void );
- void EjectRecord( void );
- virtual void UsedBy( cPlayer * a_Player ) override;
+ bool LoadFromJson(const Json::Value & a_Value);
+ virtual void SaveToJson(Json::Value & a_Value) override;
+
+ // tolua_begin
+
+ int GetRecord(void);
+ void SetRecord(int a_Record);
+ void PlayRecord(void);
+
+ /// Ejects the currently held record as a pickup. Does nothing when no record inserted.
+ void EjectRecord(void);
+
+ // tolua_end
+
+ virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override { };
private:
int m_Record;
-};
+} ; // tolua_end
diff --git a/source/BlockEntities/NoteEntity.cpp b/source/BlockEntities/NoteEntity.cpp
index 6dc0e20a1..1b0620299 100644
--- a/source/BlockEntities/NoteEntity.cpp
+++ b/source/BlockEntities/NoteEntity.cpp
@@ -6,17 +6,12 @@
#include <json/json.h>
-cNoteEntity::cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
- : cBlockEntity(E_BLOCK_NOTE_BLOCK, a_BlockX, a_BlockY, a_BlockZ, a_World)
- , m_Pitch( 0 )
-{
-}
-
-
-cNoteEntity::~cNoteEntity()
+cNoteEntity::cNoteEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
+ super(E_BLOCK_NOTE_BLOCK, a_BlockX, a_BlockY, a_BlockZ, a_World),
+ m_Pitch(0)
{
}
@@ -24,7 +19,7 @@ cNoteEntity::~cNoteEntity()
-void cNoteEntity::UsedBy( cPlayer * a_Player )
+void cNoteEntity::UsedBy(cPlayer * a_Player)
{
IncrementPitch();
MakeSound();
@@ -34,7 +29,7 @@ void cNoteEntity::UsedBy( cPlayer * a_Player )
-void cNoteEntity::MakeSound( void )
+void cNoteEntity::MakeSound(void)
{
char instrument;
AString sampleName;
@@ -102,7 +97,7 @@ void cNoteEntity::MakeSound( void )
-char cNoteEntity::GetPitch( void )
+char cNoteEntity::GetPitch(void)
{
return m_Pitch;
}
@@ -111,7 +106,7 @@ char cNoteEntity::GetPitch( void )
-void cNoteEntity::SetPitch( char a_Pitch )
+void cNoteEntity::SetPitch(char a_Pitch)
{
m_Pitch = a_Pitch % 25;
}
@@ -120,16 +115,16 @@ void cNoteEntity::SetPitch( char a_Pitch )
-void cNoteEntity::IncrementPitch( void )
+void cNoteEntity::IncrementPitch(void)
{
- SetPitch( m_Pitch + 1 );
+ SetPitch(m_Pitch + 1);
}
-bool cNoteEntity::LoadFromJson( const Json::Value & a_Value )
+bool cNoteEntity::LoadFromJson(const Json::Value & a_Value)
{
m_PosX = a_Value.get("x", 0).asInt();
@@ -145,7 +140,7 @@ bool cNoteEntity::LoadFromJson( const Json::Value & a_Value )
-void cNoteEntity::SaveToJson( Json::Value & a_Value )
+void cNoteEntity::SaveToJson(Json::Value & a_Value)
{
a_Value["x"] = m_PosX;
a_Value["y"] = m_PosY;
diff --git a/source/BlockEntities/NoteEntity.h b/source/BlockEntities/NoteEntity.h
index 385591df6..e2d088f44 100644
--- a/source/BlockEntities/NoteEntity.h
+++ b/source/BlockEntities/NoteEntity.h
@@ -26,26 +26,37 @@ enum ENUM_NOTE_INSTRUMENTS
+// tolua_begin
+
class cNoteEntity :
public cBlockEntity
{
+ typedef cBlockEntity super;
public:
- cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
- virtual ~cNoteEntity();
- bool LoadFromJson( const Json::Value& a_Value );
- virtual void SaveToJson( Json::Value& a_Value ) override;
+ // tolua_end
- char GetPitch( void );
- void SetPitch( char a_Pitch );
- void IncrementPitch( void );
- void MakeSound( void );
- virtual void UsedBy( cPlayer * a_Player ) override;
+ /// Creates a new note entity. a_World may be NULL
+ cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
+
+ bool LoadFromJson(const Json::Value & a_Value);
+ virtual void SaveToJson(Json::Value & a_Value) override;
+
+ // tolua_begin
+
+ char GetPitch(void);
+ void SetPitch(char a_Pitch);
+ void IncrementPitch(void);
+ void MakeSound(void);
+
+ // tolua_end
+
+ virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override { };
private:
- unsigned char m_Pitch;
-};
+ char m_Pitch;
+} ; // tolua_export
diff --git a/source/BlockEntities/SignEntity.cpp b/source/BlockEntities/SignEntity.cpp
index 2c160e603..81f6f6d77 100644
--- a/source/BlockEntities/SignEntity.cpp
+++ b/source/BlockEntities/SignEntity.cpp
@@ -1,29 +1,19 @@
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "SignEntity.h"
+// SignEntity.cpp
-#include "../Entities/Player.h"
-// #include "ClientHandle.h"
-// #include "World.h"
-// #include "Root.h"
+// Implements the cSignEntity class representing a single sign in the world
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include <json/json.h>
+#include "SignEntity.h"
+#include "../Entities/Player.h"
-cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World)
- : cBlockEntity(a_BlockType, a_X, a_Y, a_Z, a_World)
-{
-}
-
-
-
-
-
-cSignEntity::~cSignEntity()
+cSignEntity::cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World) :
+ super(a_BlockType, a_X, a_Y, a_Z, a_World)
{
}
@@ -32,16 +22,16 @@ cSignEntity::~cSignEntity()
// It don't do anything when 'used'
-void cSignEntity::UsedBy( cPlayer * a_Player )
+void cSignEntity::UsedBy(cPlayer * a_Player)
{
- (void)a_Player;
+ UNUSED(a_Player);
}
-void cSignEntity::SetLines( const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4 )
+void cSignEntity::SetLines(const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
m_Line[0] = a_Line1;
m_Line[1] = a_Line2;
@@ -53,25 +43,28 @@ void cSignEntity::SetLines( const AString & a_Line1, const AString & a_Line2, co
-void cSignEntity::SetLine( int a_Index, const AString & a_Line )
+void cSignEntity::SetLine(int a_Index, const AString & a_Line)
{
- if( a_Index < 4 && a_Index > -1 )
+ if ((a_Index < 0) || (a_Index >= ARRAYCOUNT(m_Line)))
{
- m_Line[a_Index] = a_Line;
+ LOGWARNING("%s: setting a non-existent line %d (value \"%s\"", __FUNCTION__, a_Index, a_Line.c_str());
+ return;
}
+ m_Line[a_Index] = a_Line;
}
-AString cSignEntity::GetLine( int a_Index ) const
+AString cSignEntity::GetLine(int a_Index) const
{
- if( a_Index < 4 && a_Index > -1 )
+ if ((a_Index < 0) || (a_Index >= ARRAYCOUNT(m_Line)))
{
- return m_Line[a_Index];
+ LOGWARNING("%s: requesting a non-existent line %d", __FUNCTION__, a_Index);
+ return "";
}
- return "";
+ return m_Line[a_Index];
}
@@ -87,19 +80,7 @@ void cSignEntity::SendTo(cClientHandle & a_Client)
-#define READ(File, Var) \
- if (File.Read(&Var, sizeof(Var)) != sizeof(Var)) \
- { \
- LOGERROR("ERROR READING cSignEntity %s FROM FILE (line %d)", #Var, __LINE__); \
- return false; \
- }
-
-
-
-
-
-
-bool cSignEntity::LoadFromJson( const Json::Value & a_Value )
+bool cSignEntity::LoadFromJson(const Json::Value & a_Value)
{
m_PosX = a_Value.get("x", 0).asInt();
m_PosY = a_Value.get("y", 0).asInt();
@@ -113,7 +94,11 @@ bool cSignEntity::LoadFromJson( const Json::Value & a_Value )
return true;
}
-void cSignEntity::SaveToJson( Json::Value & a_Value )
+
+
+
+
+void cSignEntity::SaveToJson(Json::Value & a_Value)
{
a_Value["x"] = m_PosX;
a_Value["y"] = m_PosY;
diff --git a/source/BlockEntities/SignEntity.h b/source/BlockEntities/SignEntity.h
index b4e7a141f..d998ff1e8 100644
--- a/source/BlockEntities/SignEntity.h
+++ b/source/BlockEntities/SignEntity.h
@@ -1,4 +1,12 @@
+// SignEntity.h
+
+// Declares the cSignEntity class representing a single sign in the world
+
+
+
+
+
#pragma once
#include "BlockEntity.h"
@@ -13,28 +21,46 @@ namespace Json
}
+
+
+
+// tolua_begin
+
class cSignEntity :
public cBlockEntity
{
+ typedef cBlockEntity super;
+
public:
+
+ // tolua_end
+
+ /// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL
cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
- virtual ~cSignEntity();
bool LoadFromJson( const Json::Value& a_Value );
virtual void SaveToJson(Json::Value& a_Value ) override;
- void SetLines( const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4 );
- void SetLine( int a_Index, const AString & a_Line );
-
- AString GetLine( int a_Index ) const;
+ // tolua_begin
+
+ /// Sets all the sign's lines
+ void SetLines(const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
+
+ /// Sets individual line (zero-based index)
+ void SetLine(int a_Index, const AString & a_Line);
- virtual void UsedBy( cPlayer * a_Player ) override;
+ /// Retrieves individual line (zero-based index)
+ AString GetLine(int a_Index) const;
+
+ // tolua_end
+
+ virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override;
private:
AString m_Line[4];
-};
+} ; // tolua_export
diff --git a/source/BlockID.cpp b/source/BlockID.cpp
index f8949577e..4467d7e82 100644
--- a/source/BlockID.cpp
+++ b/source/BlockID.cpp
@@ -461,23 +461,26 @@ eDimension StringToDimension(const AString & a_DimensionString)
/// Translates damage type constant to a string representation (built-in).
AString DamageTypeToString(eDamageType a_DamageType)
{
+ // Make sure to keep this alpha-sorted.
switch (a_DamageType)
{
+ case dtAdmin: return "dtAdmin";
case dtAttack: return "dtAttack";
- case dtRangedAttack: return "dtRangedAttack";
- case dtLightning: return "dtLightning";
- case dtFalling: return "dtFalling";
- case dtDrowning: return "dtDrowning";
- case dtSuffocating: return "dtSuffocation";
- case dtStarving: return "dtStarving";
case dtCactusContact: return "dtCactusContact";
- case dtLavaContact: return "dtLavaContact";
- case dtPoisoning: return "dtPoisoning";
- case dtOnFire: return "dtOnFire";
+ case dtDrowning: return "dtDrowning";
+ case dtEnderPearl: return "dtEnderPearl";
+ case dtFalling: return "dtFalling";
case dtFireContact: return "dtFireContact";
case dtInVoid: return "dtInVoid";
+ case dtLavaContact: return "dtLavaContact";
+ case dtLightning: return "dtLightning";
+ case dtOnFire: return "dtOnFire";
+ case dtPoisoning: return "dtPoisoning";
case dtPotionOfHarming: return "dtPotionOfHarming";
- case dtAdmin: return "dtAdmin";
+ case dtRangedAttack: return "dtRangedAttack";
+ case dtStarving: return "dtStarving";
+ case dtSuffocating: return "dtSuffocation";
+
}
// Unknown damage type:
diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h
index e7b320eac..9dd65aae2 100644
--- a/source/Blocks/BlockCrops.h
+++ b/source/Blocks/BlockCrops.h
@@ -79,6 +79,12 @@ public:
{
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
NIBBLETYPE Light = a_World->GetBlockBlockLight(a_BlockX, a_BlockY, a_BlockZ);
+ NIBBLETYPE SkyLight = a_World->GetBlockSkyLight(a_BlockX, a_BlockY, a_BlockZ);
+
+ if (SkyLight > Light)
+ {
+ Light = SkyLight;
+ }
if ((Meta < 7) && (Light > 8))
{
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index cfdcc783c..1c937c894 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -1261,75 +1261,22 @@ void cChunk::CreateBlockEntities(void)
switch (BlockType)
{
case E_BLOCK_CHEST:
- {
- if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
- {
- m_BlockEntities.push_back(new cChestEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
- }
- break;
- }
-
case E_BLOCK_DISPENSER:
- {
- if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
- {
- m_BlockEntities.push_back(new cDispenserEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
- }
- break;
- }
-
case E_BLOCK_DROPPER:
- {
- if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
- {
- m_BlockEntities.push_back(new cDropperEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
- }
- break;
- }
-
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_FURNACE:
- {
- if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
- {
- NIBBLETYPE BlockMeta = cChunkDef::GetNibble(m_BlockMeta, x, y, z);
- m_BlockEntities.push_back(new cFurnaceEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, BlockType, BlockMeta, m_World));
- }
- break;
- }
-
case E_BLOCK_HOPPER:
- {
- if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
- {
- m_BlockEntities.push_back(new cHopperEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
- }
- }
-
case E_BLOCK_SIGN_POST:
case E_BLOCK_WALLSIGN:
- {
- if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
- {
- m_BlockEntities.push_back( new cSignEntity(BlockType, x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
- }
- break;
- }
-
case E_BLOCK_NOTE_BLOCK:
- {
- if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
- {
- m_BlockEntities.push_back(new cNoteEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
- }
- break;
- }
-
case E_BLOCK_JUKEBOX:
{
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
{
- m_BlockEntities.push_back(new cJukeboxEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World));
+ m_BlockEntities.push_back(cBlockEntity::CreateByBlockType(
+ BlockType, GetMeta(x, y, z),
+ x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World
+ ));
}
break;
}
@@ -1426,45 +1373,17 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType,
switch (a_BlockType)
{
case E_BLOCK_CHEST:
- {
- AddBlockEntity(new cChestEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
- break;
- }
case E_BLOCK_DISPENSER:
- {
- AddBlockEntity(new cDispenserEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
- break;
- }
case E_BLOCK_DROPPER:
- {
- AddBlockEntity(new cDropperEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
- break;
- }
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_FURNACE:
- {
- AddBlockEntity(new cFurnaceEntity(WorldPos.x, WorldPos.y, WorldPos.z, a_BlockType, a_BlockMeta, m_World));
- break;
- }
case E_BLOCK_HOPPER:
- {
- AddBlockEntity(new cHopperEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
- break;
- }
case E_BLOCK_SIGN_POST:
case E_BLOCK_WALLSIGN:
- {
- AddBlockEntity(new cSignEntity(a_BlockType, WorldPos.x, WorldPos.y, WorldPos.z, m_World));
- break;
- }
case E_BLOCK_NOTE_BLOCK:
- {
- AddBlockEntity(new cNoteEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
- break;
- }
case E_BLOCK_JUKEBOX:
{
- AddBlockEntity(new cJukeboxEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
+ AddBlockEntity(cBlockEntity::CreateByBlockType(a_BlockType, a_BlockMeta, WorldPos.x, WorldPos.y, WorldPos.z, m_World));
break;
}
} // switch (a_BlockType)
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index f8fd4a8b7..daf09d4ea 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -260,6 +260,9 @@ void cClientHandle::Authenticate(void)
// Send health
m_Player->SendHealth();
+
+ // Send experience
+ m_Player->SendExperience();
// Send gamemode (1.6.1 movementSpeed):
SendGameMode(m_Player->GetGameMode());
@@ -1873,6 +1876,15 @@ void cClientHandle::SendRespawn(void)
+void cClientHandle::SendExperience(void)
+{
+ m_Protocol->SendExperience();
+}
+
+
+
+
+
void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
{
m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
diff --git a/source/ClientHandle.h b/source/ClientHandle.h
index 3844937ad..b887bb11a 100644
--- a/source/ClientHandle.h
+++ b/source/ClientHandle.h
@@ -120,6 +120,7 @@ public:
void SendPlayerPosition (void);
void SendPlayerSpawn (const cPlayer & a_Player);
void SendRespawn (void);
+ void SendExperience (void);
void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data);
void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock);
diff --git a/source/Entities/Player.cpp b/source/Entities/Player.cpp
index 098417dc5..436ae0cfc 100644
--- a/source/Entities/Player.cpp
+++ b/source/Entities/Player.cpp
@@ -66,7 +66,9 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_EatingFinishTick(-1)
, m_IsChargingBow(false)
, m_BowCharge(0)
- , m_XpTotal(0)
+ , m_CurrentXp(0)
+ , m_LifetimeTotalXp(0)
+ , m_bDirtyExperience(false)
{
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
@@ -222,6 +224,12 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
{
m_BowCharge += 1;
}
+
+ //handle updating experience
+ if (m_bDirtyExperience)
+ {
+ SendExperience();
+ }
if (m_bDirtyPosition)
{
@@ -262,7 +270,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
-int cPlayer::CalcLevelFromXp(int a_XpTotal)
+short cPlayer::CalcLevelFromXp(short a_XpTotal)
{
//level 0 to 15
if(a_XpTotal <= XP_TO_LEVEL15)
@@ -273,18 +281,18 @@ int cPlayer::CalcLevelFromXp(int a_XpTotal)
//level 30+
if(a_XpTotal > XP_TO_LEVEL30)
{
- return (int) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7;
+ return (short) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7;
}
//level 16 to 30
- return (int) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal )))) / 3;
+ return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal )))) / 3;
}
-int cPlayer::XpForLevel(int a_Level)
+short cPlayer::XpForLevel(short a_Level)
{
//level 0 to 15
if(a_Level <= 15)
@@ -295,46 +303,51 @@ int cPlayer::XpForLevel(int a_Level)
//level 30+
if(a_Level >= 31)
{
- return (int) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 );
+ return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 );
}
//level 16 to 30
- return (int) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360 );
+ return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360 );
}
-int cPlayer::XpGetLevel()
+short cPlayer::GetXpLevel()
{
- return CalcLevelFromXp(m_XpTotal);
+ return CalcLevelFromXp(m_CurrentXp);
}
-float cPlayer::XpGetPercentage()
+float cPlayer::GetXpPercentage()
{
- int currentLevel = CalcLevelFromXp(m_XpTotal);
+ short int currentLevel = CalcLevelFromXp(m_CurrentXp);
+ short int currentLevel_XpBase = XpForLevel(currentLevel);
- return (float)m_XpTotal / (float)XpForLevel(1+currentLevel);
+ return (float)(m_CurrentXp - currentLevel_XpBase) /
+ (float)(XpForLevel(1+currentLevel) - currentLevel_XpBase);
}
-bool cPlayer::SetExperience(int a_XpTotal)
+bool cPlayer::SetCurrentExperience(short int a_CurrentXp)
{
- if(!(a_XpTotal >= 0) || (a_XpTotal > (INT_MAX - m_XpTotal)))
+ if(!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp)))
{
- LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_XpTotal);
+ LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp);
return false; //oops, they gave us a dodgey number
}
- m_XpTotal = a_XpTotal;
+ m_CurrentXp = a_CurrentXp;
+
+ // Set experience to be updated
+ m_bDirtyExperience = true;
return true;
}
@@ -343,21 +356,38 @@ bool cPlayer::SetExperience(int a_XpTotal)
-int cPlayer::AddExperience(int a_Xp_delta)
+short cPlayer::DeltaExperience(short a_Xp_delta)
{
- if(a_Xp_delta < 0)
+ //ToDo: figure out a better name?...
+ if(a_Xp_delta > (SHRT_MAX - m_LifetimeTotalXp))
{
- //value was negative, abort and report
- LOGWARNING("Attempt was made to increment Xp by %d, must be positive",
+ // Value was bad, abort and report
+ LOGWARNING("Attempt was made to increment Xp by %d, which was bad",
a_Xp_delta);
- return -1; //should we instead just return the current Xp?
+ return -1; // Should we instead just return the current Xp?
+ }
+
+ m_CurrentXp += a_Xp_delta;
+
+ // Make sure they didn't subtract too much
+ if(m_CurrentXp < MIN_EXPERIENCE)
+ {
+ m_CurrentXp = MIN_EXPERIENCE;
+ }
+
+ // Update total for score calculation
+ if(a_Xp_delta > 0)
+ {
+ m_LifetimeTotalXp += a_Xp_delta;
}
-
- LOGD("Player \"%s\" earnt %d experience", m_PlayerName.c_str(), a_Xp_delta);
- m_XpTotal += a_Xp_delta;
+ LOGD("Player \"%s\" gained/lost %d experience, total is now: %d",
+ m_PlayerName.c_str(), a_Xp_delta, m_CurrentXp);
- return m_XpTotal;
+ // Set experience to be updated
+ m_bDirtyExperience = true;
+
+ return m_CurrentXp;
}
@@ -607,6 +637,19 @@ void cPlayer::SendHealth(void)
+void cPlayer::SendExperience(void)
+{
+ if (m_ClientHandle != NULL)
+ {
+ m_ClientHandle->SendExperience();
+ m_bDirtyExperience = false;
+ }
+}
+
+
+
+
+
void cPlayer::ClearInventoryPaintSlots(void)
{
// Clear the list of slots that are being inventory-painted. Used by cWindow only
@@ -759,6 +802,11 @@ void cPlayer::Respawn(void)
m_FoodLevel = MAX_FOOD_LEVEL;
m_FoodSaturationLevel = 5;
+ // Reset Experience
+ m_CurrentXp = MIN_EXPERIENCE;
+ m_LifetimeTotalXp = MIN_EXPERIENCE;
+ // ToDo: send score to client? How?
+
m_ClientHandle->SendRespawn();
// Extinguish the fire:
@@ -1411,14 +1459,16 @@ bool cPlayer::LoadFromDisk()
SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
}
- m_Health = root.get("health", 0).asInt();
+ m_Health = root.get("health", 0).asInt();
m_AirLevel = root.get("air", MAX_AIR_LEVEL).asInt();
m_FoodLevel = root.get("food", MAX_FOOD_LEVEL).asInt();
m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
m_FoodTickTimer = root.get("foodTickTimer", 0).asInt();
m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();
+ m_LifetimeTotalXp = (short) root.get("xpTotal", 0).asInt();
+ m_CurrentXp = (short) root.get("xpCurrent", 0).asInt();
- SetExperience(root.get("experience", 0).asInt());
+ //SetExperience(root.get("experience", 0).asInt());
m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();
@@ -1460,7 +1510,8 @@ bool cPlayer::SaveToDisk()
root["rotation"] = JSON_PlayerRotation;
root["inventory"] = JSON_Inventory;
root["health"] = m_Health;
- root["experience"] = m_XpTotal;
+ root["xpTotal"] = m_LifetimeTotalXp;
+ root["xpCurrent"] = m_CurrentXp;
root["air"] = m_AirLevel;
root["food"] = m_FoodLevel;
root["foodSaturation"] = m_FoodSaturationLevel;
diff --git a/source/Entities/Player.h b/source/Entities/Player.h
index ab2f94d4c..bda25715d 100644
--- a/source/Entities/Player.h
+++ b/source/Entities/Player.h
@@ -32,6 +32,7 @@ public:
EATING_TICKS = 30, ///< Number of ticks it takes to eat an item
MAX_AIR_LEVEL = 300,
DROWNING_TICKS = 10, //number of ticks per heart of damage
+ MIN_EXPERIENCE = 0,
} ;
// tolua_end
@@ -71,21 +72,25 @@ public:
Returns true on success
"should" really only be called at init or player death, plugins excepted
*/
- bool SetExperience(int a_XpTotal);
+ bool SetCurrentExperience(short a_XpTotal);
- /* Adds Xp, "should" not inc more than MAX_EXPERIENCE_ORB_SIZE unless you're a plugin being funny, *cough* cheating
- Returns the new total experience, -1 on error
+ /* changes Xp by Xp_delta, you "shouldn't" inc more than MAX_EXPERIENCE_ORB_SIZE
+ Wont't allow xp to go negative
+ Returns the new current experience, -1 on error
*/
- int AddExperience(int a_Xp_delta);
+ short DeltaExperience(short a_Xp_delta);
- /// Gets the experience total - XpTotal
- inline int XpGetTotal(void) { return m_XpTotal; }
+ /// Gets the experience total - XpTotal for score on death
+ inline short GetXpLifetimeTotal(void) { return m_LifetimeTotalXp; }
+
+ /// Gets the currrent experience
+ inline short GetCurrentXp(void) { return m_CurrentXp; }
/// Gets the current level - XpLevel
- int XpGetLevel(void);
+ short GetXpLevel(void);
/// Gets the experience bar percentage - XpP
- float XpGetPercentage(void);
+ float GetXpPercentage(void);
// tolua_end
@@ -269,6 +274,8 @@ public:
void UseEquippedItem(void);
void SendHealth(void);
+
+ void SendExperience(void);
// In UI windows, the item that the player is dragging:
bool IsDraggingItem(void) const { return !m_DraggingItem.IsEmpty(); }
@@ -413,13 +420,17 @@ protected:
Int64 m_EatingFinishTick;
/// Player Xp level
- int m_XpTotal;
+ short int m_LifetimeTotalXp;
+ short int m_CurrentXp;
+
+ // flag saying we need to send a xp update to client
+ bool m_bDirtyExperience;
/// Caculates the Xp needed for a given level, ref: http://minecraft.gamepedia.com/XP
- static int XpForLevel(int a_Level);
+ static short XpForLevel(short int a_Level);
/// inverse of XpAtLevel, ref: http://minecraft.gamepedia.com/XP values are as per this with pre-calculations
- static int CalcLevelFromXp(int a_XpTotal);
+ static short CalcLevelFromXp(short int a_CurrentXp);
bool m_IsChargingBow;
int m_BowCharge;
diff --git a/source/Generating/Caves.cpp b/source/Generating/Caves.cpp
index 4221ea187..df45bb4c2 100644
--- a/source/Generating/Caves.cpp
+++ b/source/Generating/Caves.cpp
@@ -55,7 +55,7 @@ struct cCaveDefPoint
int m_BlockY;
int m_BlockZ;
int m_Radius;
-
+
cCaveDefPoint(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Radius) :
m_BlockX(a_BlockX),
m_BlockY(a_BlockY),
@@ -78,22 +78,22 @@ class cCaveTunnel
int m_MinBlockX, m_MaxBlockX;
int m_MinBlockY, m_MaxBlockY;
int m_MinBlockZ, m_MaxBlockZ;
-
+
/// Generates the shaping defpoints for the ravine, based on the ravine block coords and noise
void Randomize(cNoise & a_Noise);
-
+
/// Refines (adds and smooths) defpoints from a_Src into a_Dst; returns false if no refinement possible (segments too short)
bool RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst);
-
+
/// Does rounds of smoothing, two passes of RefineDefPoints(), as long as they return true
void Smooth(void);
-
+
/// Linearly interpolates the points so that the maximum distance between two neighbors is max 1 block
void FinishLinear(void);
-
+
/// Calculates the bounding box of the points present
void CalcBoundingBox(void);
-
+
public:
cCaveDefPoints m_Points;
@@ -102,14 +102,14 @@ public:
int a_BlockEndX, int a_BlockEndY, int a_BlockEndZ, int a_EndRadius,
cNoise & a_Noise
);
-
+
/// Carves the tunnel into the chunk specified
void ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDef::BlockTypes & a_BlockTypes,
cChunkDef::HeightMap & a_HeightMap
);
-
+
#ifdef _DEBUG
AString ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const;
#endif // _DEBUG
@@ -128,17 +128,17 @@ public:
// The generating block position; is read directly in cStructGenWormNestCaves::GetCavesForChunk()
int m_BlockX;
int m_BlockZ;
-
+
cCaveSystem(int a_BlockX, int a_BlockZ, int a_MaxOffset, int a_Size, cNoise & a_Noise);
~cCaveSystem();
-
+
/// Carves the cave system into the chunk specified
void ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDef::BlockTypes & a_BlockTypes,
cChunkDef::HeightMap & a_HeightMap
);
-
+
#ifdef _DEBUG
AString ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) const;
#endif // _DEBUG
@@ -146,15 +146,15 @@ public:
protected:
int m_Size;
cCaveTunnels m_Tunnels;
-
+
void Clear(void);
/// Generates a_Segment successive tunnels, with possible branches. Generates the same output for the same [x, y, z, a_Segments]
void GenerateTunnelsFromPoint(
- int a_OriginX, int a_OriginY, int a_OriginZ,
+ int a_OriginX, int a_OriginY, int a_OriginZ,
cNoise & a_Noise, int a_Segments
);
-
+
/// Returns a radius based on the location provided.
int GetRadius(cNoise & a_Noise, int a_OriginX, int a_OriginY, int a_OriginZ);
} ;
@@ -174,19 +174,19 @@ cCaveTunnel::cCaveTunnel(
{
m_Points.push_back(cCaveDefPoint(a_BlockStartX, a_BlockStartY, a_BlockStartZ, a_StartRadius));
m_Points.push_back(cCaveDefPoint(a_BlockEndX, a_BlockEndY, a_BlockEndZ, a_EndRadius));
-
+
if ((a_BlockStartY <= 0) && (a_BlockEndY <= 0))
{
// Don't bother detailing this cave, it's under the world anyway
return;
}
-
+
Randomize(a_Noise);
Smooth();
-
+
// We know that the linear finishing won't affect the bounding box, so let's calculate it now, as we have less data:
CalcBoundingBox();
-
+
FinishLinear();
}
@@ -308,7 +308,7 @@ void cCaveTunnel::FinishLinear(void)
// For each segment, use Bresenham's 3D line algorithm to draw a "line" of defpoints
cCaveDefPoints Pts;
std::swap(Pts, m_Points);
-
+
m_Points.reserve(Pts.size() * 3);
int PrevX = Pts.front().m_BlockX;
int PrevY = Pts.front().m_BlockY;
@@ -324,7 +324,6 @@ void cCaveTunnel::FinishLinear(void)
int sx = (PrevX < x1) ? 1 : -1;
int sy = (PrevY < y1) ? 1 : -1;
int sz = (PrevZ < z1) ? 1 : -1;
- int err = dx - dz;
int R = itr->m_Radius;
if (dx >= std::max(dy, dz)) // x dominant
@@ -418,7 +417,7 @@ void cCaveTunnel::FinishLinear(void)
PrevY += sy;
yd -= dz;
}
-
+
// move along z
PrevZ += sz;
xd += dx;
@@ -453,8 +452,8 @@ void cCaveTunnel::CalcBoundingBox(void)
void cCaveTunnel::ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDef::BlockTypes & a_BlockTypes,
cChunkDef::HeightMap & a_HeightMap
)
{
@@ -462,7 +461,7 @@ void cCaveTunnel::ProcessChunk(
int BaseZ = a_ChunkZ * cChunkDef::Width;
if (
(BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX) ||
- (BaseX > m_MaxBlockX) || (BaseX + cChunkDef::Width < m_MinBlockX)
+ (BaseZ > m_MaxBlockZ) || (BaseZ + cChunkDef::Width < m_MinBlockZ)
)
{
// Tunnel does not intersect the chunk at all, bail out
@@ -485,7 +484,7 @@ void cCaveTunnel::ProcessChunk(
// Cannot intersect, bail out early
continue;
}
-
+
// Carve out a sphere around the xyz point, m_Radius in diameter; skip 3/7 off the top and bottom:
int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc
int DifY = itr->m_BlockY;
@@ -493,7 +492,7 @@ void cCaveTunnel::ProcessChunk(
int Bottom = std::max(itr->m_BlockY - 3 * itr->m_Radius / 7, 1);
int Top = std::min(itr->m_BlockY + 3 * itr->m_Radius / 7, (int)(cChunkDef::Height));
int SqRad = itr->m_Radius * itr->m_Radius;
- for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++)
+ for (int z = 0; z < cChunkDef::Width; z++) for (int x = 0; x < cChunkDef::Width; x++)
{
for (int y = Bottom; y <= Top; y++)
{
@@ -527,9 +526,9 @@ void cCaveTunnel::ProcessChunk(
} // for y
} // for x, z
} // for itr - m_Points[]
-
+
/*
- #ifdef _DEBUG
+ #ifdef _DEBUG
// For debugging purposes, outline the shape of the cave using glowstone, *after* carving the entire cave:
for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr)
{
@@ -587,7 +586,7 @@ cStructGenWormNestCaves::cCaveSystem::cCaveSystem(int a_BlockX, int a_BlockZ, in
int OriginX = a_BlockX + (a_Noise.IntNoise3DInt(13 * a_BlockX, 17 * a_BlockZ, 11 * i) / 19) % a_MaxOffset;
int OriginZ = a_BlockZ + (a_Noise.IntNoise3DInt(17 * a_BlockX, 13 * a_BlockZ, 11 * i) / 23) % a_MaxOffset;
int OriginY = 20 + (a_Noise.IntNoise3DInt(19 * a_BlockX, 13 * a_BlockZ, 11 * i) / 17) % 20;
-
+
// Generate three branches from the origin point:
// The tunnels generated depend on X, Y, Z and Branches,
// for the same set of numbers it generates the same offsets!
@@ -613,8 +612,8 @@ cStructGenWormNestCaves::cCaveSystem::~cCaveSystem()
void cStructGenWormNestCaves::cCaveSystem::ProcessChunk(
- int a_ChunkX, int a_ChunkZ,
- cChunkDef::BlockTypes & a_BlockTypes,
+ int a_ChunkX, int a_ChunkZ,
+ cChunkDef::BlockTypes & a_BlockTypes,
cChunkDef::HeightMap & a_HeightMap
)
{
@@ -645,14 +644,14 @@ AString cStructGenWormNestCaves::cCaveSystem::ExportAsSVG(int a_Color, int a_Off
AppendPrintf(SVG, "<path style=\"fill:none;stroke:#ff0000;stroke-width:1px;\"\nd=\"M %d,%d L %d,%d\"/>\n",
a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ - 5, a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ + 5
);
-
+
// A gray line from the base point to the first point of the ravine, for identification:
AppendPrintf(SVG, "<path style=\"fill:none;stroke:#cfcfcf;stroke-width:1px;\"\nd=\"M %d,%d L %d,%d\"/>\n",
- a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ,
- a_OffsetX + m_Tunnels.front()->m_Points.front().m_BlockX,
+ a_OffsetX + m_BlockX, a_OffsetZ + m_BlockZ,
+ a_OffsetX + m_Tunnels.front()->m_Points.front().m_BlockX,
a_OffsetZ + m_Tunnels.front()->m_Points.front().m_BlockZ
);
-
+
// Offset guides:
if (a_OffsetX > 0)
{
@@ -666,7 +665,7 @@ AString cStructGenWormNestCaves::cCaveSystem::ExportAsSVG(int a_Color, int a_Off
a_OffsetZ, a_OffsetZ
);
}
-
+
return SVG;
}
#endif // _DEBUG
@@ -689,7 +688,7 @@ void cStructGenWormNestCaves::cCaveSystem::Clear(void)
void cStructGenWormNestCaves::cCaveSystem::GenerateTunnelsFromPoint(
- int a_OriginX, int a_OriginY, int a_OriginZ,
+ int a_OriginX, int a_OriginY, int a_OriginZ,
cNoise & a_Noise, int a_NumSegments
)
{
@@ -727,7 +726,7 @@ int cStructGenWormNestCaves::cCaveSystem::GetRadius(cNoise & a_Noise, int a_Orig
// We want mapping 384 -> 3, 0 -> 19, 768 -> 19, so divide by 24 to get [0 .. 31] with center at 16, then use abs() to fold around the center
int res = 3 + abs((sum / 24) - 16);
*/
-
+
// Algorithm of choice: random value in the range of zero to random value - heavily towards zero
int res = MIN_RADIUS + (rnd >> 8) % ((rnd % (MAX_RADIUS - MIN_RADIUS)) + 1);
return res;
@@ -815,7 +814,7 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru
++itr;
}
} // for itr - m_Cache[]
-
+
for (int x = 0; x < NEIGHBORHOOD_SIZE; x++)
{
int RealX = (BaseX + x) * m_Grid;
@@ -837,11 +836,11 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru
}
}
}
-
+
// Copy a_Caves into m_Cache to the beginning:
cCaveSystems CavesCopy(a_Caves);
m_Cache.splice(m_Cache.begin(), CavesCopy, CavesCopy.begin(), CavesCopy.end());
-
+
// Trim the cache if it's too long:
if (m_Cache.size() > 100)
{
@@ -855,7 +854,7 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru
std::advance(itr, 100);
m_Cache.erase(itr, m_Cache.end());
}
-
+
/*
// Uncomment this block for debugging the caves' shapes in 2D using an SVG export
#ifdef _DEBUG
@@ -869,7 +868,7 @@ void cStructGenWormNestCaves::GetCavesForChunk(int a_ChunkX, int a_ChunkZ, cStru
SVG.append((*itr)->ExportAsSVG(Color, 512, 512));
}
SVG.append("</svg>\n");
-
+
AString fnam;
Printf(fnam, "wnc\\%03d_%03d.svg", a_ChunkX, a_ChunkZ);
cFile File(fnam, cFile::fmWrite);
@@ -905,13 +904,13 @@ static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise )
void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
{
cNoise Noise(m_Seed);
- for (int z = 0; z < cChunkDef::Width; z++)
+ for (int z = 0; z < cChunkDef::Width; z++)
{
const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z);
for (int x = 0; x < cChunkDef::Width; x++)
{
const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x);
-
+
int Top = a_ChunkDesc.GetHeight(x, z);
for (int y = 1; y < Top; ++y )
{
@@ -940,18 +939,17 @@ void cStructGenMarbleCaves::GenStructures(cChunkDesc & a_ChunkDesc)
void cStructGenDualRidgeCaves::GenStructures(cChunkDesc & a_ChunkDesc)
{
- for (int z = 0; z < cChunkDef::Width; z++)
+ for (int z = 0; z < cChunkDef::Width; z++)
{
const float zz = (float)(a_ChunkDesc.GetChunkZ() * cChunkDef::Width + z) / 10;
for (int x = 0; x < cChunkDef::Width; x++)
{
const float xx = (float)(a_ChunkDesc.GetChunkX() * cChunkDef::Width + x) / 10;
-
+
int Top = a_ChunkDesc.GetHeight(x, z);
for (int y = 1; y <= Top; ++y)
{
const float yy = (float)y / 10;
- const float WaveNoise = 1;
float n1 = m_Noise1.CubicNoise3D(xx, yy, zz);
float n2 = m_Noise2.CubicNoise3D(xx, yy, zz);
float n3 = m_Noise1.CubicNoise3D(xx * 4, yy * 4, zz * 4) / 4;
diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp
index dc6c74a3c..6050430fd 100644
--- a/source/Generating/ChunkDesc.cpp
+++ b/source/Generating/ChunkDesc.cpp
@@ -8,6 +8,7 @@
#include "../BlockArea.h"
#include "../Cuboid.h"
#include "../Noise.h"
+#include "../BlockEntities/BlockEntity.h"
@@ -270,7 +271,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
a_MaxRelX += 1;
a_MaxRelY += 1;
a_MaxRelZ += 1;
-
+
// Check coords validity:
if (a_MinRelX < 0)
{
@@ -313,7 +314,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
a_MaxRelY = cChunkDef::Height - 1;
}
-
+
if (a_MinRelZ < 0)
{
LOGWARNING("%s: MinRelZ less than zero, adjusting to zero", __FUNCTION__);
@@ -370,7 +371,7 @@ void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX
HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const
{
HEIGHTTYPE MaxHeight = m_HeightMap[0];
- for (int i = 1; i < ARRAYCOUNT(m_HeightMap); i++)
+ for (unsigned int i = 1; i < ARRAYCOUNT(m_HeightMap); i++)
{
if (m_HeightMap[i] > MaxHeight)
{
@@ -397,7 +398,7 @@ void cChunkDesc::FillRelCuboid(
int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
-
+
for (int y = MinY; y <= MaxY; y++)
{
for (int z = MinZ; z <= MaxZ; z++)
@@ -428,7 +429,7 @@ void cChunkDesc::ReplaceRelCuboid(
int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
-
+
for (int y = MinY; y <= MaxY; y++)
{
for (int z = MinZ; z <= MaxZ; z++)
@@ -464,7 +465,7 @@ void cChunkDesc::FloorRelCuboid(
int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
-
+
for (int y = MinY; y <= MaxY; y++)
{
for (int z = MinZ; z <= MaxZ; z++)
@@ -505,7 +506,7 @@ void cChunkDesc::RandomFillRelCuboid(
int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
-
+
for (int y = MinY; y <= MaxY; y++)
{
for (int z = MinZ; z <= MaxZ; z++)
@@ -526,9 +527,35 @@ void cChunkDesc::RandomFillRelCuboid(
-void cChunkDesc::AddBlockEntity(cBlockEntity * a_BlockEntity)
+cBlockEntity * cChunkDesc::GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ)
{
- m_BlockEntities.push_back(a_BlockEntity);
+ int AbsX = a_RelX + m_ChunkX * cChunkDef::Width;
+ int AbsZ = a_RelZ + m_ChunkZ * cChunkDef::Width;
+ for (cBlockEntityList::iterator itr = m_BlockEntities.begin(), end = m_BlockEntities.end(); itr != end; ++itr)
+ {
+ if (((*itr)->GetPosX() == AbsX) && ((*itr)->GetPosY() == a_RelY) && ((*itr)->GetPosZ() == AbsZ))
+ {
+ // Already in the list:
+ if ((*itr)->GetBlockType() != GetBlockType(a_RelX, a_RelY, a_RelZ))
+ {
+ // Wrong type, the block type has been overwritten. Erase and create new:
+ m_BlockEntities.erase(itr);
+ break;
+ }
+ // Correct type, already present. Return it:
+ return *itr;
+ }
+ } // for itr - m_BlockEntities[]
+
+ // The block entity is not created yet, try to create it and add to list:
+ cBlockEntity * be = cBlockEntity::CreateByBlockType(GetBlockType(a_RelX, a_RelY, a_RelZ), GetBlockMeta(a_RelX, a_RelY, a_RelZ), AbsX, a_RelY, AbsZ);
+ if (be == NULL)
+ {
+ // No block entity for this block type
+ return NULL;
+ }
+ m_BlockEntities.push_back(be);
+ return be;
}
@@ -538,7 +565,7 @@ void cChunkDesc::AddBlockEntity(cBlockEntity * a_BlockEntity)
void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
{
const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();
- for (int i = 0; i < ARRAYCOUNT(a_DestMetas); i++)
+ for (unsigned int i = 0; i < ARRAYCOUNT(a_DestMetas); i++)
{
a_DestMetas[i] = AreaMetas[2 * i] | (AreaMetas[2 * i + 1] << 4);
}
diff --git a/source/Generating/ChunkDesc.h b/source/Generating/ChunkDesc.h
index 067d8494a..e130c463f 100644
--- a/source/Generating/ChunkDesc.h
+++ b/source/Generating/ChunkDesc.h
@@ -170,9 +170,12 @@ public:
);
}
- // tolua_end
+ /// Returns the block entity at the specified coords.
+ /// If there is no block entity at those coords, tries to create one, based on the block type
+ /// If the blocktype doesn't support a block entity, returns NULL.
+ cBlockEntity * GetBlockEntity(int a_RelX, int a_RelY, int a_RelZ);
- void AddBlockEntity(cBlockEntity * a_BlockEntity);
+ // tolua_end
// Accessors used by cChunkGenerator::Generator descendants:
inline cChunkDef::BiomeMap & GetBiomeMap (void) { return m_BiomeMap; }
diff --git a/source/Generating/ChunkGenerator.cpp b/source/Generating/ChunkGenerator.cpp
index 59a00b540..33c956eba 100644
--- a/source/Generating/ChunkGenerator.cpp
+++ b/source/Generating/ChunkGenerator.cpp
@@ -15,10 +15,10 @@
/// If the generation queue size exceeds this number, a warning will be output
-const int QUEUE_WARNING_LIMIT = 1000;
+const unsigned int QUEUE_WARNING_LIMIT = 1000;
/// If the generation queue size exceeds this number, chunks with no clients will be skipped
-const int QUEUE_SKIP_LIMIT = 500;
+const unsigned int QUEUE_SKIP_LIMIT = 500;
@@ -53,7 +53,7 @@ bool cChunkGenerator::Start(cWorld * a_World, cIniFile & a_IniFile)
m_World = a_World;
m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", rnd.randInt());
AString GeneratorName = a_IniFile.GetValueSet("Generator", "Generator", "Composable");
-
+
if (NoCaseCompare(GeneratorName, "Noise3D") == 0)
{
m_Generator = new cNoise3DGenerator(*this);
@@ -72,9 +72,9 @@ bool cChunkGenerator::Start(cWorld * a_World, cIniFile & a_IniFile)
LOGERROR("Generator could not start, aborting the server");
return false;
}
-
+
m_Generator->Initialize(a_World, a_IniFile);
-
+
return super::Start();
}
@@ -101,7 +101,7 @@ void cChunkGenerator::QueueGenerateChunk(int a_ChunkX, int a_ChunkY, int a_Chunk
{
{
cCSLock Lock(m_CS);
-
+
// Check if it is already in the queue:
for (cChunkCoordsList::iterator itr = m_Queue.begin(); itr != m_Queue.end(); ++itr)
{
@@ -111,7 +111,7 @@ void cChunkGenerator::QueueGenerateChunk(int a_ChunkX, int a_ChunkY, int a_Chunk
return;
}
} // for itr - m_Queue[]
-
+
// Add to queue, issue a warning if too many:
if (m_Queue.size() >= QUEUE_WARNING_LIMIT)
{
@@ -119,7 +119,7 @@ void cChunkGenerator::QueueGenerateChunk(int a_ChunkX, int a_ChunkY, int a_Chunk
}
m_Queue.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ));
}
-
+
m_Event.Set();
}
@@ -196,7 +196,7 @@ void cChunkGenerator::Execute(void)
int NumChunksGenerated = 0; // Number of chunks generated since the queue was last empty
clock_t GenerationStart = clock(); // Clock tick when the queue started to fill
clock_t LastReportTick = clock(); // Clock tick of the last report made (so that performance isn't reported too often)
-
+
while (!m_ShouldTerminate)
{
cCSLock Lock(m_CS);
@@ -219,7 +219,7 @@ void cChunkGenerator::Execute(void)
GenerationStart = clock();
LastReportTick = clock();
}
-
+
cChunkCoords coords = m_Queue.front(); // Get next coord from queue
m_Queue.erase( m_Queue.begin() ); // Remove coordinate from queue
bool SkipEnabled = (m_Queue.size() > QUEUE_SKIP_LIMIT);
@@ -243,19 +243,19 @@ void cChunkGenerator::Execute(void)
// Already generated, ignore request
continue;
}
-
+
if (SkipEnabled && !m_World->HasChunkAnyClients(coords.m_ChunkX, coords.m_ChunkZ))
{
LOGWARNING("Chunk generator overloaded, skipping chunk [%d, %d]", coords.m_ChunkX, coords.m_ChunkZ);
continue;
}
-
+
LOGD("Generating chunk [%d, %d, %d]", coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ);
DoGenerate(coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ);
-
+
// Save the chunk right after generating, so that we don't have to generate it again on next run
m_World->GetStorage().QueueSaveChunk(coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ);
-
+
NumChunksGenerated++;
} // while (!bStop)
}
@@ -269,17 +269,17 @@ void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
cRoot::Get()->GetPluginManager()->CallHookChunkGenerating(m_World, a_ChunkX, a_ChunkZ, &ChunkDesc);
m_Generator->DoGenerate(a_ChunkX, a_ChunkZ, ChunkDesc);
cRoot::Get()->GetPluginManager()->CallHookChunkGenerated(m_World, a_ChunkX, a_ChunkZ, &ChunkDesc);
-
+
#ifdef _DEBUG
// Verify that the generator has produced valid data:
ChunkDesc.VerifyHeightmap();
#endif
-
+
cChunkDef::BlockNibbles BlockMetas;
ChunkDesc.CompressBlockMetas(BlockMetas);
-
+
m_World->SetChunkData(
- a_ChunkX, a_ChunkZ,
+ a_ChunkX, a_ChunkZ,
ChunkDesc.GetBlockTypes(), BlockMetas,
NULL, NULL, // We don't have lighting, chunk will be lighted when needed
&ChunkDesc.GetHeightMap(), &ChunkDesc.GetBiomeMap(),
diff --git a/source/Generating/DistortedHeightmap.cpp b/source/Generating/DistortedHeightmap.cpp
index 98eab31b5..7e46c251e 100644
--- a/source/Generating/DistortedHeightmap.cpp
+++ b/source/Generating/DistortedHeightmap.cpp
@@ -30,7 +30,7 @@ const cDistortedHeightmap::sGenParam cDistortedHeightmap::m_GenParam[biNumBiomes
/* biExtremeHills */ {16.0f, 16.0f},
/* biForest */ { 3.0f, 3.0f},
/* biTaiga */ { 1.5f, 1.5f},
-
+
/* biSwampland */ { 0.0f, 0.0f},
/* biRiver */ { 0.0f, 0.0f},
/* biNether */ { 0.0f, 0.0f}, // Unused, but must be here due to indexing
@@ -81,7 +81,7 @@ void cDistortedHeightmap::Initialize(cIniFile & a_IniFile)
{
return;
}
-
+
// Read the params from the INI file:
m_SeaLevel = a_IniFile.GetValueSetI("Generator", "DistortedHeightmapSeaLevel", 62);
m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "DistortedHeightmapFrequencyX", 10);
@@ -103,8 +103,8 @@ void cDistortedHeightmap::PrepareState(int a_ChunkX, int a_ChunkZ)
}
m_CurChunkX = a_ChunkX;
m_CurChunkZ = a_ChunkZ;
-
-
+
+
m_HeightGen.GenHeightMap(a_ChunkX, a_ChunkZ, m_CurChunkHeights);
UpdateDistortAmps();
GenerateHeightArray();
@@ -126,13 +126,13 @@ void cDistortedHeightmap::GenerateHeightArray(void)
NOISE_DATATYPE EndY = ((NOISE_DATATYPE)(257)) / m_FrequencyY;
NOISE_DATATYPE StartZ = ((NOISE_DATATYPE)(m_CurChunkZ * cChunkDef::Width)) / m_FrequencyZ;
NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((m_CurChunkZ + 1) * cChunkDef::Width - 1)) / m_FrequencyZ;
-
+
m_NoiseDistortX.Generate3D(DistortNoiseX, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, Workspace);
m_NoiseDistortZ.Generate3D(DistortNoiseZ, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, Workspace);
// The distorted heightmap, before linear upscaling
NOISE_DATATYPE DistHei[DIM_X * DIM_Y * DIM_Z];
-
+
// Distort the heightmap using the distortion:
for (int z = 0; z < DIM_Z; z++)
{
@@ -151,7 +151,7 @@ void cDistortedHeightmap::GenerateHeightArray(void)
}
}
}
-
+
// Upscale the distorted heightmap into full dimensions:
LinearUpscale3DArray(
DistHei, DIM_X, DIM_Y, DIM_Z,
@@ -208,7 +208,7 @@ void cDistortedHeightmap::ComposeTerrain(cChunkDesc & a_ChunkDesc)
// Prepare the internal state for generating this chunk:
PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
-
+
// Compose:
a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
for (int z = 0; z < cChunkDef::Width; z++)
@@ -348,7 +348,7 @@ int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z)
{
return cChunkDef::GetHeight(m_CurChunkHeights, RelX, RelZ);
}
-
+
// Ask the cache:
HEIGHTTYPE res = 0;
if (m_HeightGen.GetHeightAt(ChunkX, ChunkZ, RelX, RelZ, res))
@@ -356,7 +356,7 @@ int cDistortedHeightmap::GetHeightmapAt(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Z)
// The height was in the cache
return res;
}
-
+
// The height is not in the cache, generate full heightmap and get it there:
cChunkDef::HeightMap Heightmap;
m_HeightGen.GenHeightMap(ChunkX, ChunkZ, Heightmap);
@@ -385,7 +385,7 @@ void cDistortedHeightmap::UpdateDistortAmps(void)
GetDistortAmpsAt(Biomes, x * INTERPOL_X, z * INTERPOL_Z, m_DistortAmpX[x + DIM_X * z], m_DistortAmpZ[x + DIM_X * z]);
}
}
-}
+}
@@ -430,7 +430,7 @@ void cDistortedHeightmap::GetDistortAmpsAt(BiomeNeighbors & a_Neighbors, int a_R
// For each biome type that has a nonzero count, calc its amps and add it:
NOISE_DATATYPE AmpX = 0;
NOISE_DATATYPE AmpZ = 0;
- for (int i = 0; i < ARRAYCOUNT(BiomeCounts); i++)
+ for (unsigned int i = 0; i < ARRAYCOUNT(BiomeCounts); i++)
{
AmpX += BiomeCounts[i] * m_GenParam[i].m_DistortAmpX;
AmpZ += BiomeCounts[i] * m_GenParam[i].m_DistortAmpZ;
diff --git a/source/Generating/EndGen.cpp b/source/Generating/EndGen.cpp
index 3eba5c47b..90a8071fa 100644
--- a/source/Generating/EndGen.cpp
+++ b/source/Generating/EndGen.cpp
@@ -18,7 +18,7 @@ enum
INTERPOL_X = 4,
INTERPOL_Y = 4,
INTERPOL_Z = 4,
-
+
// Size of chunk data, downscaled before interpolation:
DIM_X = 16 / INTERPOL_X + 1,
DIM_Y = 256 / INTERPOL_Y + 1,
@@ -59,7 +59,7 @@ void cEndGen::Initialize(cIniFile & a_IniFile)
m_FrequencyX = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyX", m_FrequencyX);
m_FrequencyY = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyY", m_FrequencyY);
m_FrequencyZ = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "EndGenFrequencyZ", m_FrequencyZ);
-
+
// Recalculate the min and max chunk coords of the island
m_MaxChunkX = (m_IslandSizeX + cChunkDef::Width - 1) / cChunkDef::Width;
m_MinChunkX = -m_MaxChunkX;
@@ -75,15 +75,15 @@ void cEndGen::Initialize(cIniFile & a_IniFile)
void cEndGen::PrepareState(int a_ChunkX, int a_ChunkZ)
{
ASSERT(!IsChunkOutsideRange(a_ChunkX, a_ChunkZ)); // Should be filtered before calling this function
-
+
if ((m_LastChunkX == a_ChunkX) && (m_LastChunkZ == a_ChunkZ))
{
return;
}
-
+
m_LastChunkX = a_ChunkX;
m_LastChunkZ = a_ChunkZ;
-
+
GenerateNoiseArray();
}
@@ -96,7 +96,7 @@ void cEndGen::GenerateNoiseArray(void)
{
NOISE_DATATYPE NoiseData[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y]
NOISE_DATATYPE Workspace[DIM_X * DIM_Y * DIM_Z]; // [x + DIM_X * z + DIM_X * DIM_Z * y]
-
+
// Generate the downscaled noise:
NOISE_DATATYPE StartX = ((NOISE_DATATYPE)(m_LastChunkX * cChunkDef::Width)) / m_FrequencyX;
NOISE_DATATYPE EndX = ((NOISE_DATATYPE)((m_LastChunkX + 1) * cChunkDef::Width)) / m_FrequencyX;
@@ -105,7 +105,7 @@ void cEndGen::GenerateNoiseArray(void)
NOISE_DATATYPE StartY = 0;
NOISE_DATATYPE EndY = ((NOISE_DATATYPE)257) / m_FrequencyY;
m_Perlin.Generate3D(NoiseData, DIM_X, DIM_Z, DIM_Y, StartX, EndX, StartZ, EndZ, StartY, EndY, Workspace);
-
+
// Add distance:
int idx = 0;
for (int y = 0; y < DIM_Y; y++)
@@ -125,7 +125,7 @@ void cEndGen::GenerateNoiseArray(void)
} // for x
} // for z
} // for y
-
+
// Upscale into real chunk size:
LinearUpscale3DArray(NoiseData, DIM_X, DIM_Z, DIM_Y, m_NoiseArray, INTERPOL_X, INTERPOL_Z, INTERPOL_Y);
}
@@ -133,14 +133,14 @@ void cEndGen::GenerateNoiseArray(void)
-
+
/// Returns true if the chunk is outside of the island's dimensions
bool cEndGen::IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ)
{
return (
(a_ChunkX < m_MinChunkX) || (a_ChunkX > m_MaxChunkX) ||
(a_ChunkZ < m_MinChunkZ) || (a_ChunkZ > m_MaxChunkZ)
- );
+ );
}
@@ -151,15 +151,15 @@ void cEndGen::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_
{
if (IsChunkOutsideRange(a_ChunkX, a_ChunkZ))
{
- for (int i = 0; i < ARRAYCOUNT(a_HeightMap); i++)
+ for (unsigned int i = 0; i < ARRAYCOUNT(a_HeightMap); i++)
{
a_HeightMap[i] = 0;
}
return;
}
-
+
PrepareState(a_ChunkX, a_ChunkZ);
-
+
int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);
for (int z = 0; z < cChunkDef::Width; z++)
{
@@ -189,9 +189,9 @@ void cEndGen::ComposeTerrain(cChunkDesc & a_ChunkDesc)
a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
return;
}
-
+
PrepareState(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
-
+
int MaxY = std::min((int)(1.75 * m_IslandSizeY + 1), cChunkDef::Height - 1);
for (int z = 0; z < cChunkDef::Width; z++)
{
diff --git a/source/Generating/MineShafts.cpp b/source/Generating/MineShafts.cpp
index 3131b5429..f42240e55 100644
--- a/source/Generating/MineShafts.cpp
+++ b/source/Generating/MineShafts.cpp
@@ -41,8 +41,8 @@ public:
mskCrossing,
mskStaircase,
} ;
-
-
+
+
enum eDirection
{
dirXP,
@@ -50,8 +50,8 @@ public:
dirXM,
dirZM,
} ;
-
-
+
+
cStructGenMineShafts::cMineShaftSystem & m_ParentSystem;
eKind m_Kind;
cCuboid m_BoundingBox;
@@ -62,25 +62,25 @@ public:
m_Kind(a_Kind)
{
}
-
+
cMineShaft(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, eKind a_Kind, const cCuboid & a_BoundingBox) :
m_ParentSystem(a_ParentSystem),
m_Kind(a_Kind),
m_BoundingBox(a_BoundingBox)
{
}
-
+
/// Returns true if this mineshaft intersects the specified cuboid
bool DoesIntersect(const cCuboid & a_Other)
{
return m_BoundingBox.DoesIntersect(a_Other);
}
-
+
/** If recursion level is not too large, appends more branches to the parent system,
using exit points specific to this class.
*/
virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) = 0;
-
+
/// Imprints this shape into the specified chunk's data
virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) = 0;
} ;
@@ -95,10 +95,10 @@ class cMineShaftDirtRoom :
public cMineShaft
{
typedef cMineShaft super;
-
+
public:
cMineShaftDirtRoom(cStructGenMineShafts::cMineShaftSystem & a_Parent, cNoise & a_Noise);
-
+
// cMineShaft overrides:
virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
@@ -112,7 +112,7 @@ class cMineShaftCorridor :
public cMineShaft
{
typedef cMineShaft super;
-
+
public:
/** Creates a new Corridor attached to the specified pivot point and direction.
Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
@@ -123,36 +123,36 @@ public:
int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
cNoise & a_Noise
);
-
+
protected:
static const int MAX_SEGMENTS = 5;
-
+
int m_NumSegments;
eDirection m_Direction;
bool m_HasFullBeam[MAX_SEGMENTS]; ///< If true, segment at that index has a full beam support (planks in the top center block)
int m_ChestPosition; ///< If <0, no chest; otherwise an offset from m_BoundingBox's p1.x or p1.z, depenging on m_Direction
int m_SpawnerPosition; ///< If <0, no spawner; otherwise an offset from m_BoundingBox's p1.x or p1.z, depenging on m_Direction
bool m_HasTracks; ///< If true, random tracks will be placed on the floor
-
+
cMineShaftCorridor(
cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
const cCuboid & a_BoundingBox, int a_NumSegments, eDirection a_Direction,
cNoise & a_Noise
);
-
+
// cMineShaft overrides:
virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
/// Places a chest, if the corridor has one
void PlaceChest(cChunkDesc & a_ChunkDesc);
-
+
/// If this corridor has tracks, places them randomly
void PlaceTracks(cChunkDesc & a_ChunkDesc);
-
+
/// If this corridor has a spawner, places the spawner
void PlaceSpawner(cChunkDesc & a_ChunkDesc);
-
+
/// Randomly places torches around the central beam block
void PlaceTorches(cChunkDesc & a_ChunkDesc);
} ;
@@ -165,7 +165,7 @@ class cMineShaftCrossing :
public cMineShaft
{
typedef cMineShaft super;
-
+
public:
/** Creates a new Crossing attached to the specified pivot point and direction.
Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
@@ -176,10 +176,10 @@ public:
int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
cNoise & a_Noise
);
-
+
protected:
cMineShaftCrossing(cStructGenMineShafts::cMineShaftSystem & a_ParentSystem, const cCuboid & a_BoundingBox);
-
+
// cMineShaft overrides:
virtual void AppendBranches(int a_RecursionLevel, cNoise & a_Noise) override;
virtual void ProcessChunk(cChunkDesc & a_ChunkDesc) override;
@@ -193,14 +193,14 @@ class cMineShaftStaircase :
public cMineShaft
{
typedef cMineShaft super;
-
+
public:
enum eSlope
{
sUp,
sDown,
} ;
-
+
/** Creates a new Staircase attached to the specified pivot point and direction.
Checks all ParentSystem's objects and disallows intersecting. Initializes the new object to fit.
May return NULL if cannot fit.
@@ -210,12 +210,12 @@ public:
int a_PivotX, int a_PivotY, int a_PivotZ, eDirection a_Direction,
cNoise & a_Noise
);
-
+
protected:
eDirection m_Direction;
eSlope m_Slope;
-
-
+
+
cMineShaftStaircase(
cStructGenMineShafts::cMineShaftSystem & a_ParentSystem,
const cCuboid & a_BoundingBox,
@@ -257,7 +257,7 @@ public:
/// Carves the system into the chunk data
void ProcessChunk(cChunkDesc & a_Chunk);
-
+
/** Creates new cMineShaft descendant connected at the specified point, heading the specified direction,
if it fits, appends it to the list and calls its AppendBranches()
*/
@@ -266,7 +266,7 @@ public:
cMineShaft::eDirection a_Direction, cNoise & a_Noise,
int a_RecursionLevel
);
-
+
/// Returns true if none of the objects in m_MineShafts intersect with the specified bounding box and the bounding box is valid
bool CanAppend(const cCuboid & a_BoundingBox);
} ;
@@ -294,7 +294,7 @@ cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem(
m_ChanceTorch(1000) // TODO: settable
{
m_MineShafts.reserve(100);
-
+
cMineShaft * Start = new cMineShaftDirtRoom(*this, a_Noise);
m_MineShafts.push_back(Start);
@@ -302,9 +302,9 @@ cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem(
Start->m_BoundingBox.p1.x - a_MaxSystemSize / 2, 2, Start->m_BoundingBox.p1.z - a_MaxSystemSize / 2,
Start->m_BoundingBox.p2.x + a_MaxSystemSize / 2, 50, Start->m_BoundingBox.p2.z + a_MaxSystemSize / 2
);
-
+
Start->AppendBranches(0, a_Noise);
-
+
for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
{
ASSERT((*itr)->m_BoundingBox.IsSorted());
@@ -341,7 +341,7 @@ void cStructGenMineShafts::cMineShaftSystem::ProcessChunk(cChunkDesc & a_Chunk)
void cStructGenMineShafts::cMineShaftSystem::AppendBranch(
- int a_PivotX, int a_PivotY, int a_PivotZ,
+ int a_PivotX, int a_PivotY, int a_PivotZ,
cMineShaft::eDirection a_Direction, cNoise & a_Noise,
int a_RecursionLevel
)
@@ -350,7 +350,7 @@ void cStructGenMineShafts::cMineShaftSystem::AppendBranch(
{
return;
}
-
+
cMineShaft * Next = NULL;
int rnd = (a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_RecursionLevel * 16, a_PivotZ) / 13) % m_ProbLevelStaircase;
if (rnd < m_ProbLevelCorridor)
@@ -384,7 +384,7 @@ bool cStructGenMineShafts::cMineShaftSystem::CanAppend(const cCuboid & a_Boundin
// Too far away, or too low / too high
return false;
}
-
+
// Check intersections:
for (cMineShafts::const_iterator itr = m_MineShafts.begin(), end = m_MineShafts.end(); itr != end; ++itr)
{
@@ -436,7 +436,7 @@ void cMineShaftDirtRoom::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
rnd >>= 4;
m_ParentSystem.AppendBranch(x, m_BoundingBox.p1.y + (rnd % Height), m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel);
}
-
+
for (int z = m_BoundingBox.p1.z + 1; z < m_BoundingBox.p2.z; z += 4)
{
int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, a_RecursionLevel, z) / 13;
@@ -464,13 +464,13 @@ void cMineShaftDirtRoom::ProcessChunk(cChunkDesc & a_ChunkDesc)
// Early bailout - cannot intersect this chunk
return;
}
-
+
// Chunk-relative coords of the boundaries:
int MinX = std::max(BlockX, m_BoundingBox.p1.x) - BlockX;
int MaxX = std::min(BlockX + cChunkDef::Width, m_BoundingBox.p2.x + 1) - BlockX;
int MinZ = std::max(BlockZ, m_BoundingBox.p1.z) - BlockZ;
int MaxZ = std::min(BlockZ + cChunkDef::Width, m_BoundingBox.p2.z + 1) - BlockZ;
-
+
// Carve the room out:
for (int z = MinZ; z < MaxZ; z++)
{
@@ -513,7 +513,7 @@ cMineShaftCorridor::cMineShaftCorridor(
rnd >>= 2;
}
m_HasTracks = ((rnd % 4) < 2); // 50 % chance of tracks
-
+
rnd = a_Noise.IntNoise3DInt(a_BoundingBox.p1.z, a_BoundingBox.p1.x, a_BoundingBox.p1.y) / 7;
int ChestCheck = rnd % 250;
rnd >>= 8;
@@ -597,7 +597,7 @@ void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
}
break;
}
-
+
case dirZM:
{
m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel);
@@ -646,14 +646,14 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc)
Top.p2.y += 1;
Top.p1.y = Top.p2.y;
a_ChunkDesc.FillRelCuboid(RelBoundingBox, E_BLOCK_AIR, 0);
- a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_AIR, 0, BlockX ^ BlockZ + BlockX, 8000);
+ a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_AIR, 0, (BlockX ^ (BlockZ + BlockX)), 8000);
if (m_SpawnerPosition >= 0)
{
// Cobwebs around the spider spawner
- a_ChunkDesc.RandomFillRelCuboid(RelBoundingBox, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockZ, 8000);
- a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX, 5000);
+ a_ChunkDesc.RandomFillRelCuboid(RelBoundingBox, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockZ)), 8000);
+ a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockX)), 5000);
}
- a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, BlockX ^ BlockZ + BlockX + 10, 500);
+ a_ChunkDesc.RandomFillRelCuboid(Top, E_BLOCK_COBWEB, 0, (BlockX ^ (BlockZ + BlockX + 10)), 500);
RelBoundingBox.p1.y = m_BoundingBox.p1.y;
RelBoundingBox.p2.y = m_BoundingBox.p1.y;
a_ChunkDesc.FloorRelCuboid(RelBoundingBox, E_BLOCK_PLANKS, 0);
@@ -693,7 +693,7 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc)
} // for i - NumSegments
break;
}
-
+
case dirZM:
case dirZP:
{
@@ -729,7 +729,7 @@ void cMineShaftCorridor::ProcessChunk(cChunkDesc & a_ChunkDesc)
break;
} // case dirZ?
} // for i
-
+
PlaceChest(a_ChunkDesc);
PlaceTracks(a_ChunkDesc);
PlaceSpawner(a_ChunkDesc); // (must be after Tracks!)
@@ -762,7 +762,7 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
{
return;
}
-
+
int BlockX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
int BlockZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
int x, z;
@@ -777,9 +777,10 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
Meta = E_META_CHEST_FACING_ZP;
break;
}
-
+
case dirZM:
case dirZP:
+ default:
{
x = m_BoundingBox.p1.x - BlockX;
z = m_BoundingBox.p1.z + m_ChestPosition - BlockZ;
@@ -794,12 +795,12 @@ void cMineShaftCorridor::PlaceChest(cChunkDesc & a_ChunkDesc)
)
{
a_ChunkDesc.SetBlockTypeMeta(x, m_BoundingBox.p1.y + 1, z, E_BLOCK_CHEST, Meta);
- cChestEntity * ChestEntity = new cChestEntity(BlockX + x, m_BoundingBox.p1.y + 1, BlockZ + z);
+ cChestEntity * ChestEntity = (cChestEntity *)a_ChunkDesc.GetBlockEntity(x, m_BoundingBox.p1.y + 1, z);
+ ASSERT((ChestEntity != NULL) && (ChestEntity->GetBlockType() == E_BLOCK_CHEST));
cNoise Noise(a_ChunkDesc.GetChunkX() ^ a_ChunkDesc.GetChunkZ());
int NumSlots = 3 + ((Noise.IntNoise3DInt(x, m_BoundingBox.p1.y, z) / 11) % 4);
int Seed = Noise.IntNoise2DInt(x, z);
ChestEntity->GetContents().GenerateRandomLootWithBooks(LootProbab, ARRAYCOUNT(LootProbab), NumSlots, Seed);
- a_ChunkDesc.AddBlockEntity(ChestEntity);
}
}
@@ -829,7 +830,7 @@ void cMineShaftCorridor::PlaceTracks(cChunkDesc & a_ChunkDesc)
Meta = E_META_TRACKS_X;
break;
}
-
+
case dirZM:
case dirZP:
{
@@ -921,7 +922,7 @@ void cMineShaftCorridor::PlaceTorches(cChunkDesc & a_ChunkDesc)
} // for i
break;
}
-
+
case dirZM:
case dirZP:
{
@@ -1034,14 +1035,14 @@ void cMineShaftCrossing::AppendBranches(int a_RecursionLevel, cNoise & a_Noise)
{ 5, 5, 2, dirXP},
{ 2, 5, 5, dirZP},
} ;
- for (int i = 0; i < ARRAYCOUNT(Exits); i++)
+ for (unsigned int i = 0; i < ARRAYCOUNT(Exits); i++)
{
if (m_BoundingBox.p1.y + Exits[i].y >= m_BoundingBox.p2.y)
{
// This exit is not available (two-level exit on a one-level crossing)
continue;
}
-
+
int Height = m_BoundingBox.p1.y + Exits[i].y;
m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + Exits[i].x, Height, m_BoundingBox.p1.z + Exits[i].z, Exits[i].dir, a_Noise, a_RecursionLevel);
} // for i
@@ -1089,7 +1090,7 @@ void cMineShaftCrossing::ProcessChunk(cChunkDesc & a_ChunkDesc)
a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Mid, Ceil, box.p1.z, box.p1.z, E_BLOCK_AIR, 0);
a_ChunkDesc.FillRelCuboid(box.p1.x + 1, box.p2.x - 1, Mid, Ceil, box.p2.z, box.p2.z, E_BLOCK_AIR, 0);
}
-
+
// The floor, if needed:
box.p2.y = box.p1.y;
a_ChunkDesc.FloorRelCuboid(box, E_BLOCK_PLANKS, 0);
@@ -1198,7 +1199,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc)
// No intersection between this staircase and this chunk
return;
}
-
+
int SFloor = RelB.p1.y + ((m_Slope == sDown) ? 5 : 1);
int DFloor = RelB.p1.y + ((m_Slope == sDown) ? 1 : 5);
int Add = (m_Slope == sDown) ? -1 : 1;
@@ -1221,7 +1222,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc)
}
break;
}
-
+
case dirXP:
{
a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p1.x + 1, SFloor, SFloor + 2, RelB.p1.z, RelB.p2.z, E_BLOCK_AIR, 0);
@@ -1253,7 +1254,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc)
}
break;
}
-
+
case dirZP:
{
a_ChunkDesc.FillRelCuboid (RelB.p1.x, RelB.p2.x, SFloor, SFloor + 2, RelB.p1.z, RelB.p1.z + 1, E_BLOCK_AIR, 0);
@@ -1269,7 +1270,7 @@ void cMineShaftStaircase::ProcessChunk(cChunkDesc & a_ChunkDesc)
}
break;
}
-
+
} // switch (m_Direction)
}
@@ -1359,7 +1360,7 @@ void cStructGenMineShafts::GetMineShaftSystemsForChunk(
++itr;
}
} // for itr - m_Cache[]
-
+
for (int x = 0; x < NEIGHBORHOOD_SIZE; x++)
{
int RealX = (BaseX + x) * m_GridSize;
@@ -1381,11 +1382,11 @@ void cStructGenMineShafts::GetMineShaftSystemsForChunk(
}
} // for z
} // for x
-
+
// Copy a_MineShafts into m_Cache to the beginning:
cMineShaftSystems MineShaftsCopy(a_MineShafts);
m_Cache.splice(m_Cache.begin(), MineShaftsCopy, MineShaftsCopy.begin(), MineShaftsCopy.end());
-
+
// Trim the cache if it's too long:
if (m_Cache.size() > 100)
{
diff --git a/source/Generating/Noise3DGenerator.cpp b/source/Generating/Noise3DGenerator.cpp
index f47c64430..03626a800 100644
--- a/source/Generating/Noise3DGenerator.cpp
+++ b/source/Generating/Noise3DGenerator.cpp
@@ -25,8 +25,8 @@ public:
DoTest1();
DoTest2();
}
-
-
+
+
void DoTest1(void)
{
float In[3 * 3 * 3];
@@ -39,8 +39,8 @@ public:
LinearUpscale3DArray(In, 3, 3, 3, Out, 8, 16, 17);
Debug3DNoise(Out, 17, 33, 35, "Upscale3D test");
}
-
-
+
+
void DoTest2(void)
{
float In[3 * 3];
@@ -53,7 +53,7 @@ public:
LinearUpscale2DArray(In, 3, 3, Out, 8, 16);
Debug2DNoise(Out, 17, 33, "Upscale2D test");
}
-
+
} gTest;
//*/
@@ -72,7 +72,7 @@ cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) :
m_Perlin.AddOctave(1, (NOISE_DATATYPE)0.5);
m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 1);
m_Perlin.AddOctave((NOISE_DATATYPE)0.5, 2);
-
+
#if 0
// DEBUG: Test the noise generation:
// NOTE: In order to be able to run MCS with this code, you need to increase the default thread stack size
@@ -84,7 +84,7 @@ cNoise3DGenerator::cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator) :
m_FrequencyY = 4;
m_FrequencyZ = 4;
m_AirThreshold = 0.5;
-
+
const int NumChunks = 4;
NOISE_DATATYPE Noise[NumChunks][cChunkDef::Width * cChunkDef::Width * cChunkDef::Height];
for (int x = 0; x < NumChunks; x++)
@@ -153,7 +153,7 @@ cNoise3DGenerator::~cNoise3DGenerator()
void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile)
{
m_World = a_World;
-
+
// Params:
m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62);
m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0);
@@ -170,7 +170,7 @@ void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile)
void cNoise3DGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
{
- for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
+ for (unsigned int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
{
a_BiomeMap[i] = biExtremeHills;
}
@@ -184,7 +184,7 @@ void cNoise3DGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_Ch
{
NOISE_DATATYPE Noise[17 * 257 * 17];
GenerateNoiseArray(a_ChunkX, a_ChunkZ, Noise);
-
+
// Output noise into chunk:
for (int z = 0; z < cChunkDef::Width; z++)
{
@@ -207,7 +207,7 @@ void cNoise3DGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_Ch
}
}
}
-
+
UpdateHeightmap(a_ChunkDesc);
ComposeTerrain (a_ChunkDesc);
}
@@ -228,19 +228,19 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT
NOISE_DATATYPE EndZ = ((NOISE_DATATYPE)((a_ChunkZ + 1) * cChunkDef::Width) - 1) / m_FrequencyZ;
NOISE_DATATYPE StartY = 0;
NOISE_DATATYPE EndY = ((NOISE_DATATYPE)256) / m_FrequencyY;
-
+
m_Perlin.Generate3D(NoiseO, DIM_X, DIM_Y, DIM_Z, StartX, EndX, StartY, EndY, StartZ, EndZ, NoiseW);
-
+
// DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_orig", a_ChunkX, a_ChunkZ));
-
+
// Precalculate a "height" array:
NOISE_DATATYPE Height[DIM_X * DIM_Z]; // Output for the cubic noise heightmap ("source")
m_Cubic.Generate2D(Height, DIM_X, DIM_Z, StartX / 25, EndX / 25, StartZ / 25, EndZ / 25);
- for (int i = 0; i < ARRAYCOUNT(Height); i++)
+ for (unsigned int i = 0; i < ARRAYCOUNT(Height); i++)
{
Height[i] = abs(Height[i]) * m_HeightAmplification + 1;
}
-
+
// Modify the noise by height data:
for (int y = 0; y < DIM_Y; y++)
{
@@ -257,13 +257,13 @@ void cNoise3DGenerator::GenerateNoiseArray(int a_ChunkX, int a_ChunkZ, NOISE_DAT
}
// DEBUG: Debug3DNoise(NoiseO, DIM_X, DIM_Y, DIM_Z, Printf("Chunk_%d_%d_hei", a_ChunkX, a_ChunkZ));
-
+
// Upscale the Perlin noise into full-blown chunk dimensions:
LinearUpscale3DArray(
NoiseO, DIM_X, DIM_Y, DIM_Z,
a_OutNoise, UPSCALE_X, UPSCALE_Y, UPSCALE_Z
);
-
+
// DEBUG: Debug3DNoise(a_OutNoise, 17, 257, 17, Printf("Chunk_%d_%d_lerp", a_ChunkX, a_ChunkZ));
}
@@ -383,15 +383,11 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
}
m_LastChunkX = a_ChunkX;
m_LastChunkZ = a_ChunkZ;
-
+
// Upscaling parameters:
const int UPSCALE_X = 8;
const int UPSCALE_Y = 4;
const int UPSCALE_Z = 8;
-
- const int DIM_X = 1 + cChunkDef::Width / UPSCALE_X;
- const int DIM_Y = 1 + cChunkDef::Height / UPSCALE_Y;
- const int DIM_Z = 1 + cChunkDef::Width / UPSCALE_Z;
// Precalculate a "height" array:
NOISE_DATATYPE Height[17 * 17]; // x + 17 * z
@@ -405,8 +401,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
Height[x + 17 * z] = val * val * val;
}
}
-
- int idx = 0;
+
for (int y = 0; y < 257; y += UPSCALE_Y)
{
NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)y) / m_FrequencyY;
@@ -419,7 +414,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
for (int x = 0; x < 17; x += UPSCALE_X)
{
NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + x)) / m_FrequencyX;
- CurFloor[x + 17 * z] =
+ CurFloor[x + 17 * z] =
m_Noise1.CubicNoise3D(NoiseX, NoiseY, NoiseZ) * (NOISE_DATATYPE)0.5 +
m_Noise2.CubicNoise3D(NoiseX / 2, NoiseY / 2, NoiseZ / 2) +
m_Noise3.CubicNoise3D(NoiseX / 4, NoiseY / 4, NoiseZ / 4) * 2 +
@@ -429,7 +424,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
// Linear-interpolate this XZ floor:
LinearUpscale2DArrayInPlace(CurFloor, 17, 17, UPSCALE_X, UPSCALE_Z);
}
-
+
// Finish the 3D linear interpolation by interpolating between each XZ-floors on the Y axis
for (int y = 1; y < cChunkDef::Height; y++)
{
@@ -455,7 +450,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
idx += 1; // Skipping one X column
}
}
-
+
// The noise array is now fully interpolated
/*
// DEBUG: Output two images of the array, sliced by XY and XZ:
@@ -504,7 +499,7 @@ void cNoise3DComposable::GenerateNoiseArrayIfNeeded(int a_ChunkX, int a_ChunkZ)
void cNoise3DComposable::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
{
GenerateNoiseArrayIfNeeded(a_ChunkX, a_ChunkZ);
-
+
for (int z = 0; z < cChunkDef::Width; z++)
{
for (int x = 0; x < cChunkDef::Width; x++)
@@ -529,9 +524,9 @@ void cNoise3DComposable::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::Hei
void cNoise3DComposable::ComposeTerrain(cChunkDesc & a_ChunkDesc)
{
GenerateNoiseArrayIfNeeded(a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ());
-
+
a_ChunkDesc.FillBlocks(E_BLOCK_AIR, 0);
-
+
// Make basic terrain composition:
for (int z = 0; z < cChunkDef::Width; z++)
{
diff --git a/source/LineBlockTracer.cpp b/source/LineBlockTracer.cpp
index 7cc14089d..9fcbca915 100644
--- a/source/LineBlockTracer.cpp
+++ b/source/LineBlockTracer.cpp
@@ -179,9 +179,9 @@ bool cLineBlockTracer::MoveToNextBlock(void)
// Based on the wall hit, adjust the current coords
switch (Direction)
{
- case dirX: m_CurrentX += m_DirX; m_CurrentFace = (m_DirX > 0) ? BLOCK_FACE_EAST : BLOCK_FACE_WEST; break;
- case dirY: m_CurrentY += m_DirY; m_CurrentFace = (m_DirY > 0) ? BLOCK_FACE_BOTTOM : BLOCK_FACE_TOP; break;
- case dirZ: m_CurrentZ += m_DirZ; m_CurrentFace = (m_DirZ > 0) ? BLOCK_FACE_SOUTH : BLOCK_FACE_NORTH; break;
+ case dirX: m_CurrentX += m_DirX; m_CurrentFace = (m_DirX > 0) ? BLOCK_FACE_XM : BLOCK_FACE_XP; break;
+ case dirY: m_CurrentY += m_DirY; m_CurrentFace = (m_DirY > 0) ? BLOCK_FACE_YM : BLOCK_FACE_YP; break;
+ case dirZ: m_CurrentZ += m_DirZ; m_CurrentFace = (m_DirZ > 0) ? BLOCK_FACE_ZM : BLOCK_FACE_ZP; break;
case dirNONE: return false;
}
return true;
diff --git a/source/LinearUpscale.h b/source/LinearUpscale.h
index b7ac84c6a..b337b3219 100644
--- a/source/LinearUpscale.h
+++ b/source/LinearUpscale.h
@@ -31,7 +31,7 @@ Linearly interpolates values in the array between the equidistant anchor points
Works in-place (input is already present at the correct output coords)
*/
template<typename TYPE> void LinearUpscale2DArrayInPlace(
- TYPE * a_Array,
+ TYPE * a_Array,
int a_SizeX, int a_SizeY, // Dimensions of the array
int a_AnchorStepX, int a_AnchorStepY // Distances between the anchor points in each direction
)
@@ -53,7 +53,7 @@ template<typename TYPE> void LinearUpscale2DArrayInPlace(
Idx += a_AnchorStepX;
} // for x
} // for y
-
+
// Now interpolate in rows, each row has values in the anchor columns
int LastXCell = a_SizeX - a_AnchorStepX;
for (int y = 0; y < a_SizeY; y++)
@@ -92,7 +92,7 @@ template<typename TYPE> void LinearUpscale2DArray(
// Feel free to enlarge them if needed, but keep in mind that they're on the stack
const int MAX_UPSCALE_X = 128;
const int MAX_UPSCALE_Y = 128;
-
+
ASSERT(a_Src != NULL);
ASSERT(a_Dst != NULL);
ASSERT(a_SrcSizeX > 0);
@@ -101,7 +101,7 @@ template<typename TYPE> void LinearUpscale2DArray(
ASSERT(a_UpscaleY > 0);
ASSERT(a_UpscaleX <= MAX_UPSCALE_X);
ASSERT(a_UpscaleY <= MAX_UPSCALE_Y);
-
+
// Pre-calculate the upscaling ratios:
TYPE RatioX[MAX_UPSCALE_X];
TYPE RatioY[MAX_UPSCALE_Y];
@@ -113,7 +113,7 @@ template<typename TYPE> void LinearUpscale2DArray(
{
RatioY[y] = (TYPE)y / a_UpscaleY;
}
-
+
// Interpolate each XY cell:
int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
@@ -163,7 +163,7 @@ template<typename TYPE> void LinearUpscale3DArray(
const int MAX_UPSCALE_X = 128;
const int MAX_UPSCALE_Y = 128;
const int MAX_UPSCALE_Z = 128;
-
+
ASSERT(a_Src != NULL);
ASSERT(a_Dst != NULL);
ASSERT(a_SrcSizeX > 0);
@@ -175,11 +175,11 @@ template<typename TYPE> void LinearUpscale3DArray(
ASSERT(a_UpscaleX <= MAX_UPSCALE_X);
ASSERT(a_UpscaleY <= MAX_UPSCALE_Y);
ASSERT(a_UpscaleZ <= MAX_UPSCALE_Z);
-
+
// Pre-calculate the upscaling ratios:
TYPE RatioX[MAX_UPSCALE_X];
TYPE RatioY[MAX_UPSCALE_Y];
- TYPE RatioZ[MAX_UPSCALE_Y];
+ TYPE RatioZ[MAX_UPSCALE_Z];
for (int x = 0; x <= a_UpscaleX; x++)
{
RatioX[x] = (TYPE)x / a_UpscaleX;
@@ -192,7 +192,7 @@ template<typename TYPE> void LinearUpscale3DArray(
{
RatioZ[z] = (TYPE)z / a_UpscaleZ;
}
-
+
// Interpolate each XYZ cell:
int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
diff --git a/source/Log.cpp b/source/Log.cpp
index fc19595db..a0de4531b 100644
--- a/source/Log.cpp
+++ b/source/Log.cpp
@@ -124,7 +124,7 @@ void cLog::Log(const char * a_Format, va_list argList)
#endif
if (m_File)
{
- fprintf(m_File, "%s\n", Line.c_str(), m_File);
+ fprintf(m_File, "%s\n", Line.c_str());
fflush(m_File);
}
diff --git a/source/Mobs/Giant.cpp b/source/Mobs/Giant.cpp
index 66e5bbb01..bbcad46f0 100644
--- a/source/Mobs/Giant.cpp
+++ b/source/Mobs/Giant.cpp
@@ -8,7 +8,6 @@
cGiant::cGiant(void) :
- // 6.0 * (0.6|1.8)
super("Giant", mtGiant, "mob.zombie.hurt", "mob.zombie.death", 3.6, 10.8)
{
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp
index c1f695163..0a9f5b9d3 100644
--- a/source/PluginManager.cpp
+++ b/source/PluginManager.cpp
@@ -113,9 +113,13 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
FindPlugins();
cServer::BindBuiltInConsoleCommands();
-
- unsigned int KeyNum = a_SettingsIni.FindKey("Plugins");
+
+ // Check if the Plugins section exists.
+ int KeyNum = a_SettingsIni.FindKey("Plugins");
+
+ // If it does, how many plugins are there?
unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
+
if (KeyNum == -1)
{
InsertDefaultPlugins(a_SettingsIni);
@@ -202,7 +206,7 @@ void cPluginManager::Tick(float a_Dt)
bool cPluginManager::CallHookBlockToPickups(
cWorld * a_World, cEntity * a_Digger,
- int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
+ int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
cItems & a_Pickups
)
{
@@ -247,7 +251,7 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
{
return false;
}
-
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChat(a_Player, a_Message))
@@ -255,7 +259,7 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
return true;
}
}
-
+
return false;
}
@@ -1230,27 +1234,27 @@ bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt)
bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
{
ASSERT(a_Player != NULL);
-
+
AStringVector Split(StringSplit(a_Command, " "));
if (Split.empty())
{
return false;
}
-
+
CommandMap::iterator cmd = m_Commands.find(Split[0]);
if (cmd == m_Commands.end())
{
// Command not found
return false;
}
-
+
// Ask plugins first if a command is okay to execute the command:
if (CallHookExecuteCommand(a_Player, Split))
{
LOGINFO("Player \"%s\" tried executing command \"%s\" that was stopped by the HOOK_EXECUTE_COMMAND hook", a_Player->GetName().c_str(), Split[0].c_str());
return false;
}
-
+
if (
a_ShouldCheckPermissions &&
!cmd->second.m_Permission.empty() &&
@@ -1262,8 +1266,8 @@ bool cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command
}
ASSERT(cmd->second.m_Plugin != NULL);
-
- return cmd->second.m_Plugin->HandleCommand(Split, a_Player);
+
+ return cmd->second.m_Plugin->HandleCommand(Split, a_Player);
}
@@ -1320,7 +1324,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName)
{
return false;
}
-
+
if (itr->first.compare(a_PluginName) == 0) // _X 2013_02_01: wtf? Isn't this supposed to be what find() does?
{
m_DisablePluginList.push_back(itr->second);
@@ -1365,7 +1369,7 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin)
break;
}
}
-
+
RemovePluginCommands(a_Plugin);
RemovePluginConsoleCommands(a_Plugin);
RemoveHooks(a_Plugin);
@@ -1386,7 +1390,7 @@ void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin)
{
a_Plugin->ClearCommands();
}
-
+
for (CommandMap::iterator itr = m_Commands.begin(); itr != m_Commands.end();)
{
if (itr->second.m_Plugin == a_Plugin)
@@ -1414,7 +1418,7 @@ bool cPluginManager::BindCommand(const AString & a_Command, cPlugin * a_Plugin,
LOGWARNING("Command \"%s\" is already bound to plugin \"%s\".", a_Command.c_str(), cmd->second.m_Plugin->GetName().c_str());
return false;
}
-
+
m_Commands[a_Command].m_Plugin = a_Plugin;
m_Commands[a_Command].m_Permission = a_Permission;
m_Commands[a_Command].m_HelpString = a_HelpString;
@@ -1484,7 +1488,7 @@ void cPluginManager::RemovePluginConsoleCommands(cPlugin * a_Plugin)
{
a_Plugin->ClearConsoleCommands();
}
-
+
for (CommandMap::iterator itr = m_ConsoleCommands.begin(); itr != m_ConsoleCommands.end();)
{
if (itr->second.m_Plugin == a_Plugin)
@@ -1519,7 +1523,7 @@ bool cPluginManager::BindConsoleCommand(const AString & a_Command, cPlugin * a_P
}
return false;
}
-
+
m_ConsoleCommands[a_Command].m_Plugin = a_Plugin;
m_ConsoleCommands[a_Command].m_Permission = "";
m_ConsoleCommands[a_Command].m_HelpString = a_HelpString;
@@ -1561,20 +1565,20 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma
{
return false;
}
-
+
CommandMap::iterator cmd = m_ConsoleCommands.find(a_Split[0]);
if (cmd == m_ConsoleCommands.end())
{
// Command not found
return false;
}
-
+
if (cmd->second.m_Plugin == NULL)
{
// This is a built-in command
return false;
}
-
+
// Ask plugins first if a command is okay to execute the console command:
if (CallHookExecuteCommand(NULL, a_Split))
{
@@ -1582,7 +1586,7 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma
return false;
}
- return cmd->second.m_Plugin->HandleConsoleCommand(a_Split, a_Output);
+ return cmd->second.m_Plugin->HandleConsoleCommand(a_Split, a_Output);
}
@@ -1656,7 +1660,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook)
unsigned int cPluginManager::GetNumPlugins() const
{
- return m_Plugins.size();
+ return m_Plugins.size();
}
diff --git a/source/Protocol/Protocol.h b/source/Protocol/Protocol.h
index 5023ea227..542060ece 100644
--- a/source/Protocol/Protocol.h
+++ b/source/Protocol/Protocol.h
@@ -22,9 +22,9 @@ class cWindow;
class cInventory;
class cPawn;
class cPickup;
+class cWorld;
class cMonster;
class cChunkDataSerializer;
-class cWorld;
class cFallingBlock;
@@ -85,6 +85,7 @@ public:
virtual void SendPlayerPosition (void) = 0;
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
virtual void SendRespawn (void) = 0;
+ virtual void SendExperience (void) = 0;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0;
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index 9f2770815..54be65b12 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -72,6 +72,7 @@ enum
PACKET_ENT_STATUS = 0x26,
PACKET_ATTACH_ENTITY = 0x27,
PACKET_METADATA = 0x28,
+ PACKET_EXPERIENCE = 0x2b,
PACKET_PRE_CHUNK = 0x32,
PACKET_MAP_CHUNK = 0x33,
PACKET_MULTI_BLOCK = 0x34,
@@ -690,6 +691,20 @@ void cProtocol125::SendRespawn(void)
+void cProtocol125::SendExperience(void)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_EXPERIENCE);
+ WriteFloat (m_Client->GetPlayer()->GetXpPercentage());
+ WriteShort (m_Client->GetPlayer()->GetXpLevel());
+ WriteShort (m_Client->GetPlayer()->GetCurrentXp());
+ Flush();
+}
+
+
+
+
+
void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
{
// Not needed in this protocol version
diff --git a/source/Protocol/Protocol125.h b/source/Protocol/Protocol125.h
index db913bb57..c5f44c818 100644
--- a/source/Protocol/Protocol125.h
+++ b/source/Protocol/Protocol125.h
@@ -62,6 +62,7 @@ public:
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRespawn (void) override;
+ virtual void SendExperience (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
diff --git a/source/Protocol/Protocol17x.cpp b/source/Protocol/Protocol17x.cpp
index 628b8e071..ae1df7395 100644
--- a/source/Protocol/Protocol17x.cpp
+++ b/source/Protocol/Protocol17x.cpp
@@ -597,6 +597,18 @@ void cProtocol172::SendRespawn(void)
+void cProtocol172::SendExperience (void)
+{
+ cPacketizer Pkt(*this, 0x1F); //Experience Packet
+ Pkt.WriteFloat(m_Client->GetPlayer()->GetXpPercentage());
+ Pkt.WriteShort(m_Client->GetPlayer()->GetXpLevel());
+ Pkt.WriteShort(m_Client->GetPlayer()->GetCurrentXp());
+}
+
+
+
+
+
void cProtocol172::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) // a_Src coords are Block * 8
{
cPacketizer Pkt(*this, 0x29); // Sound Effect packet
diff --git a/source/Protocol/Protocol17x.h b/source/Protocol/Protocol17x.h
index 844069403..e3f2ad922 100644
--- a/source/Protocol/Protocol17x.h
+++ b/source/Protocol/Protocol17x.h
@@ -72,6 +72,7 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRespawn (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
+ virtual void SendExperience (void) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override;
diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp
index 9234785b5..64bd83075 100644
--- a/source/Protocol/ProtocolRecognizer.cpp
+++ b/source/Protocol/ProtocolRecognizer.cpp
@@ -466,6 +466,16 @@ void cProtocolRecognizer::SendRespawn(void)
+void cProtocolRecognizer::SendExperience(void)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendExperience();
+}
+
+
+
+
+
void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
{
ASSERT(m_Protocol != NULL);
diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h
index c085e2cd8..03f48fb35 100644
--- a/source/Protocol/ProtocolRecognizer.h
+++ b/source/Protocol/ProtocolRecognizer.h
@@ -97,6 +97,7 @@ public:
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRespawn (void) override;
+ virtual void SendExperience (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
diff --git a/source/Root.cpp b/source/Root.cpp
index 701832be7..be5a0553c 100644
--- a/source/Root.cpp
+++ b/source/Root.cpp
@@ -489,7 +489,7 @@ void cRoot::SaveAllChunks(void)
{
for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr)
{
- itr->second->SaveAllChunks();
+ itr->second->QueueSaveAllChunks();
}
}