1
0

Merge branch 'htmlescape'.

This commit is contained in:
madmaxoft 2013-10-20 09:14:30 +02:00
commit 0258213d24
4 changed files with 150 additions and 113 deletions

View File

@ -15,7 +15,7 @@ g_APIDesc =
ExampleClassName = ExampleClassName =
{ {
Desc = "Description, exported as the first paragraph of the class page. Usually enclosed within double brackets." Desc = "Description, exported as the first paragraph of the class page. Usually enclosed within double brackets."
Functions = Functions =
{ {
FunctionName = { Params = "Parameter list", Return = "Return values list", Notes = "Notes" ), FunctionName = { Params = "Parameter list", Return = "Return values list", Notes = "Notes" ),
@ -25,17 +25,17 @@ g_APIDesc =
{ Params = "Parameter list 2", Return = "Return values list 2", Notes = "Notes 2" }, { Params = "Parameter list 2", Return = "Return values list 2", Notes = "Notes 2" },
} }
} , } ,
Constants = Constants =
{ {
ConstantName = { Notes = "Notes about the constant" }, ConstantName = { Notes = "Notes about the constant" },
} , } ,
Variables = Variables =
{ {
VariableName = { Type = "string", Notes = "Notes about the variable" }, VariableName = { Type = "string", Notes = "Notes about the variable" },
} , } ,
AdditionalInfo = -- Paragraphs to be exported after the function definitions table AdditionalInfo = -- Paragraphs to be exported after the function definitions table
{ {
{ {
@ -47,17 +47,17 @@ g_APIDesc =
Contents = "Contents of the additional section 2", Contents = "Contents of the additional section 2",
} }
}, },
Inherits = "ParentClassName", -- Only present if the class inherits from another API class Inherits = "ParentClassName", -- Only present if the class inherits from another API class
}, },
]]-- ]]--
cArrowEntity = cArrowEntity =
{ {
Desc = [[ Desc = [[
Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}. Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}.
]], ]],
Functions = Functions =
{ {
CanPickup = { Params = "{{cPlayer|Player}}", Return = "bool", Notes = "Returns true if the specified player can pick the arrow when it's on the ground" }, CanPickup = { Params = "{{cPlayer|Player}}", Return = "bool", Notes = "Returns true if the specified player can pick the arrow when it's on the ground" },
@ -68,17 +68,17 @@ g_APIDesc =
SetIsCritical = { Params = "bool", Return = "", Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage" }, SetIsCritical = { Params = "bool", Return = "", Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage" },
SetPickupState = { Params = "PickupState", Return = "", Notes = "Sets the pickup state (one of the psXXX constants, above)" }, SetPickupState = { Params = "PickupState", Return = "", Notes = "Sets the pickup state (one of the psXXX constants, above)" },
}, },
Constants = Constants =
{ {
psInCreative = { Notes = "The arrow can be picked up only by players in creative gamemode" }, psInCreative = { Notes = "The arrow can be picked up only by players in creative gamemode" },
psInSurvivalOrCreative = { Notes = "The arrow can be picked up by players in survival or creative gamemode" }, psInSurvivalOrCreative = { Notes = "The arrow can be picked up by players in survival or creative gamemode" },
psNoPickup = { Notes = "The arrow cannot be picked up at all" }, psNoPickup = { Notes = "The arrow cannot be picked up at all" },
}, },
Inherits = "cProjectileEntity", Inherits = "cProjectileEntity",
}, },
cBlockArea = cBlockArea =
{ {
Desc = [[ Desc = [[
@ -182,7 +182,7 @@ g_APIDesc =
msImprint = { Notes = "Src overwrites Dst anywhere where Dst has non-air blocks" }, msImprint = { Notes = "Src overwrites Dst anywhere where Dst has non-air blocks" },
msLake = { Notes = "Special mode for merging lake images" }, msLake = { Notes = "Special mode for merging lake images" },
}, },
AdditionalInfo = AdditionalInfo =
{ {
{ {
@ -268,7 +268,7 @@ g_APIDesc =
or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in. or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in.
The cBlockEntity class acts as a common ancestor for all the individual block entities. The cBlockEntity class acts as a common ancestor for all the individual block entities.
]], ]],
Functions = Functions =
{ {
GetBlockType = { Params = "", Return = "BLOCKTYPE", Notes = "Returns the blocktype which is represented by this blockentity. This is the primary means of type-identification" }, GetBlockType = { Params = "", Return = "BLOCKTYPE", Notes = "Returns the blocktype which is represented by this blockentity. This is the primary means of type-identification" },
@ -295,9 +295,9 @@ g_APIDesc =
number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage
is monitored for changes and the changes are immediately sent to clients of the UI window. is monitored for changes and the changes are immediately sent to clients of the UI window.
]], ]],
Inherits = "cBlockEntity", Inherits = "cBlockEntity",
Functions = Functions =
{ {
GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" }, GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" },
@ -306,7 +306,7 @@ g_APIDesc =
{ Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" }, { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" },
{ Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" }, { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" },
}, },
SetSlot = SetSlot =
{ {
{ Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" }, { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" },
{ Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" }, { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" },
@ -316,8 +316,8 @@ g_APIDesc =
{ {
}, },
}, },
cBoundingBox = cBoundingBox =
{ {
Desc = [[ Desc = [[
Represents two sets of coordinates, minimum and maximum for each direction; thus defining an Represents two sets of coordinates, minimum and maximum for each direction; thus defining an
@ -362,7 +362,7 @@ g_APIDesc =
Desc = [[ Desc = [[
A wrapper class for constants representing colors or effects. A wrapper class for constants representing colors or effects.
]], ]],
Functions = Functions =
{ {
MakeColor = { Params = "ColorCodeConstant", Return = "string", Notes = "Creates the complete color-code-sequence from the color or effect constant" }, MakeColor = { Params = "ColorCodeConstant", Return = "string", Notes = "Creates the complete color-code-sequence from the color or effect constant" },
@ -390,9 +390,9 @@ g_APIDesc =
To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with 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 either DoWithChestAt() or ForEachChestInChunk() function. See the code example below
]], ]],
Inherits = "cBlockEntityWithItems", Inherits = "cBlockEntityWithItems",
Functions = 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}}." }, 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}}." },
@ -431,7 +431,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
{{OnChunkGenerated|OnChunkGenerated}} hooks and cannot be constructed on its own. Plugins can use this {{OnChunkGenerated|OnChunkGenerated}} hooks and cannot be constructed on its own. Plugins can use this
class in both those hooks to manipulate generated chunks. class in both those hooks to manipulate generated chunks.
]], ]],
Functions = Functions =
{ {
FillBlocks = { Params = "BlockType, BlockMeta", Return = "", Notes = "Fills the entire chunk with the specified blocks" }, FillBlocks = { Params = "BlockType, BlockMeta", Return = "", Notes = "Fills the entire chunk with the specified blocks" },
@ -493,7 +493,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
connection. Internally, it handles all the incoming and outgoing packets, the chunks that are to be connection. Internally, it handles all the incoming and outgoing packets, the chunks that are to be
sent to the client, ping times etc. sent to the client, ping times etc.
]], ]],
Functions = Functions =
{ {
GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" }, GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" },
@ -525,7 +525,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
specifying the exact number of ingredients to consume in that recipe; plugins may use this to specifying the exact number of ingredients to consume in that recipe; plugins may use this to
apply the crafting recipe.</p> apply the crafting recipe.</p>
]], ]],
Functions = Functions =
{ {
constructor = { Params = "Width, Height", Return = "cCraftingGrid", Notes = "Creates a new CraftingGrid object. This new crafting grid is not related to any player, but may be needed for {{cCraftingRecipe}}'s ConsumeIngredients function." }, constructor = { Params = "Width, Height", Return = "cCraftingGrid", Notes = "Creates a new CraftingGrid object. This new crafting grid is not related to any player, but may be needed for {{cCraftingRecipe}}'s ConsumeIngredients function." },
@ -535,7 +535,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
GetHeight = { Params = "", Return = "number", Notes = "Returns the height of the grid" }, GetHeight = { Params = "", Return = "number", Notes = "Returns the height of the grid" },
GetItem = { Params = "x, y", Return = "{{cItem|cItem}}", Notes = "Returns the item at the specified coords" }, GetItem = { Params = "x, y", Return = "{{cItem|cItem}}", Notes = "Returns the item at the specified coords" },
GetWidth = { Params = "", Return = "number", Notes = "Returns the width of the grid" }, GetWidth = { Params = "", Return = "number", Notes = "Returns the width of the grid" },
SetItem = SetItem =
{ {
{ Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified coords" }, { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified coords" },
{ Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified coords" }, { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified coords" },
@ -562,7 +562,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
GetIngredientsHeight = { Params = "", Return = "number", Notes = "Returns the height of the ingredients' grid" }, GetIngredientsHeight = { Params = "", Return = "number", Notes = "Returns the height of the ingredients' grid" },
GetIngredientsWidth = { Params = "", Return = "number", Notes = "Returns the width of the ingredients' grid" }, GetIngredientsWidth = { Params = "", Return = "number", Notes = "Returns the width of the ingredients' grid" },
GetResult = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the result of the recipe" }, GetResult = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the result of the recipe" },
SetIngredient = SetIngredient =
{ {
{ Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" }, { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" },
{ Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" }, { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" },
@ -624,7 +624,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
{ {
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. 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>
<p>An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). <p>An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks).
]], ]],
Functions = Functions =
{ {
@ -640,7 +640,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
{ {
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. 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>
<p>An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). <p>An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks).
]], ]],
Functions = Functions =
{ {
@ -667,13 +667,13 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" }, ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" },
ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" }, ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" },
}, },
Inherits = "cBlockEntity"; Inherits = "cBlockEntity";
}, },
cEnchantments = cEnchantments =
{ {
Desc = [[This class is the storage for enchantments for a single {{cItem|cItem}} object, through its m_Enchantments member variable. Although it is possible to create a standalone object of this class, it is not yet used in any API directly. Desc = [[This class is the storage for enchantments for a single {{cItem|cItem}} object, through its m_Enchantments member variable. Although it is possible to create a standalone object of this class, it is not yet used in any API directly.
</p> </p>
<p>Enchantments can be initialized either programmatically by calling the individual functions (SetLevel()), or by using a string description of the enchantment combination. This string description is in the form "id=lvl;id=lvl;...;id=lvl;", where id is either a numerical ID of the enchantment, or its textual representation from the table below, and lvl is the desired enchantment level. The class can also create its string description from its current contents; however that string description will only have the numerical IDs. <p>Enchantments can be initialized either programmatically by calling the individual functions (SetLevel()), or by using a string description of the enchantment combination. This string description is in the form "id=lvl;id=lvl;...;id=lvl;", where id is either a numerical ID of the enchantment, or its textual representation from the table below, and lvl is the desired enchantment level. The class can also create its string description from its current contents; however that string description will only have the numerical IDs.
]], ]],
@ -855,7 +855,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
cFile:Delete("/usr/bin/virus.exe"); cFile:Delete("/usr/bin/virus.exe");
</pre></p> </pre></p>
]], ]],
Functions = 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." }, 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." },
@ -870,14 +870,14 @@ cFile:Delete("/usr/bin/virus.exe");
}, },
cFireChargeEntity = cFireChargeEntity =
{ {
Desc = "", Desc = "",
Functions = {}, Functions = {},
Constants = {}, Constants = {},
Inherits = "cProjectileEntity", Inherits = "cProjectileEntity",
} , } ,
cFurnaceEntity = 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. An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks)
@ -914,7 +914,7 @@ cFile:Delete("/usr/bin/virus.exe");
Constants = {}, Constants = {},
Inherits = "cProjectileEntity", Inherits = "cProjectileEntity",
} , } ,
cGroup = cGroup =
{ {
Desc = [[cGroup is a group {{cPlayer|cPlayer}}'s can be in. Groups define the permissions players have, and optionally the color of their name in the chat. Desc = [[cGroup is a group {{cPlayer|cPlayer}}'s can be in. Groups define the permissions players have, and optionally the color of their name in the chat.
@ -1098,7 +1098,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins,
To test if a cItem object represents an empty item, do not compare the item type nor the item count, To test if a cItem object represents an empty item, do not compare the item type nor the item count,
but rather use the IsEmpty() function. but rather use the IsEmpty() function.
]], ]],
Functions = Functions =
{ {
constructor = constructor =
@ -1278,7 +1278,7 @@ various events. See below for further information.
{ {
Trace = { Params = "{{cWorld}}, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ", Return = "bool", Notes = "(STATIC) Performs the trace on the specified line. Returns true if the entire trace was processed (no callback returned true)" }, Trace = { Params = "{{cWorld}}, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ", Return = "bool", Notes = "(STATIC) Performs the trace on the specified line. Returns true if the entire trace was processed (no callback returned true)" },
}, },
AdditionalInfo = AdditionalInfo =
{ {
{ {
@ -1333,17 +1333,17 @@ function HandleSpideyCmd(a_Split, a_Player)
World:SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_COBWEB, 0); World:SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_COBWEB, 0);
end end
}; };
local EyePos = a_Player:GetEyePosition(); local EyePos = a_Player:GetEyePosition();
local LookVector = a_Player:GetLookVector(); local LookVector = a_Player:GetLookVector();
LookVector:Normalize(); -- Make the vector 1 m long LookVector:Normalize(); -- Make the vector 1 m long
-- Start cca 2 blocks away from the eyes -- Start cca 2 blocks away from the eyes
local Start = EyePos + LookVector + LookVector; local Start = EyePos + LookVector + LookVector;
local End = EyePos + LookVector * 50; local End = EyePos + LookVector * 50;
cLineBlockTracer.Trace(World, Callbacks, Start.x, Start.y, Start.z, End.x, End.y, End.z); cLineBlockTracer.Trace(World, Callbacks, Start.x, Start.y, Start.z, End.x, End.y, End.z);
return true; return true;
end end
</pre> </pre>
@ -1352,7 +1352,7 @@ end
}, },
}, -- AdditionalInfo }, -- AdditionalInfo
}, -- cLineBlockTracer }, -- cLineBlockTracer
cLuaWindow = cLuaWindow =
{ {
Desc = [[This class is used by plugins wishing to display a custom window to the player, unrelated to block entities or entities near the player. The window can be of any type and have any contents that the plugin defines. Callbacks for when the player modifies the window contents and when the player closes the window can be set. Desc = [[This class is used by plugins wishing to display a custom window to the player, unrelated to block entities or entities near the player. The window can be of any type and have any contents that the plugin defines. Callbacks for when the player modifies the window contents and when the player closes the window can be set.
@ -1447,7 +1447,7 @@ a_Player:OpenWindow(Window);
Constants = {}, Constants = {},
Inherits = "cPawn", Inherits = "cPawn",
}, },
cPawn = cPawn =
{ {
Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{centity|centity}} Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{centity|centity}}
@ -1554,7 +1554,7 @@ a_Player:OpenWindow(Window);
Constants = {}, Constants = {},
Inherits = "cPlugin", Inherits = "cPlugin",
}, },
cPluginManager = cPluginManager =
{ {
Desc = [[ Desc = [[
@ -1667,7 +1667,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
Constants = {}, Constants = {},
Inherits = "cEntity", Inherits = "cEntity",
}, },
cRoot = cRoot =
{ {
Desc = [[There is always only one cRoot object in MCServer. cRoot manages all the important objects such as {{cServer|cServer}} Desc = [[There is always only one cRoot object in MCServer. cRoot manages all the important objects such as {{cServer|cServer}}
@ -1728,7 +1728,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa
Constants = Constants =
{ {
}, },
Inherits = "cBlockEntity"; Inherits = "cBlockEntity";
}, },
@ -1743,7 +1743,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa
{ {
}, },
}, },
cThrownEggEntity = cThrownEggEntity =
{ {
Desc = "", Desc = "",
@ -1751,7 +1751,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa
Constants = {}, Constants = {},
Inherits = "cProjectileEntity", Inherits = "cProjectileEntity",
}, },
cThrownEnderPearlEntity = cThrownEnderPearlEntity =
{ {
Desc = "", Desc = "",
@ -1759,7 +1759,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa
Constants = {}, Constants = {},
Inherits = "cProjectileEntity", Inherits = "cProjectileEntity",
}, },
cThrownSnowballEntity = cThrownSnowballEntity =
{ {
Desc = "", Desc = "",
@ -1767,7 +1767,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa
Constants = {}, Constants = {},
Inherits = "cProjectileEntity", Inherits = "cProjectileEntity",
}, },
cTracer = cTracer =
{ {
Desc = [[A cTracer object is used to trace lines in the world. One thing you can use the cTracer for, is tracing what block a player is looking at, but you can do more with it if you want. Desc = [[A cTracer object is used to trace lines in the world. One thing you can use the cTracer for, is tracing what block a player is looking at, but you can do more with it if you want.
@ -1785,17 +1785,20 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa
cWebAdmin = cWebAdmin =
{ {
Desc = "", Desc = "",
Functions = {}, Functions =
{
GetHTMLEscapedString = { Params = "string", Return = "string", Notes = "Gets the HTML escaped representation of a requested string. This is useful for user input and game data that is not guaranteed to be escaped already." },
},
Constants = {}, Constants = {},
}, },
cWebPlugin = cWebPlugin =
{ {
Desc = "", Desc = "",
Functions = {}, Functions = {},
Constants = {}, Constants = {},
}, },
cWindow = cWindow =
{ {
Desc = [[This class is the common ancestor for all window classes used by MCServer. It is inherited by the {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be used for window-related hooks in the future. It implements the basic functionality of any window. Desc = [[This class is the common ancestor for all window classes used by MCServer. It is inherited by the {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be used for window-related hooks in the future. It implements the basic functionality of any window.
@ -1861,7 +1864,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa
<p> <p>
Game time is also handled by the world. It provides the time-of-day and the total world age. Game time is also handled by the world. It provides the time-of-day and the total world age.
]], ]],
Functions = Functions =
{ {
BroadcastChat = { Params = "Message, [{{cClientHandle|ExcludeClient}}]", Return = "", Notes = "Sends the Message to all players in this world, except the optional ExceptClient" }, BroadcastChat = { Params = "Message, [{{cClientHandle|ExcludeClient}}]", Return = "", Notes = "Sends the Message to all players in this world, except the optional ExceptClient" },
@ -2126,8 +2129,8 @@ World:ForEachEntity(
}, },
}, },
}, },
Hooks = Hooks =
{ {
HOOK_BLOCK_TO_PICKUPS = HOOK_BLOCK_TO_PICKUPS =
@ -2173,10 +2176,10 @@ function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_Blo
-- Not a tall grass being washed away -- Not a tall grass being washed away
return false; return false;
end end
-- Remove all pickups suggested by MCServer: -- Remove all pickups suggested by MCServer:
a_Pickups:Clear(); a_Pickups:Clear();
-- Drop a diamond: -- Drop a diamond:
a_Pickups:Add(cItem(E_ITEM_DIAMOND)); a_Pickups:Add(cItem(E_ITEM_DIAMOND));
return true; return true;
@ -2269,17 +2272,17 @@ function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
PseudoRandom = PseudoRandom * 8192 + PseudoRandom; PseudoRandom = PseudoRandom * 8192 + PseudoRandom;
PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff; PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff;
PseudoRandom = PseudoRandom / 7; PseudoRandom = PseudoRandom / 7;
-- Based on the PseudoRandom value, choose a location for the ore: -- Based on the PseudoRandom value, choose a location for the ore:
local OreX = PseudoRandom % 16; local OreX = PseudoRandom % 16;
local OreY = 2 + ((PseudoRandom / 16) % 20); local OreY = 2 + ((PseudoRandom / 16) % 20);
local OreZ = (PseudoRandom / 320) % 16; local OreZ = (PseudoRandom / 320) % 16;
-- Check if the location is in ExtremeHills: -- Check if the location is in ExtremeHills:
if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then
return false; return false;
end end
-- Only replace allowed blocks with the ore: -- Only replace allowed blocks with the ore:
local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ); local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ);
if ( if (
@ -3569,7 +3572,7 @@ end
}, -- HOOK_WORLD_TICK }, -- HOOK_WORLD_TICK
}, -- Hooks[] }, -- Hooks[]
IgnoreClasses = IgnoreClasses =
{ {
@ -3583,7 +3586,7 @@ end
"table", "table",
"g_TrackedPages", "g_TrackedPages",
}, },
IgnoreFunctions = IgnoreFunctions =
{ {
"Globals.assert", "Globals.assert",
@ -3594,7 +3597,7 @@ end
"%a+\.new", -- AnyClass.new "%a+\.new", -- AnyClass.new
"%a+.new_local", -- AnyClass.new_local "%a+.new_local", -- AnyClass.new_local
"%a+.delete", -- AnyClass.delete "%a+.delete", -- AnyClass.delete
-- Functions global in the APIDump plugin: -- Functions global in the APIDump plugin:
"CreateAPITables", "CreateAPITables",
"DumpAPIHtml", "DumpAPIHtml",

View File

@ -12,24 +12,24 @@
#if defined(_MSC_VER) #if defined(_MSC_VER)
// MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
#pragma warning(disable:4481) #pragma warning(disable:4481)
// Disable some warnings that we don't care about: // Disable some warnings that we don't care about:
#pragma warning(disable:4100) #pragma warning(disable:4100)
#define OBSOLETE __declspec(deprecated) #define OBSOLETE __declspec(deprecated)
// No alignment needed in MSVC // No alignment needed in MSVC
#define ALIGN_8 #define ALIGN_8
#define ALIGN_16 #define ALIGN_16
#elif defined(__GNUC__) #elif defined(__GNUC__)
// TODO: Can GCC explicitly mark classes as abstract (no instances can be created)? // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
#define abstract #define abstract
// TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class) // TODO: Can GCC mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
#define override #define override
#define OBSOLETE __attribute__((deprecated)) #define OBSOLETE __attribute__((deprecated))
#define ALIGN_8 __attribute__((aligned(8))) #define ALIGN_8 __attribute__((aligned(8)))
@ -41,13 +41,13 @@
#else #else
#error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler" #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
/* /*
// Copy and uncomment this into another #elif section based on your compiler identification // Copy and uncomment this into another #elif section based on your compiler identification
// Explicitly mark classes as abstract (no instances can be created) // Explicitly mark classes as abstract (no instances can be created)
#define abstract #define abstract
// Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class) // Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
#define override #define override
@ -92,17 +92,17 @@ typedef unsigned short UInt16;
// OS-dependent stuff: // OS-dependent stuff:
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x501 // We want to target WinXP and higher #define _WIN32_WINNT 0x501 // We want to target WinXP and higher
#include <Windows.h> #include <Windows.h>
#include <winsock2.h> #include <winsock2.h>
#include <Ws2tcpip.h> // IPv6 stuff #include <Ws2tcpip.h> // IPv6 stuff
// Windows SDK defines min and max macros, messing up with our std::min and std::max usage // Windows SDK defines min and max macros, messing up with our std::min and std::max usage
#undef min #undef min
#undef max #undef max
// Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant // Windows SDK defines GetFreeSpace as a constant, probably a Win16 API remnant
#ifdef GetFreeSpace #ifdef GetFreeSpace
#undef GetFreeSpace #undef GetFreeSpace

View File

@ -32,7 +32,7 @@ class cPlayerAccum :
m_Contents.append("</li>"); m_Contents.append("</li>");
return false; return false;
} }
public: public:
AString m_Contents; AString m_Contents;
@ -90,18 +90,18 @@ bool cWebAdmin::Init(void)
{ {
return false; return false;
} }
LOG("Initialising WebAdmin..."); LOG("Initialising WebAdmin...");
if (!m_IniFile.GetValueSetB("WebAdmin", "Enabled", true)) if (!m_IniFile.GetValueSetB("WebAdmin", "Enabled", true))
{ {
// WebAdmin is disabled, bail out faking a success // WebAdmin is disabled, bail out faking a success
return true; return true;
} }
AString PortsIPv4 = m_IniFile.GetValueSet("WebAdmin", "Port", "8080"); AString PortsIPv4 = m_IniFile.GetValueSet("WebAdmin", "Port", "8080");
AString PortsIPv6 = m_IniFile.GetValueSet("WebAdmin", "PortsIPv6", ""); AString PortsIPv6 = m_IniFile.GetValueSet("WebAdmin", "PortsIPv6", "");
if (!m_HTTPServer.Initialize(PortsIPv4, PortsIPv6)) if (!m_HTTPServer.Initialize(PortsIPv4, PortsIPv6))
{ {
return false; return false;
@ -121,9 +121,9 @@ bool cWebAdmin::Start(void)
// Not initialized // Not initialized
return false; return false;
} }
LOG("Starting WebAdmin..."); LOG("Starting WebAdmin...");
// Initialize the WebAdmin template script and load the file // Initialize the WebAdmin template script and load the file
m_TemplateScript.Create(); m_TemplateScript.Create();
if (!m_TemplateScript.LoadFile(FILE_IO_PREFIX "webadmin/template.lua")) if (!m_TemplateScript.LoadFile(FILE_IO_PREFIX "webadmin/template.lua"))
@ -176,12 +176,12 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque
a_Connection.SendNeedAuth("MCServer WebAdmin - bad username or password"); a_Connection.SendNeedAuth("MCServer WebAdmin - bad username or password");
return; return;
} }
// Check if the contents should be wrapped in the template: // Check if the contents should be wrapped in the template:
AString URL = a_Request.GetBareURL(); AString URL = a_Request.GetBareURL();
ASSERT(URL.length() > 0); ASSERT(URL.length() > 0);
bool ShouldWrapInTemplate = ((URL.length() > 1) && (URL[1] != '~')); bool ShouldWrapInTemplate = ((URL.length() > 1) && (URL[1] != '~'));
// Retrieve the request data: // Retrieve the request data:
cWebadminRequestData * Data = (cWebadminRequestData *)(a_Request.GetUserData()); cWebadminRequestData * Data = (cWebadminRequestData *)(a_Request.GetUserData());
if (Data == NULL) if (Data == NULL)
@ -189,14 +189,14 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque
a_Connection.SendStatusAndReason(500, "Bad UserData"); a_Connection.SendStatusAndReason(500, "Bad UserData");
return; return;
} }
// Wrap it all up for the Lua call: // Wrap it all up for the Lua call:
AString Template; AString Template;
HTTPTemplateRequest TemplateRequest; HTTPTemplateRequest TemplateRequest;
TemplateRequest.Request.Username = a_Request.GetAuthUsername(); TemplateRequest.Request.Username = a_Request.GetAuthUsername();
TemplateRequest.Request.Method = a_Request.GetMethod(); TemplateRequest.Request.Method = a_Request.GetMethod();
TemplateRequest.Request.Path = URL.substr(1); TemplateRequest.Request.Path = URL.substr(1);
if (Data->m_Form.Finish()) if (Data->m_Form.Finish())
{ {
for (cHTTPFormParser::const_iterator itr = Data->m_Form.begin(), end = Data->m_Form.end(); itr != end; ++itr) for (cHTTPFormParser::const_iterator itr = Data->m_Form.begin(), end = Data->m_Form.end(); itr != end; ++itr)
@ -208,7 +208,7 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque
TemplateRequest.Request.FormData[itr->first] = HTTPfd; TemplateRequest.Request.FormData[itr->first] = HTTPfd;
TemplateRequest.Request.PostParams[itr->first] = itr->second; TemplateRequest.Request.PostParams[itr->first] = itr->second;
} // for itr - Data->m_Form[] } // for itr - Data->m_Form[]
// Parse the URL into individual params: // Parse the URL into individual params:
size_t idxQM = a_Request.GetURL().find('?'); size_t idxQM = a_Request.GetURL().find('?');
if (idxQM != AString::npos) if (idxQM != AString::npos)
@ -221,7 +221,7 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque
} // for itr - URLParams[] } // for itr - URLParams[]
} }
} }
// Try to get the template from the Lua template script // Try to get the template from the Lua template script
if (ShouldWrapInTemplate) if (ShouldWrapInTemplate)
{ {
@ -236,7 +236,7 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque
a_Connection.SendStatusAndReason(500, "m_TemplateScript failed"); a_Connection.SendStatusAndReason(500, "m_TemplateScript failed");
return; return;
} }
AString BaseURL = GetBaseURL(URL); AString BaseURL = GetBaseURL(URL);
AString Menu; AString Menu;
Template = "{CONTENT}"; Template = "{CONTENT}";
@ -397,7 +397,38 @@ AString cWebAdmin::GetBaseURL( const AString& a_URL )
AString cWebAdmin::GetBaseURL( const AStringVector& a_URLSplit ) AString cWebAdmin::GetHTMLEscapedString(const AString & a_Input)
{
AString dst;
dst.reserve(a_Input.length());
// Loop over input and substitute HTML characters for their alternatives:
size_t len = a_Input.length();
for (size_t i = 0; i < len; i++)
{
switch (a_Input[i])
{
case '&': dst.append("&amp;"); break;
case '\'': dst.append("&apos;"); break;
case '"': dst.append("&quot;"); break;
case '<': dst.append("&lt;"); break;
case '>': dst.append("&gt;"); break;
default:
{
dst.push_back(a_Input[i]);
break;
}
} // switch (a_Input[i])
} // for i - a_Input[]
return dst;
}
AString cWebAdmin::GetBaseURL(const AStringVector & a_URLSplit)
{ {
AString BaseURL = "./"; AString BaseURL = "./";
if (a_URLSplit.size() > 1) if (a_URLSplit.size() > 1)
@ -481,7 +512,7 @@ void cWebAdmin::OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest &
{ {
// TODO: Handle other requests // TODO: Handle other requests
} }
// Delete any request data assigned to the request: // Delete any request data assigned to the request:
cRequestData * Data = (cRequestData *)(a_Request.GetUserData()); cRequestData * Data = (cRequestData *)(a_Request.GetUserData());
delete Data; delete Data;

View File

@ -51,18 +51,18 @@ struct HTTPRequest
{ {
typedef std::map< std::string, std::string > StringStringMap; typedef std::map< std::string, std::string > StringStringMap;
typedef std::map< std::string, HTTPFormData > FormDataMap; typedef std::map< std::string, HTTPFormData > FormDataMap;
AString Method; AString Method;
AString Path; AString Path;
AString Username; AString Username;
// tolua_end // tolua_end
/// Parameters given in the URL, after the questionmark /// Parameters given in the URL, after the questionmark
StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS << StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS <<
/// Parameters posted as a part of a form - either in the URL (GET method) or in the body (POST method) /// Parameters posted as a part of a form - either in the URL (GET method) or in the body (POST method)
StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS << StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS <<
/// Same as PostParams /// Same as PostParams
FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS << FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS <<
} ; // tolua_export } ; // tolua_export
@ -101,7 +101,7 @@ class cWebAdmin :
{ {
public: public:
// tolua_end // tolua_end
typedef std::list< cWebPlugin* > PluginList; typedef std::list< cWebPlugin* > PluginList;
@ -110,7 +110,7 @@ public:
/// Initializes the object. Returns true if successfully initialized and ready to start /// Initializes the object. Returns true if successfully initialized and ready to start
bool Init(void); bool Init(void);
/// Starts the HTTP server taking care of the admin. Returns true if successful /// Starts the HTTP server taking care of the admin. Returns true if successful
bool Start(void); bool Start(void);
@ -121,32 +121,35 @@ public:
PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS << PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS <<
// tolua_begin // tolua_begin
/// Returns the amount of currently used memory, in KiB, or -1 if it cannot be queried /// Returns the amount of currently used memory, in KiB, or -1 if it cannot be queried
static int GetMemoryUsage(void); static int GetMemoryUsage(void);
sWebAdminPage GetPage(const HTTPRequest& a_Request); sWebAdminPage GetPage(const HTTPRequest& a_Request);
/// Returns the contents of the default page - the list of plugins and players /// Returns the contents of the default page - the list of plugins and players
AString GetDefaultPage(void); AString GetDefaultPage(void);
AString GetBaseURL(const AString& a_URL); AString GetBaseURL(const AString& a_URL);
// Escapes text passed into it, so it can be embedded into html.
AString GetHTMLEscapedString( const AString& a_Input );
// tolua_end // tolua_end
AString GetBaseURL(const AStringVector& a_URLSplit); AString GetBaseURL(const AStringVector& a_URLSplit);
protected: protected:
/// Common base class for request body data handlers /// Common base class for request body data handlers
class cRequestData class cRequestData
{ {
public: public:
virtual ~cRequestData() {} // Force a virtual destructor in all descendants virtual ~cRequestData() {} // Force a virtual destructor in all descendants
/// Called when a new chunk of body data is received /// Called when a new chunk of body data is received
virtual void OnBody(const char * a_Data, int a_Size) = 0; virtual void OnBody(const char * a_Data, int a_Size) = 0;
} ; } ;
/// The body handler for requests in the "/webadmin" and "/~webadmin" paths /// The body handler for requests in the "/webadmin" and "/~webadmin" paths
class cWebadminRequestData : class cWebadminRequestData :
public cRequestData, public cRequestData,
@ -154,13 +157,13 @@ protected:
{ {
public: public:
cHTTPFormParser m_Form; cHTTPFormParser m_Form;
cWebadminRequestData(cHTTPRequest & a_Request) : cWebadminRequestData(cHTTPRequest & a_Request) :
m_Form(a_Request, *this) m_Form(a_Request, *this)
{ {
} }
// cRequestData overrides: // cRequestData overrides:
virtual void OnBody(const char * a_Data, int a_Size) override; virtual void OnBody(const char * a_Data, int a_Size) override;
@ -169,31 +172,31 @@ protected:
virtual void OnFileData(cHTTPFormParser & a_Parser, const char * a_Data, int a_Size) override {} virtual void OnFileData(cHTTPFormParser & a_Parser, const char * a_Data, int a_Size) override {}
virtual void OnFileEnd(cHTTPFormParser & a_Parser) override {} virtual void OnFileEnd(cHTTPFormParser & a_Parser) override {}
} ; } ;
/// Set to true if Init() succeeds and the webadmin isn't to be disabled /// Set to true if Init() succeeds and the webadmin isn't to be disabled
bool m_IsInitialized; bool m_IsInitialized;
/// The webadmin.ini file, used for the settings and allowed logins /// The webadmin.ini file, used for the settings and allowed logins
cIniFile m_IniFile; cIniFile m_IniFile;
PluginList m_Plugins; PluginList m_Plugins;
/// The Lua template script to provide templates: /// The Lua template script to provide templates:
cLuaState m_TemplateScript; cLuaState m_TemplateScript;
/// The HTTP server which provides the underlying HTTP parsing, serialization and events /// The HTTP server which provides the underlying HTTP parsing, serialization and events
cHTTPServer m_HTTPServer; cHTTPServer m_HTTPServer;
AString GetTemplate(void); AString GetTemplate(void);
/// Handles requests coming to the "/webadmin" or "/~webadmin" URLs /// Handles requests coming to the "/webadmin" or "/~webadmin" URLs
void HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request); void HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request);
/// Handles requests for the root page /// Handles requests for the root page
void HandleRootRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request); void HandleRootRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request);
// cHTTPServer::cCallbacks overrides: // cHTTPServer::cCallbacks overrides:
virtual void OnRequestBegun (cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override; virtual void OnRequestBegun (cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override;
virtual void OnRequestBody (cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, int a_Size) override; virtual void OnRequestBody (cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, int a_Size) override;