Merge branch 'master' into MobSpawner
Conflicts: MCServer/Plugins/Core
2
.gitignore
vendored
@@ -24,6 +24,8 @@ AllFiles.lst
|
||||
*.*~
|
||||
*~
|
||||
*.orig
|
||||
## CLion
|
||||
.idea
|
||||
## Eclipse
|
||||
.cproject
|
||||
.project
|
||||
|
||||
14
.gitmodules
vendored
@@ -7,9 +7,21 @@
|
||||
[submodule "MCServer/Plugins/TransAPI"]
|
||||
path = MCServer/Plugins/TransAPI
|
||||
url = https://github.com/bearbin/transapi.git
|
||||
[submodule "MCServer/Plugins/ChunkWorx"]
|
||||
path = MCServer/Plugins/ChunkWorx
|
||||
url = https://github.com/mc-server/ChunkWorx.git
|
||||
[submodule "MCServer/Plugins/ChatLog"]
|
||||
path = MCServer/Plugins/ChatLog
|
||||
url = https://github.com/mc-server/ChatLog.git
|
||||
[submodule "MCServer/Plugins/Handy"]
|
||||
path = MCServer/Plugins/Handy
|
||||
url = https://github.com/mc-server/Handy.git
|
||||
[submodule "MCServer/Plugins/MagicCarpet"]
|
||||
path = MCServer/Plugins/MagicCarpet
|
||||
url = https://github.com/mc-server/MagicCarpet.git
|
||||
[submodule "lib/polarssl"]
|
||||
path = lib/polarssl
|
||||
url = https://github.com/mc-server/polarssl
|
||||
url = https://github.com/mc-server/polarssl.git
|
||||
[submodule "lib/SQLiteCpp"]
|
||||
path = lib/SQLiteCpp
|
||||
url = https://github.com/mc-server/SQLiteCpp.git
|
||||
|
||||
13
Android/res/values-pl/strings.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="hello">Hello World, MCServerActivity!</string>
|
||||
<string name="app_name">MCServer</string>
|
||||
<string name="start">Start</string>
|
||||
<string name="stop">Stop</string>
|
||||
<string name="mcserver_is_running">MCServer jest włączony</string>
|
||||
<string name="mcserver_is_not_running">MCServer jest wyłączony</string>
|
||||
<string name="your_ip">Twoje IP …</string>
|
||||
<string name="configure">Ustawienia</string>
|
||||
|
||||
</resources>
|
||||
@@ -37,6 +37,21 @@ if(DEFINED ENV{MCSERVER_BUILD_ID})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# We need C++11 features, Visual Studio has those from VS2012, but it needs a new platform toolset for those; VS2013 supports them natively:
|
||||
# Adapted from http://binglongx.wordpress.com/2013/06/28/set-non-default-platform-toolset-in-cmake/
|
||||
if(MSVC OR MSVC_IDE)
|
||||
if( MSVC_VERSION LESS 1700 ) # VC10- / VS2010-
|
||||
message(FATAL_ERROR "The project requires C++11 features. "
|
||||
"You need at least Visual Studio 11 (Microsoft Visual Studio 2012), "
|
||||
"with Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012).")
|
||||
elseif( MSVC_VERSION EQUAL 1700 ) # VC11 / VS2012
|
||||
message( "VC11: using Microsoft Visual Studio 2012 "
|
||||
"with Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012)" )
|
||||
set(CMAKE_GENERATOR_TOOLSET "v120_CTP_Nov2012" CACHE STRING "Platform Toolset" FORCE)
|
||||
else() # VC12+, assuming C++11 supported.
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# This has to be done before any flags have been set up.
|
||||
if(${BUILD_TOOLS})
|
||||
add_subdirectory(Tools/MCADefrag/)
|
||||
@@ -81,7 +96,6 @@ set(SQLITECPP_BUILD_TESTS OFF CACHE BOOL "Build and run tests."
|
||||
set(SQLITECPP_INTERNAL_SQLITE OFF CACHE BOOL "Add the internal SQLite3 source to the project." FORCE)
|
||||
|
||||
# Include all the libraries:
|
||||
add_subdirectory(lib/inifile/)
|
||||
add_subdirectory(lib/jsoncpp/)
|
||||
add_subdirectory(lib/zlib/)
|
||||
add_subdirectory(lib/lua/)
|
||||
|
||||
@@ -4,9 +4,8 @@ To compile MCServer from source, you need CMake and make, as well as a C compile
|
||||
|
||||
## Windows ##
|
||||
|
||||
We use Microsoft Visual Studio for Windows compilation. It is possible to use other toolchains, but it isn't tested nor supported. Visual Studio versions 2008 Express and 2013 Express are being actively used for development, so either should work.
|
||||
You can find download links for VS2008 Express here: http://stackoverflow.com/questions/15318560/visual-c-2008-express-download-link-dead
|
||||
And VS2013 Express here: http://www.microsoft.com/en-us/download/details.aspx?id=40787
|
||||
We use Microsoft Visual Studio for Windows compilation. It is possible to use other toolchains, but it isn't tested nor supported. Visual Studio versions 2013 Express is being actively used for development.
|
||||
You can find download links for VS2013 Express here: http://www.microsoft.com/en-us/download/details.aspx?id=40787
|
||||
|
||||
Next, you need to download and install CMake. Download from here: http://cmake.org/cmake/resources/software.html . You should download a full installation package, so that the installer will set everything up for you (especially the paths).
|
||||
|
||||
|
||||
@@ -4,12 +4,14 @@ BasedDoge (Donated AlchemistVillage prefabs)
|
||||
bearbin (Alexander Harkness)
|
||||
derouinw
|
||||
Diusrex
|
||||
Duralex
|
||||
Duralex
|
||||
FakeTruth (founder)
|
||||
Howaner
|
||||
keyboard
|
||||
Lapayo
|
||||
Luksor
|
||||
marmot21
|
||||
Masy98
|
||||
mborland
|
||||
mgueydan
|
||||
MikeHunsinger
|
||||
@@ -18,6 +20,7 @@ nesco
|
||||
rs2k
|
||||
SamJBarney
|
||||
Sofapriester
|
||||
SphinxC0re
|
||||
STR_Warrior
|
||||
structinf (xdot)
|
||||
Sxw1212
|
||||
@@ -25,10 +28,9 @@ Taugeshtu
|
||||
tigerw (Tiger Wang)
|
||||
tonibm19
|
||||
UltraCoderRU
|
||||
WebFreak001
|
||||
worktycho
|
||||
xoft
|
||||
Yeeeeezus (Donated AlchemistVillage prefabs)
|
||||
Howaner
|
||||
Masy98
|
||||
|
||||
Please add yourself to this list if you contribute to MCServer.
|
||||
|
||||
@@ -524,22 +524,29 @@ end
|
||||
Functions =
|
||||
{
|
||||
GenerateOfflineUUID = { Params = "Username", Return = "string", Notes = "(STATIC) Generates an UUID based on the player name provided. This is used for the offline (non-auth) mode, when there's no UUID source. Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. Returns a 32-char UUID (no dashes)." },
|
||||
GetClientBrand = { Params = "", Return = "string", Notes = "Returns the brand that the client has sent in their MC|Brand plugin message." },
|
||||
GetIPString = { Params = "", Return = "string", Notes = "Returns the IP address of the connection, as a string. Only the address part is returned, without the port number." },
|
||||
GetLocale = { Params = "", Return = "Locale", Notes = "Returns the locale string that the client sends as part of the protocol handshake. Can be used to provide localized strings." },
|
||||
GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" },
|
||||
GetPlayer = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player object connected to this client. Note that this may be nil, for example if the player object is not yet spawned." },
|
||||
GetProtocolVersion = { Params = "", Return = "number", Notes = "Returns the protocol version number of the protocol that the client is talking. Returns zero if the protocol version is not (yet) known." },
|
||||
GetUniqueID = { Params = "", Return = "number", Notes = "Returns the UniqueID of the client used to identify the client in the server" },
|
||||
GetUUID = { Params = "", Return = "string", Notes = "Returns the authentication-based UUID of the client. This UUID should be used to identify the player when persisting any player-related data. Returns a 32-char UUID (no dashes)" },
|
||||
GetUsername = { Params = "", Return = "string", Notes = "Returns the username that the client has provided" },
|
||||
GetViewDistance = { Params = "", Return = "number", Notes = "Returns the viewdistance (number of chunks loaded for the player in each direction)" },
|
||||
GetRequestedViewDistance = { Params = "", Return = "number", Notes = "Returns the view distance that the player request, not the used view distance." },
|
||||
HasPluginChannel = { Params = "ChannelName", Return = "bool", Notes = "Returns true if the client has registered to receive messages on the specified plugin channel." },
|
||||
IsUUIDOnline = { Params = "UUID", Return = "bool", Notes = "(STATIC) Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. Accepts both 32-char and 36-char UUIDs (with and without dashes). If the string given is not a valid UUID, returns false."},
|
||||
Kick = { Params = "Reason", Return = "", Notes = "Kicks the user with the specified reason" },
|
||||
SendPluginMessage = { Params = "Channel, Message", Return = "", Notes = "Sends the plugin message on the specified channel." },
|
||||
SetClientBrand = { Params = "ClientBrand", Return = "", Notes = "Sets the value of the client's brand. Normally this value is received from the client by a MC|Brand plugin message, this function lets plugins overwrite the value." },
|
||||
SetLocale = { Params = "Locale", Return = "", Notes = "Sets the locale that MCServer keeps on record. Initially the locale is initialized in protocol handshake, this function allows plugins to override the stored value (but only server-side and only until the user disconnects)." },
|
||||
SetUsername = { Params = "Name", Return = "", Notes = "Sets the username" },
|
||||
SetViewDistance = { Params = "ViewDistance", Return = "", Notes = "Sets the viewdistance (number of chunks loaded for the player in each direction)" },
|
||||
SendBlockChange = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sends a BlockChange packet to the client. This can be used to create fake blocks only for that player." },
|
||||
SendEntityAnimation = { Params = "{{cEntity|Entity}}, AnimationNumber", Return = "", Notes = "Sends the specified animation of the specified entity to the client. The AnimationNumber is protocol-specific." },
|
||||
SendSoundEffect = { Params = "SoundName, X, Y, Z, Volume, Pitch", Return = "", Notes = "Sends a sound effect request to the client. The sound is played at the specified coords, with the specified volume (a float, 1.0 is full volume, can be more) and pitch (0-255, 63 is 100%)" },
|
||||
SendTimeUpdate = { Params = "WorldAge, TimeOfDay, DoDaylightCycle", Return = "", Notes = "Sends the specified time update to the client. WorldAge is the total age of the world, in ticks. TimeOfDay is the current day's time, in ticks (0 - 24000). DoDaylightCycle is a bool that specifies whether the client should automatically move the sun (true) or keep it in the same place (false)." },
|
||||
},
|
||||
Constants =
|
||||
{
|
||||
@@ -555,9 +562,9 @@ end
|
||||
and commands suggested on click. The chat message can be sent by the regular chat-sending functions,
|
||||
{{cPlayer}}:SendMessage(), {{cWorld}}:BroadcastChat() and {{cRoot}}:BroadcastChat().</p>
|
||||
<p>
|
||||
Note that most of the functions in this class are so-called modifiers - they modify the object and
|
||||
then return the object itself, so that they can be chained one after another. See the Chaining
|
||||
example below for details.</p>
|
||||
Note that most of the functions in this class are so-called chaining modifiers - they modify the
|
||||
object and then return the object itself, so that they can be chained one after another. See the
|
||||
Chaining example below for details.</p>
|
||||
<p>
|
||||
Each part of the composite chat message takes a "Style" parameter, this is a string that describes
|
||||
the formatting. It uses the following strings, concatenated together:
|
||||
@@ -581,14 +588,17 @@ end
|
||||
{ Params = "Text", Return = "", Notes = "Creates a chat message containing the specified text, parsed by the ParseText() function. This allows easy migration from old chat messages." },
|
||||
},
|
||||
AddRunCommandPart = { Params = "Text, Command, [Style]", Return = "self", Notes = "Adds a text which, when clicked, runs the specified command. Chaining." },
|
||||
AddShowAchievementPart = { Params = "PlayerName, AchievementName, [Style]", Return = "", Notes = "Adds a text that represents the 'Achievement get' message." },
|
||||
AddSuggestCommandPart = { Params = "Text, Command, [Style]", Return = "self", Notes = "Adds a text which, when clicked, puts the specified command into the player's chat input area. Chaining." },
|
||||
AddTextPart = { Params = "Text, [Style]", Return = "self", Notes = "Adds a regular text. Chaining." },
|
||||
AddUrlPart = { Params = "Text, Url, [Style]", Return = "self", Notes = "Adds a text which, when clicked, opens up a browser at the specified URL. Chaining." },
|
||||
Clear = { Params = "", Return = "", Notes = "Removes all parts from this object" },
|
||||
CreateJsonString = { Params = "[AddPrefixes]", Return = "string", Notes = "Returns the entire object serialized into JSON, as it would be sent to a client. AddPrefixes specifies whether the chat prefixes should be prepended to the message, true by default." },
|
||||
ExtractText = { Params = "", Return = "string", Notes = "Returns the text from the parts that comprises the human-readable data. Used for older protocols that don't support composite chat and for console-logging." },
|
||||
GetAdditionalMessageTypeData = { Params = "", Return = "string", Notes = "Returns the AdditionalData associated with the message, such as the sender's name for mtPrivateMessage" },
|
||||
GetMessageType = { Params = "", Return = "MessageType", Notes = "Returns the MessageType (mtXXX constant) that is associated with this message. When sent to a player, the message will be formatted according to this message type and the player's settings (adding \"[INFO]\" prefix etc.)" },
|
||||
ParseText = { Params = "Text", Return = "self", Notes = "Adds text, while recognizing http and https URLs and old-style formatting codes (\"@2\"). Chaining." },
|
||||
SetMessageType = { Params = "MessageType", Return = "self", Notes = "Sets the MessageType (mtXXX constant) that is associated with this message. When sent to a player, the message will be formatted according to this message type and the player's settings (adding \"[INFO]\" prefix etc.) Chaining." },
|
||||
SetMessageType = { Params = "MessageType, AdditionalData", Return = "self", Notes = "Sets the MessageType (mtXXX constant) that is associated with this message. Also sets the additional data (string) associated with the message, which is specific for the message type - such as the sender's name for mtPrivateMessage. When sent to a player, the message will be formatted according to this message type and the player's settings (adding \"[INFO]\" prefix etc.). Chaining." },
|
||||
UnderlineUrls = { Params = "", Return = "self", Notes = "Makes all URL parts contained in the message underlined. Doesn't affect parts added in the future. Chaining." },
|
||||
},
|
||||
|
||||
@@ -605,7 +615,7 @@ function OnPlayerJoined(a_Player)
|
||||
-- Send an example composite chat message to the player:
|
||||
a_Player:SendMessage(cCompositeChat()
|
||||
:AddTextPart("Hello, ")
|
||||
:AddUrlPart(a_Player:GetName(), "www.mc-server.org", "u@2") -- Colored underlined link
|
||||
:AddUrlPart(a_Player:GetName(), "http://www.mc-server.org", "u@2") -- Colored underlined link
|
||||
:AddSuggestCommandPart(", and welcome.", "/help", "u") -- Underlined suggest-command
|
||||
:AddRunCommandPart(" SetDay", "/time set 0") -- Regular text that will execute command when clicked
|
||||
:SetMessageType(mtJoin) -- It is a join-message
|
||||
@@ -777,7 +787,9 @@ end</pre>
|
||||
AddSpeedX = { Params = "AddX", Return = "", Notes = "Adds the specified amount of speed in the X axis direction." },
|
||||
AddSpeedY = { Params = "AddY", Return = "", Notes = "Adds the specified amount of speed in the Y axis direction." },
|
||||
AddSpeedZ = { Params = "AddZ", Return = "", Notes = "Adds the specified amount of speed in the Z axis direction." },
|
||||
ArmorCoversAgainst = { Params = "{{cEntity|AttackerEntity}}, DamageType, RawDamage", Return = "number", Notes = "Returns the points out of a_RawDamage that the currently equipped armor would cover." },
|
||||
Destroy = { Params = "", Return = "", Notes = "Schedules the entity to be destroyed" },
|
||||
GetAirLevel = { Params = "", Return = "number", Notes = "Returns the air level (number of ticks of air left). Note, this function is only updated with mobs or players." },
|
||||
GetArmorCoverAgainst = { Params = "AttackerEntity, DamageType, RawDamage", Return = "number", Notes = "Returns the number of hitpoints out of RawDamage that the currently equipped armor would cover. See {{TakeDamageInfo}} for more information on attack damage." },
|
||||
GetChunkX = { Params = "", Return = "number", Notes = "Returns the X-coord of the chunk in which the entity is placed" },
|
||||
GetChunkZ = { Params = "", Return = "number", Notes = "Returns the Z-coord of the chunk in which the entity is placed" },
|
||||
@@ -793,6 +805,7 @@ end</pre>
|
||||
GetHeadYaw = { Params = "", Return = "number", Notes = "Returns the pitch of the entity's head (FIXME: Rename to GetHeadPitch() )." },
|
||||
GetHealth = { Params = "", Return = "number", Notes = "Returns the current health of the entity." },
|
||||
GetHeight = { Params = "", Return = "number", Notes = "Returns the height (Y size) of the entity" },
|
||||
GetInvulnerableTicks = { Params = "", Return = "number", Notes = "Returns the number of ticks that this entity will be invulnerable for. This is used for after-hit recovery - the entities are invulnerable for half a second after being hit." },
|
||||
GetKnockbackAmountAgainst = { Params = "ReceiverEntity", Return = "number", Notes = "Returns the amount of knockback that the currently equipped items would cause when attacking the ReceiverEntity." },
|
||||
GetLookVector = { Params = "", Return = "{{Vector3f}}", Notes = "Returns the vector that defines the direction in which the entity is looking" },
|
||||
GetMass = { Params = "", Return = "number", Notes = "Returns the mass of the entity. Currently unused." },
|
||||
@@ -810,23 +823,29 @@ end</pre>
|
||||
GetSpeedX = { Params = "", Return = "number", Notes = "Returns the X-part of the speed vector" },
|
||||
GetSpeedY = { Params = "", Return = "number", Notes = "Returns the Y-part of the speed vector" },
|
||||
GetSpeedZ = { Params = "", Return = "number", Notes = "Returns the Z-part of the speed vector" },
|
||||
GetTicksAlive = { Params = "", Return = "number", Notes = "Returns the number of ticks that this entity has been alive for." },
|
||||
GetUniqueID = { Params = "", Return = "number", Notes = "Returns the ID that uniquely identifies the entity within the running server. Note that this ID is not persisted to the data files." },
|
||||
GetWidth = { Params = "", Return = "number", Notes = "Returns the width (X and Z size) of the entity." },
|
||||
GetWorld = { Params = "", Return = "{{cWorld}}", Notes = "Returns the world where the entity resides" },
|
||||
GetYaw = { Params = "", Return = "number", Notes = "Returns the yaw (direction) of the entity. Measured in degrees, values range from -180 to +180. 0 means ZP, 90 means XM, -180 means ZM, -90 means XP." },
|
||||
HandleSpeedFromAttachee = { Params = "ForwardAmount, SidewaysAmount", Return = "", Notes = "Updates the entity's speed based on the attachee exerting the specified force forward and sideways. Used for entities being driven by other entities attached to them - usually players driving minecarts and boats." },
|
||||
Heal = { Params = "Hitpoints", Return = "", Notes = "Heals the specified number of hitpoints. Hitpoints is expected to be a positive number." },
|
||||
IsA = { Params = "ClassName", Return = "bool", Notes = "Returns true if the entity class is a descendant of the specified class name, or the specified class itself" },
|
||||
IsBoat = { Params = "", Return = "bool", Notes = "Returns true if the entity is a {{cBoat|boat}}." },
|
||||
IsCrouched = { Params = "", Return = "bool", Notes = "Returns true if the entity is crouched. Always false for entities that don't support crouching." },
|
||||
IsDestroyed = { Params = "", Return = "bool", Notes = "Returns true if the entity has been destroyed and is awaiting removal from the internal structures." },
|
||||
IsEnderCrystal = { Params = "", Return = "bool", Notes = "Returns true if the entity is an ender crystal." },
|
||||
IsExpOrb = { Params = "", Return = "bool", Notes = "Returns true if the entity represents an experience orb" },
|
||||
IsFallingBlock = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cFallingBlock}} entity." },
|
||||
IsFireproof = { Params = "", Return = "bool", Notes = "Returns true if the entity takes no damage from being on fire." },
|
||||
IsFloater = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a fishing rod floater" },
|
||||
IsInvisible = { Params = "", Return = "bool", Notes = "Returns true if the entity is invisible" },
|
||||
IsItemFrame = { Params = "", Return = "bool", Notes = "Returns true if the entity is an item frame." },
|
||||
IsMinecart = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cMinecart|minecart}}" },
|
||||
IsMob = { Params = "", Return = "bool", Notes = "Returns true if the entity represents any {{cMonster|mob}}." },
|
||||
IsOnFire = { Params = "", Return = "bool", Notes = "Returns true if the entity is on fire" },
|
||||
IsPainting = { Params = "", Return = "bool", Notes = "Returns if this entity is a painting." },
|
||||
IsPawn = { Params = "", Return = "bool", Notes = "Returns true if the entity is a {{cPawn}} descendant." },
|
||||
IsPickup = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cPickup|pickup}}." },
|
||||
IsPlayer = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cPlayer|player}}" },
|
||||
IsProjectile = { Params = "", Return = "bool", Notes = "Returns true if the entity is a {{cProjectileEntity}} descendant." },
|
||||
@@ -836,12 +855,19 @@ end</pre>
|
||||
IsSubmerged = { Params = "", Return = "bool", Notes = "Returns true if the mob or player is submerged in water (head is in a water block). Note, this function is only updated with mobs or players." },
|
||||
IsSwimming = { Params = "", Return = "bool", Notes = "Returns true if the mob or player is swimming in water (feet are in a water block). Note, this function is only updated with mobs or players." },
|
||||
IsTNT = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cTNTEntity|TNT entity}}" },
|
||||
Killed = { Params = "{{cEntity|Victim}}", Return = "", Notes = "This entity has killed another entity (the Victim). For players, adds the scoreboard statistics about the kill." },
|
||||
KilledBy = { Notes = "FIXME: Remove this from API" },
|
||||
GetAirLevel = { Params = "", Return = "number", Notes = "Returns the air level (number of ticks of air left). Note, this function is only updated with mobs or players." },
|
||||
MoveToWorld =
|
||||
{
|
||||
{ Params = "{{cWorld|World}}, [ShouldSendRespawn]", Return = "bool", Notes = "Removes the entity from this world and starts moving it to the specified world. Note that to avoid deadlocks, the move is asynchronous - the entity is moved into a queue and will be moved from that queue into the destination world at some (unpredictable) time in the future. ShouldSendRespawn is used only for players, it specifies whether the player should be sent a Repawn packet upon leaving the world (The client handles respawns only between different dimensions)." },
|
||||
{ Params = "WorldName, [ShouldSendRespawn]", Return = "bool", Notes = "Removes the entity from this world and starts moving it to the specified world. Note that to avoid deadlocks, the move is asynchronous - the entity is moved into a queue and will be moved from that queue into the destination world at some (unpredictable) time in the future. ShouldSendRespawn is used only for players, it specifies whether the player should be sent a Repawn packet upon leaving the world (The client handles respawns only between different dimensions)." },
|
||||
},
|
||||
SetGravity = { Params = "Gravity", Return = "", Notes = "Sets the number that is used as the gravity for physics simulation. 1G (9.78) by default." },
|
||||
SetHeadYaw = { Params = "HeadPitch", Return = "", Notes = "Sets the head pitch (FIXME: Rename to SetHeadPitch() )." },
|
||||
SetHealth = { Params = "Hitpoints", Return = "", Notes = "Sets the entity's health to the specified amount of hitpoints. Doesn't broadcast any hurt animation. Doesn't kill the entity if health drops below zero. Use the TakeDamage() function instead for taking damage." },
|
||||
SetHeight = { Params = "", Return = "", Notes = "FIXME: Remove this from API" },
|
||||
SetInvulnerableTicks = { Params = "NumTicks", Return = "", Notes = "Sets the amount of ticks for which the entity will not receive any damage from other entities." },
|
||||
SetIsFireproof = { Params = "IsFireproof", Return = "", Notes = "Sets whether the entity receives damage from being on fire." },
|
||||
SetMass = { Params = "Mass", Return = "", Notes = "Sets the mass of the entity. Currently unused." },
|
||||
SetMaxHealth = { Params = "MaxHitpoints", Return = "", Notes = "Sets the maximum hitpoints of the entity. If current health is above MaxHitpoints, it is capped to MaxHitpoints." },
|
||||
SetPitch = { Params = "number", Return = "", Notes = "Sets the pitch (nose-down rotation) of the entity" },
|
||||
@@ -856,7 +882,7 @@ end</pre>
|
||||
SetPosZ = { Params = "number", Return = "", Notes = "Sets the Z-coord of the entity's pivot" },
|
||||
SetRoll = { Params = "number", Return = "", Notes = "Sets the roll (sideways rotation) of the entity. Currently unused." },
|
||||
SetRot = { Params = "{{Vector3f|Rotation}}", Return = "", Notes = "Sets the entire rotation vector (Yaw, Pitch, Roll)" },
|
||||
SetYawFromSpeed = { Params = "", Return = "", Notes = "Sets the entity's yaw to match its current speed (entity looking forwards as it moves). (FIXME: Rename to SetYawFromSpeed)" },
|
||||
SetYawFromSpeed = { Params = "", Return = "", Notes = "Sets the entity's yaw to match its current speed (entity looking forwards as it moves)." },
|
||||
SetSpeed =
|
||||
{
|
||||
{ Params = "SpeedX, SpeedY, SpeedZ", Return = "", Notes = "Sets the current speed of the entity" },
|
||||
@@ -882,18 +908,20 @@ end</pre>
|
||||
Constants =
|
||||
{
|
||||
etBoat = { Notes = "The entity is a {{cBoat}}" },
|
||||
etEnderCrystal = { Notes = "" },
|
||||
etEntity = { Notes = "No further specialization available" },
|
||||
etExpOrb = { Notes = "The entity is a {{cExpOrb}}" },
|
||||
etFallingBlock = { Notes = "The entity is a {{cFallingBlock}}" },
|
||||
etFloater = { Notes = "The entity is a fishing rod floater" },
|
||||
etItemFrame = { Notes = "" },
|
||||
etMinecart = { Notes = "The entity is a {{cMinecart}} descendant" },
|
||||
etMob = { Notes = "The entity is a {{cMonster}} descendant" },
|
||||
etMonster = { Notes = "The entity is a {{cMonster}} descendant" },
|
||||
etMinecart = { Notes = "The entity is a {{cMinecart}} descendant" },
|
||||
etPlayer = { Notes = "The entity is a {{cPlayer}}" },
|
||||
etPainting = { Notes = "The entity is a {{cPainting}}" },
|
||||
etPickup = { Notes = "The entity is a {{cPickup}}" },
|
||||
etPlayer = { Notes = "The entity is a {{cPlayer}}" },
|
||||
etProjectile = { Notes = "The entity is a {{cProjectileEntity}} descendant" },
|
||||
etTNT = { Notes = "The entity is a {{cTNTEntity}}" },
|
||||
etPainting = { Notes = "The entity is a {{cPainting}}" },
|
||||
},
|
||||
ConstantGroups =
|
||||
{
|
||||
@@ -1043,6 +1071,7 @@ ValueName0=SomeOtherValue
|
||||
GetValueSetB = { Params = "KeyName, ValueName, Default", Return = "bool", Notes = "Returns the value of the specified name under the specified key, as a bool. If the value doesn't exist, creates it with the specified default." },
|
||||
GetValueSetF = { Params = "KeyName, ValueName, Default", Return = "number", Notes = "Returns the value of the specified name under the specified key, as a floating-point number. If the value doesn't exist, creates it with the specified default." },
|
||||
GetValueSetI = { Params = "KeyName, ValueName, Default", Return = "number", Notes = "Returns the value of the specified name under the specified key, as an integer. If the value doesn't exist, creates it with the specified default." },
|
||||
HasValue = { Params = "KeyName, ValueName", Return = "bool", Notes = "Returns true if the specified value is present." },
|
||||
ReadFile = { Params = "FileName, [AllowExampleFallback]", Return = "bool", Notes = "Reads the values from the specified file. Previous in-memory contents are lost. If the file cannot be opened, and AllowExample is true, another file, \"filename.example.ini\", is loaded and then saved as \"filename.ini\". Returns true if successful, false if not." },
|
||||
SetValue =
|
||||
{
|
||||
@@ -1740,6 +1769,7 @@ a_Player:OpenWindow(Window);
|
||||
GetItem = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item represented by this pickup" },
|
||||
IsCollected = { Params = "", Return = "bool", Notes = "Returns true if this pickup has already been collected (is waiting to be destroyed)" },
|
||||
IsPlayerCreated = { Params = "", Return = "bool", Notes = "Returns true if the pickup was created by a player" },
|
||||
SetAge = { Params = "AgeTicks", Return = "", Notes = "Sets the pickup's age, in ticks." },
|
||||
},
|
||||
Inherits = "cEntity",
|
||||
}, -- cPickup
|
||||
@@ -1764,8 +1794,8 @@ a_Player:OpenWindow(Window);
|
||||
ForceSetSpeed = { Params = "{{Vector3d|Direction}}", Notes = "Forces the player to move to the given direction." },
|
||||
GetClientHandle = { Params = "", Return = "{{cClientHandle}}", Notes = "Returns the client handle representing the player's connection. May be nil (AI players)." },
|
||||
GetColor = { Return = "string", Notes = "Returns the full color code to be used for this player's messages (based on their rank). Prefix player messages with this code." },
|
||||
GetPlayerListName = { Return = "string", Notes = "Returns the name that is used in the playerlist." },
|
||||
GetCurrentXp = { Params = "", Return = "number", Notes = "Returns the current amount of XP" },
|
||||
GetCustomName = { Params = "", Return = "string", Notes = "Returns the custom name of this player. If the player hasn't a custom name, it will return an empty string." },
|
||||
GetEffectiveGameMode = { Params = "", Return = "{{Globals#GameMode|GameMode}}", Notes = "(OBSOLETE) Returns the current resolved game mode of the player. If the player is set to inherit the world's gamemode, returns that instead. See also GetGameMode() and IsGameModeXXX() functions. Note that this function is the same as GetGameMode(), use that function instead." },
|
||||
GetEquippedItem = { Params = "", Return = "{{cItem}}", Notes = "Returns the item that the player is currently holding; empty item if holding nothing." },
|
||||
GetEyeHeight = { Return = "number", Notes = "Returns the height of the player's eyes, in absolute coords" },
|
||||
@@ -1780,18 +1810,24 @@ a_Player:OpenWindow(Window);
|
||||
GetGameMode = { Return = "{{Globals#GameMode|GameMode}}", Notes = "Returns the player's gamemode. The player may have their gamemode unassigned, in which case they inherit the gamemode from the current {{cWorld|world}}.<br /> <b>NOTE:</b> Instead of comparing the value returned by this function to the gmXXX constants, use the IsGameModeXXX() functions. These functions handle the gamemode inheritance automatically."},
|
||||
GetIP = { Return = "string", Notes = "Returns the IP address of the player, if available. Returns an empty string if there's no IP to report."},
|
||||
GetInventory = { Return = "{{cInventory|Inventory}}", Notes = "Returns the player's inventory"},
|
||||
GetLastBedPos = { Params = "", Return = "{{Vector3i}}", Notes = "Returns the position of the last bed the player has slept in, or the world's spawn if no such position was recorded." },
|
||||
GetMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's current maximum speed, relative to the game default speed. Takes into account the sprinting / flying status." },
|
||||
GetName = { Return = "string", Notes = "Returns the player's name" },
|
||||
GetNormalMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's maximum walking speed, relative to the game default speed. Defaults to 1, but plugins may modify it for faster or slower walking." },
|
||||
GetPermissions = { Params = "", Return = "array-table of strings", Notes = "Returns the list of all permissions that the player has assigned to them through their rank." },
|
||||
GetPlayerListName = { Return = "string", Notes = "Returns the name that is used in the playerlist." },
|
||||
GetResolvedPermissions = { Return = "array-table of string", Notes = "Returns all the player's permissions, as a table. The permissions are stored in the array part of the table, beginning with index 1." },
|
||||
GetSprintingMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's maximum sprinting speed, relative to the game default speed. Defaults to 1.3, but plugins may modify it for faster or slower sprinting." },
|
||||
GetStance = { Return = "number", Notes = "Returns the player's stance (Y-pos of player's eyes)" },
|
||||
GetTeam = { Params = "", Return = "{{cTeam}}", Notes = "Returns the team that the player belongs to, or nil if none." },
|
||||
GetThrowSpeed = { Params = "SpeedCoeff", Return = "{{Vector3d}}", Notes = "Returns the speed vector for an object thrown with the specified speed coeff. Basically returns the normalized look vector multiplied by the coeff, with a slight random variation." },
|
||||
GetThrowStartPos = { Params = "", Return = "{{Vector3d}}", Notes = "Returns the position where the projectiles should start when thrown by this player." },
|
||||
GetUUID = { Params = "", Return = "string", Notes = "Returns the (short) UUID that the player is using. Could be empty string for players that don't have a Mojang account assigned to them (in the future, bots for example)." },
|
||||
GetWindow = { Params = "", Return = "{{cWindow}}", Notes = "Returns the currently open UI window. If the player doesn't have any UI window open, returns the inventory window." },
|
||||
GetXpLevel = { Params = "", Return = "number", Notes = "Returns the current XP level (based on current XP amount)." },
|
||||
GetXpLifetimeTotal = { Params = "", Return = "number", Notes = "Returns the amount of XP that has been accumulated throughout the player's lifetime." },
|
||||
GetXpPercentage = { Params = "", Return = "number", Notes = "Returns the percentage of the experience bar - the amount of XP towards the next XP level. Between 0 and 1." },
|
||||
HasCustomName = { Params = "", Return = "bool", Notes = "Returns true if the player has a custom name." },
|
||||
HasPermission = { Params = "PermissionString", Return = "bool", Notes = "Returns true if the player has the specified permission" },
|
||||
Heal = { Params = "HitPoints", Return = "", Notes = "Heals the player by the specified amount of HPs. Only positive amounts are expected. Sends a health update to the client." },
|
||||
IsEating = { Params = "", Return = "bool", Notes = "Returns true if the player is currently eating the item in their hand." },
|
||||
@@ -1799,7 +1835,9 @@ a_Player:OpenWindow(Window);
|
||||
IsFlying = { Return = "bool", Notes = "Returns true if the player is flying." },
|
||||
IsGameModeAdventure = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmAdventure gamemode, or has their gamemode unset and the world is a gmAdventure world." },
|
||||
IsGameModeCreative = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmCreative gamemode, or has their gamemode unset and the world is a gmCreative world." },
|
||||
IsGameModeSpectator = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmSpectator gamemode, or has their gamemode unset and the world is a gmSpectator world." },
|
||||
IsGameModeSurvival = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmSurvival gamemode, or has their gamemode unset and the world is a gmSurvival world." },
|
||||
IsInBed = { Params = "", Return = "bool", Notes = "Returns true if the player is currently lying in a bed." },
|
||||
IsOnGround = { Params = "", Return = "bool", Notes = "Returns true if the player is on ground (not falling, not jumping, not flying)" },
|
||||
IsSatiated = { Params = "", Return = "bool", Notes = "Returns true if the player is satiated (cannot eat)." },
|
||||
IsVisible = { Params = "", Return = "bool", Notes = "Returns true if the player is visible to other players" },
|
||||
@@ -1807,6 +1845,7 @@ a_Player:OpenWindow(Window);
|
||||
MoveTo = { Params = "{{Vector3d|NewPosition}}", Return = "Tries to move the player into the specified position." },
|
||||
MoveToWorld = { Params = "WorldName", Return = "bool", Return = "Moves the player to the specified world. Returns true if successful." },
|
||||
OpenWindow = { Params = "{{cWindow|Window}}", Return = "", Notes = "Opens the specified UI window for the player." },
|
||||
PermissionMatches = { Params = "Permission, Template", Return = "bool", Notes = "(STATIC) Returns true if the specified permission matches the specified template. The template may contain wildcards." },
|
||||
Respawn = { Params = "", Return = "", Notes = "Restores the health, extinguishes fire, makes visible and sends the Respawn packet." },
|
||||
SendMessage = { Params = "Message", Return = "", Notes = "Sends the specified message to the player." },
|
||||
SendMessageFailure = { Params = "Message", Return = "", Notes = "Prepends Rose [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and sends message to player. For a command that failed to run because of insufficient permissions, etc." },
|
||||
@@ -1815,12 +1854,12 @@ a_Player:OpenWindow(Window);
|
||||
SendMessagePrivateMsg = { Params = "Message, SenderName", Return = "", Notes = "Prepends Light Blue [MSG: *SenderName*] / prepends SenderName and colours entire text (depending on ShouldUseChatPrefixes()) and sends message to player. For private messaging." },
|
||||
SendMessageSuccess = { Params = "Message", Return = "", Notes = "Prepends Green [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and sends message to player. Success notification." },
|
||||
SendMessageWarning = { Params = "Message, Sender", Return = "", Notes = "Prepends Rose [WARN] / colours entire text (depending on ShouldUseChatPrefixes()) and sends message to player. Denotes that something concerning, such as plugin reload, is about to happen." },
|
||||
HasCustomName = { Params = "", Return = "bool", Notes = "Returns true if the player has a custom name." },
|
||||
GetCustomName = { Params = "", Return = "string", Notes = "Returns the custom name of this player. If the player hasn't a custom name, it will return an empty string." },
|
||||
SetCustomName = { Params = "string", Return = "", Notes = "Sets the custom name of this player. If you want to disable the custom name, simply set an empty string. The custom name will be used in the tab-list, in the player nametag and in the tab-completion." },
|
||||
SendRotation = { Params = "YawDegrees, PitchDegrees", Return = "", Notes = "Sends the specified rotation to the player, forcing them to look that way" },
|
||||
SetBedPos = { Params = "{{Vector3i|Position}}", Return = "", Notes = "Sets the internal representation of the last bed position the player has slept in. The player will respawn at this position if they die." },
|
||||
SetCanFly = { Params = "CanFly", Notes = "Sets if the player can fly or not." },
|
||||
SetCrouch = { Params = "IsCrouched", Return = "", Notes = "Sets the crouch state, broadcasts the change to other players." },
|
||||
SetCurrentExperience = { Params = "XPAmount", Return = "", Notes = "Sets the current amount of experience (and indirectly, the XP level)." },
|
||||
SetCustomName = { Params = "string", Return = "", Notes = "Sets the custom name of this player. If you want to disable the custom name, simply set an empty string. The custom name will be used in the tab-list, in the player nametag and in the tab-completion." },
|
||||
SetFlying = { Params = "IsFlying", Notes = "Sets if the player is flying or not." },
|
||||
SetFlyingMaxSpeed = { Params = "FlyingMaxSpeed", Return = "", Notes = "Sets the flying maximum speed, relative to the game default speed. The default value is 1. Sends the updated speed to the client." },
|
||||
SetFoodExhaustionLevel = { Params = "ExhaustionLevel", Return = "", Notes = "Sets the food exhaustion to the specified level." },
|
||||
@@ -1834,7 +1873,11 @@ a_Player:OpenWindow(Window);
|
||||
SetNormalMaxSpeed = { Params = "NormalMaxSpeed", Return = "", Notes = "Sets the normal (walking) maximum speed, relative to the game default speed. The default value is 1. Sends the updated speed to the client, if appropriate." },
|
||||
SetSprint = { Params = "IsSprinting", Return = "", Notes = "Sets whether the player is sprinting or not." },
|
||||
SetSprintingMaxSpeed = { Params = "SprintingMaxSpeed", Return = "", Notes = "Sets the sprinting maximum speed, relative to the game default speed. The default value is 1.3. Sends the updated speed to the client, if appropriate." },
|
||||
SetTeam = { Params = "{{cTeam|Team}}", Return = "", Notes = "Moves the player to the specified team." },
|
||||
SetVisible = { Params = "IsVisible", Return = "", Notes = "Sets the player visibility to other players" },
|
||||
TossEquippedItem = { Params = "[Amount]", Return = "", Notes = "Tosses the item that the player has selected in their hotbar. Amount defaults to 1." },
|
||||
TossHeldItem = { Params = "[Amount]", Return = "", Notes = "Tosses the item held by the cursor, then the player is in a UI window. Amount defaults to 1." },
|
||||
TossPickup = { Params = "{{cItem|Item}}", Return = "", Notes = "Tosses a pickup newly created from the specified item." },
|
||||
XpForLevel = { Params = "XPLevel", Return = "number", Notes = "(STATIC) Returns the total amount of XP needed for the specified XP level. Inverse of CalcLevelFromXp()." },
|
||||
},
|
||||
Constants =
|
||||
@@ -1984,6 +2027,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
|
||||
HOOK_PLAYER_USING_ITEM = { Notes = "Called when the player is about to right-click with a usable item in their hand." },
|
||||
HOOK_POST_CRAFTING = { Notes = "Called after a valid recipe has been chosen for the current contents of the crafting grid. Plugins may modify the recipe." },
|
||||
HOOK_PRE_CRAFTING = { Notes = "Called before a recipe is searched for the current contents of the crafting grid. Plugins may provide a recipe and cancel the built-in search." },
|
||||
HOOK_SERVER_PING = { Notes = "Called when a client pings the server from the server list. Plugins may change the favicon, server description, players online and maximum players values." },
|
||||
HOOK_SPAWNED_ENTITY = { Notes = "Called after an entity is spawned in a {{cWorld|world}}. The entity is already part of the world." },
|
||||
HOOK_SPAWNED_MONSTER = { Notes = "Called after a mob is spawned in a {{cWorld|world}}. The mob is already part of the world." },
|
||||
HOOK_SPAWNING_ENTITY = { Notes = "Called just before an entity is spawned in a {{cWorld|world}}." },
|
||||
@@ -2033,8 +2077,10 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
|
||||
AddGroupToRank = { Params = "GroupName, RankName", Return = "bool", Notes = "Adds the specified group to the specified rank. Returns true on success, false on failure - if the group name or the rank name is not found." },
|
||||
AddPermissionToGroup = { Params = "Permission, GroupName", Return = "bool", Notes = "Adds the specified permission to the specified group. Returns true on success, false on failure - if the group name is not found." },
|
||||
AddRank = { Params = "RankName, MsgPrefix, MsgSuffix, MsgNameColorCode", Return = "", Notes = "Adds a new rank of the specified name and with the specified message visuals. Logs an info message and does nothing if the rank already exists." },
|
||||
ClearPlayerRanks = { Params = "", Return = "", Notes = "Removes all player ranks from the database. Note that this doesn't change the cPlayer instances for the already connected players, you need to update all the instances manually." },
|
||||
GetAllGroups = { Params = "", Return = "array-table of groups' names", Notes = "Returns an array-table containing the names of all the groups that are known to the manager." },
|
||||
GetAllPermissions = { Params = "", Return = "array-table of permissions", Notes = "Returns an array-table containing all the permissions that are known to the manager." },
|
||||
GetAllPlayerUUIDs = { Params = "", Return = "array-table of uuids", Notes = "Returns the short uuids of all players stored in the rank DB, sorted by the players' names (case insensitive)." },
|
||||
GetAllRanks = { Params = "", Return = "array-table of ranks' names", Notes = "Returns an array-table containing the names of all the ranks that are known to the manager." },
|
||||
GetDefaultRank = { Params = "", Return = "string", Notes = "Returns the name of the default rank. " },
|
||||
GetGroupPermissions = { Params = "GroupName", Return = "array-table of permissions", Notes = "Returns an array-table containing the permissions that the specified group contains." },
|
||||
@@ -2042,6 +2088,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
|
||||
GetPlayerMsgVisuals = { Params = "PlayerUUID", Return = "MsgPrefix, MsgSuffix, MsgNameColorCode", Notes = "Returns the message visuals assigned to the player. If the player is not explicitly assigned a rank, the default rank's visuals are returned. If there is an error, no value is returned at all." },
|
||||
GetPlayerPermissions = { Params = "PlayerUUID", Return = "array-table of permissions", Notes = "Returns the permissions that the specified player is assigned through their rank. Returns the default rank's permissions if the player has no explicit rank assigned to them. Returns an empty array on error." },
|
||||
GetPlayerRankName = { Params = "PlayerUUID", Return = "RankName", Notes = "Returns the name of the rank that is assigned to the specified player. An empty string (NOT the default rank) is returned if the player has no rank assigned to them." },
|
||||
GetPlayerName = { Params = "PlayerUUID", Return = "PlayerName", Notes = "Returns the last name that the specified player has, for a player in the ranks database. An empty string is returned if the player isn't in the database." },
|
||||
GetRankGroups = { Params = "RankName", Return = "array-table of groups' names", Notes = "Returns an array-table of the names of all the groups that are assigned to the specified rank. Returns an empty table if there is no such rank." },
|
||||
GetRankPermissions = { Params = "RankName", Return = "array-table of permissions", Notes = "Returns an array-table of all the permissions that are assigned to the specified rank through its groups. Returns an empty table if there is no such rank." },
|
||||
GetRankVisuals = { Params = "RankName", Return = "MsgPrefix, MsgSuffix, MsgNameColorCode", Notes = "Returns the message visuals for the specified rank. Returns no value if the specified rank does not exist." },
|
||||
@@ -2076,14 +2123,22 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
BroadcastChat = { Params = "Message", Return = "", Notes = "Broadcasts a message to every player in the server. No formatting is done by the server." },
|
||||
BroadcastChatFailure = { Params = "Message", Return = "", Notes = "Prepends Rose [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For a command that failed to run because of insufficient permissions, etc." },
|
||||
BroadcastChatFatal = { Params = "Message", Return = "", Notes = "Prepends Red [FATAL] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For a plugin that crashed, or similar." },
|
||||
BroadcastChatInfo = { Params = "Message", Return = "", Notes = "Prepends Yellow [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For informational messages, such as command usage." },
|
||||
BroadcastChatSuccess = { Params = "Message", Return = "", Notes = "Prepends Green [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For success messages." },
|
||||
BroadcastChatWarning = { Params = "Message", Return = "", Notes = "Prepends Rose [WARN] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For concerning events, such as plugin reload etc." },
|
||||
CreateAndInitializeWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Creates a new world and initializes it. If there is a world whith the same name it returns nil." },
|
||||
BroadcastChat =
|
||||
{
|
||||
{ Params = "MessageText, MessageType", Return = "", Notes = "Broadcasts a message to all players, with its message type set to MessageType (default: mtCustom)." },
|
||||
{ Params = "{{cCompositeChat|CompositeChat}}", Return = "", Notes = "Broadcasts a {{cCompositeChat|composite chat message} to all players." },
|
||||
},
|
||||
BroadcastChatDeath = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtDeath. Use for when a player has died." },
|
||||
BroadcastChatFailure = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtFailure. Use for a command that failed to run because of insufficient permissions, etc." },
|
||||
BroadcastChatFatal = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtFatal. Use for a plugin that crashed, or similar." },
|
||||
BroadcastChatInfo = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtInfo. Use for informational messages, such as command usage." },
|
||||
BroadcastChatJoin = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtJoin. Use for players joining the server." },
|
||||
BroadcastChatLeave = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtLeave. Use for players leaving the server." },
|
||||
BroadcastChatSuccess = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtSuccess. Use for success messages." },
|
||||
BroadcastChatWarning = { Params = "MessageText", Return = "", Notes = "Broadcasts the specified message to all players, with its message type set to mtWarning. Use for concerning events, such as plugin reload etc." },
|
||||
CreateAndInitializeWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Creates a new world and initializes it. If there is a world whith the same name it returns nil.<br/><br/><b>NOTE</b>This function is currently unsafe, do not use!" },
|
||||
FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for all players with names partially (or fully) matching the name string provided." },
|
||||
DoWithPlayerByUUID = { Params = "PlayerUUID, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is the player with the uuid, calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|Player}}, [CallbackData])</pre> The function returns false if the player was not found, or whatever bool value the callback returned if the player was found." },
|
||||
ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|cPlayer}})</pre>" },
|
||||
ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world. The callback function has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cWorld|cWorld}})</pre>" },
|
||||
Get = { Params = "", Return = "Root object", Notes = "(STATIC)This function returns the cRoot object." },
|
||||
@@ -2353,6 +2408,7 @@ end
|
||||
{ Params = "{{Vector3i|BlockCoords}}, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!" },
|
||||
},
|
||||
FindAndDoWithPlayer = { Params = "PlayerNameHint, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of a name similar to the specified name (weighted-match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|Player}}, [CallbackData])</pre> The function returns false if the player was not found, or whatever bool value the callback returned if the player was found. Note that the name matching is very loose, so it is a good idea to check the player name in the callback function." },
|
||||
DoWithPlayerByUUID = { Params = "PlayerUUID, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is the player with the uuid, calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cPlayer|Player}}, [CallbackData])</pre> The function returns false if the player was not found, or whatever bool value the callback returned if the player was found." },
|
||||
ForEachBlockEntityInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each block entity in the chunk. Returns true if all block entities in the chunk have been processed (including when there are zero block entities), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cBlockEntity|BlockEntity}}, [CallbackData])</pre> The callback should return false or no value to continue with the next block entity, or true to abort the enumeration. Use {{tolua}}.cast() to cast the Callback's BlockEntity parameter to the correct {{cBlockEntity}} descendant." },
|
||||
ForEachChestInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each chest in the chunk. Returns true if all chests in the chunk have been processed (including when there are zero chests), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cChestEntity|ChestEntity}}, [CallbackData])</pre> The callback should return false or no value to continue with the next chest, or true to abort the enumeration." },
|
||||
ForEachEntity = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the loaded world. Returns true if all the entities have been processed (including when there are zero entities), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature: <pre class=\"prettyprint lang-lua\">function Callback({{cEntity|Entity}}, [CallbackData])</pre> The callback should return false or no value to continue with the next entity, or true to abort the enumeration." },
|
||||
@@ -2444,7 +2500,7 @@ end
|
||||
SetCommandBlocksEnabled = { Params = "IsEnabled (bool)", Return = "", Notes = "Sets whether command blocks should be enabled on the (entire) server." },
|
||||
SetShouldUseChatPrefixes = { Params = "", Return = "ShouldUse (bool)", Notes = "Sets whether coloured chat prefixes such as [INFO] is used with the SendMessageXXX() or BroadcastChatXXX(), or simply the entire message is coloured in the respective colour." },
|
||||
ShouldUseChatPrefixes = { Params = "", Return = "bool", Notes = "Returns whether coloured chat prefixes are prepended to chat messages or the entire message is simply coloured." },
|
||||
SetSignLines = { Params = "X, Y, Z, Line1, Line2, Line3, Line4, [{{cPlayer|Player}}]", Return = "", Notes = "Sets the sign text at the specified coords. The sign-updating hooks are called for the change. The Player parameter is used to indicate the player from whom the change has come, it may be nil. Same as UpdateSign()." },
|
||||
SetSignLines = { Params = "X, Y, Z, Line1, Line2, Line3, Line4, [{{cPlayer|Player}}]", Return = "", Notes = "Sets the sign text at the specified coords. The sign-updating hooks are called for the change. The Player parameter is used to indicate the player from whom the change has come, it may be nil." },
|
||||
SetTicksUntilWeatherChange = { Params = "NumTicks", Return = "", Notes = "Sets the number of ticks after which the weather will be changed." },
|
||||
SetTimeOfDay = { Params = "TimeOfDayTicks", Return = "", Notes = "Sets the time of day, expressed as number of ticks past sunrise, in the range 0 .. 24000." },
|
||||
SetWeather = { Params = "Weather", Return = "", Notes = "Sets the current weather (wSunny, wRain, wStorm) and resets the TicksUntilWeatherChange to the default value for the new weather. The normal weather-changing hooks are called for the change." },
|
||||
@@ -2459,7 +2515,7 @@ end
|
||||
SpawnExperienceOrb = { Params = "X, Y, Z, Reward", Return = "EntityID", Notes = "Spawns an {{cExpOrb|experience orb}} at the specified coords, with the given reward" },
|
||||
SpawnPrimedTNT = { Params = "X, Y, Z, FuseTicks, InitialVelocityCoeff", Return = "", Notes = "Spawns a {{cTNTEntity|primed TNT entity}} at the specified coords, with the given fuse ticks. The entity gets a random speed multiplied by the InitialVelocityCoeff, 1 being the default value." },
|
||||
TryGetHeight = { Params = "BlockX, BlockZ", Return = "IsValid, Height", Notes = "Returns true and height of the highest non-air block if the chunk is loaded, or false otherwise." },
|
||||
UpdateSign = { Params = "X, Y, Z, Line1, Line2, Line3, Line4, [{{cPlayer|Player}}]", Return = "", Notes = "Sets the sign text at the specified coords. The sign-updating hooks are called for the change. The Player parameter is used to indicate the player from whom the change has come, it may be nil. Same as SetSignLiens()" },
|
||||
UpdateSign = { Params = "X, Y, Z, Line1, Line2, Line3, Line4, [{{cPlayer|Player}}]", Return = "", Notes = "(<b>DEPRECATED</b>) Please use SetSignLines()." },
|
||||
UseBlockEntity = { Params = "{{cPlayer|Player}}, BlockX, BlockY, BlockZ", Return = "", Notes = "Makes the specified Player use the block entity at the specified coords (open chest UI, etc.) If the cords are in an unloaded chunk or there's no block entity, ignores the call." },
|
||||
WakeUpSimulators = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Wakes up the simulators for the specified block." },
|
||||
WakeUpSimulatorsInArea = { Params = "MinBlockX, MaxBlockX, MinBlockY, MaxBlockY, MinBlockZ, MaxBlockZ", Return = "", Notes = "Wakes up the simulators for all the blocks in the specified area (edges inclusive)." },
|
||||
@@ -2814,7 +2870,7 @@ end
|
||||
Globals =
|
||||
{
|
||||
Desc = [[
|
||||
These functions are available directly, without a class instance. Any plugin cal call them at any
|
||||
These functions are available directly, without a class instance. Any plugin can call them at any
|
||||
time.
|
||||
]],
|
||||
Functions =
|
||||
|
||||
@@ -35,12 +35,49 @@ return
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cArrowEntity
|
||||
|
||||
cExpBottleEntity =
|
||||
{
|
||||
Desc = [[
|
||||
Represents a thrown ExpBottle. A subclass of the {{cProjectileEntity}}.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cExpBottleEntity
|
||||
|
||||
cFireChargeEntity =
|
||||
{
|
||||
Desc = [[
|
||||
Represents a fire charge that has been shot by a Blaze or a {{cDispenserEntity|Dispenser}}. A subclass
|
||||
of the {{cProjectileEntity}}.
|
||||
]],
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cFireChargeEntity
|
||||
|
||||
cFireworkEntity =
|
||||
{
|
||||
Desc = [[
|
||||
Represents a firework rocket.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
GetItem = { Params = "", Return = "{{cItem}}", Notes = "Returns the item that has been used to create the firework rocket. The item's m_FireworkItem member contains all the firework-related data." },
|
||||
GetTicksToExplosion = { Params = "", Return = "number", Notes = "Returns the number of ticks left until the firework explodes." },
|
||||
SetItem = { Params = "{{cItem}}", Return = "", Notes = "Sets a new item to be used for the firework." },
|
||||
SetTicksToExplosion = { Params = "NumTicks", Return = "", Notes = "Sets the number of ticks left until the firework explodes." },
|
||||
},
|
||||
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cFireworkEntity
|
||||
|
||||
cFloater =
|
||||
{
|
||||
Desc = "",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cFireChargeEntity
|
||||
}, -- cFloater
|
||||
|
||||
cGhastFireballEntity =
|
||||
{
|
||||
@@ -64,14 +101,14 @@ return
|
||||
pkArrow = { Notes = "The projectile is an {{cArrowEntity|arrow}}" },
|
||||
pkEgg = { Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}" },
|
||||
pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" },
|
||||
pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" },
|
||||
pkExpBottle = { Notes = "The projectile is a {{cExpBottleEntity|thrown exp bottle}}" },
|
||||
pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" },
|
||||
pkFirework = { Notes = "The projectile is a (flying) firework (NYI)" },
|
||||
pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" },
|
||||
pkFirework = { Notes = "The projectile is a (flying) {{cFireworkEntity|firework}}" },
|
||||
pkFishingFloat = { Notes = "The projectile is a {{cFloater|fishing float}}" },
|
||||
pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" },
|
||||
pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" },
|
||||
pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" },
|
||||
pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" },
|
||||
pkSplashPotion = { Notes = "The projectile is a {{cSplashPotionEntity|thrown splash potion}}" },
|
||||
pkWitherSkull = { Notes = "The projectile is a {{cWitherSkullEntity|wither skull}}" },
|
||||
},
|
||||
ConstantGroups =
|
||||
{
|
||||
@@ -84,26 +121,52 @@ return
|
||||
Inherits = "cEntity",
|
||||
}, -- cProjectileEntity
|
||||
|
||||
cSplashPotionEntity =
|
||||
{
|
||||
Desc = [[
|
||||
Represents a thrown splash potion.
|
||||
]],
|
||||
Functions =
|
||||
{
|
||||
GetEntityEffect = { Params = "", Return = "{{cEntityEffect}}", Notes = "Returns the entity effect in this potion" },
|
||||
GetEntityEffectType = { Params = "", Return = "{{cEntityEffect|Entity effect type}}", Notes = "Returns the effect type of this potion" },
|
||||
GetPotionColor = { Params = "", Return = "number", Notes = "Returns the color index of the particles emitted by this potion" },
|
||||
SetEntityEffect = { Params = "{{cEntityEffect}}", Return = "", Notes = "Sets the entity effect for this potion" },
|
||||
SetEntityEffectType = { Params = "{{cEntityEffect|Entity effect type}}", Return = "", Notes = "Sets the effect type of this potion" },
|
||||
SetPotionColor = { Params = "number", Return = "", Notes = "Sets the color index of the particles for this potion" },
|
||||
},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cSplashPotionEntity
|
||||
|
||||
cThrownEggEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Desc = [[
|
||||
Represents a thrown egg.
|
||||
]],
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cThrownEggEntity
|
||||
|
||||
cThrownEnderPearlEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Desc = "Represents a thrown ender pearl.",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cThrownEnderPearlEntity
|
||||
|
||||
|
||||
cThrownSnowballEntity =
|
||||
{
|
||||
Desc = "",
|
||||
Desc = "Represents a thrown snowball.",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cThrownSnowballEntity
|
||||
|
||||
cWitherSkullEntity =
|
||||
{
|
||||
Desc = "Represents a wither skull being shot.",
|
||||
Functions = {},
|
||||
Inherits = "cProjectileEntity",
|
||||
}, -- cWitherSkullEntity
|
||||
}
|
||||
|
||||
|
||||
|
||||
50
MCServer/Plugins/APIDump/Hooks/OnServerPing.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
return
|
||||
{
|
||||
HOOK_SERVER_PING =
|
||||
{
|
||||
CalledWhen = "Client pings the server from the server list.",
|
||||
DefaultFnName = "OnServerPing", -- also used as pagename
|
||||
Desc = [[
|
||||
A plugin may implement an OnServerPing() function and register it as a Hook to process pings from
|
||||
clients in the server server list. It can change the logged in players and player capacity, as well
|
||||
as the server description and the favicon, that are displayed to the client in the server list.
|
||||
]],
|
||||
Params = {
|
||||
{ Name = "ClientHandle", Type = "{{cClientHandle}}", Notes = "The client handle that pinged the server" },
|
||||
{ Name = "ServerDescription", Type = "string", Notes = "The server description" },
|
||||
{ Name = "OnlinePlayersCount", Type = "number", Notes = "The number of players currently on the server" },
|
||||
{ Name = "MaxPlayersCount", Type = "number", Notes = "The current player cap for the server" },
|
||||
{ Name = "Favicon", Type = "string", Notes = "The base64 encoded favicon to be displayed in the server list for compatible clients" },
|
||||
},
|
||||
Returns = [[
|
||||
The plugin can return whether to continue processing of the hook with other plugins, the server description to
|
||||
be displayed to the client, the currently online players, the player cap and the base64/png favicon data, in that order.
|
||||
]],
|
||||
CodeExamples = {
|
||||
{
|
||||
Title = "Change information returned to the player",
|
||||
Desc = "Tells the client that the server description is 'test', there are one more players online than there actually are, and that the player cap is zero. It also changes the favicon data.",
|
||||
Code = [[
|
||||
function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
|
||||
-- Change Server Description
|
||||
ServerDescription = "Test"
|
||||
|
||||
-- Change online / max players
|
||||
OnlinePlayers = OnlinePlayers + 1
|
||||
MaxPlayers = 0
|
||||
|
||||
-- Change favicon
|
||||
if cFile:IsFile("my-favicon.png") then
|
||||
local FaviconData = cFile:ReadWholeFile("my-favicon.png")
|
||||
if (FaviconData ~= "") and (FaviconData ~= nil) then
|
||||
Favicon = Base64Encode(FaviconData)
|
||||
end
|
||||
end
|
||||
|
||||
return false, ServerDescription, OnlinePlayers, MaxPlayers, Favicon
|
||||
end
|
||||
]],
|
||||
},
|
||||
},
|
||||
}, -- HOOK_SERVER_PING
|
||||
}
|
||||
1
MCServer/Plugins/ChatLog
Submodule
@@ -1,31 +0,0 @@
|
||||
|
||||
-- plugin.lua
|
||||
|
||||
-- Implements the main entrypoint for the plugin, as well as all the handling needed
|
||||
|
||||
-- ChatLog plugin logs all chat messages into the server log
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function Initialize(Plugin)
|
||||
Plugin:SetName("ChatLog")
|
||||
Plugin:SetVersion(3)
|
||||
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChat)
|
||||
|
||||
LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function OnChat(Player, Message)
|
||||
-- Lets get loggin'
|
||||
LOGINFO("[" .. Player:GetName() .. "]: " .. StripColorCodes(Message));
|
||||
|
||||
return false
|
||||
end
|
||||
1
MCServer/Plugins/ChunkWorx
Submodule
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<file>
|
||||
<filename>chunkworx_main.lua</filename>
|
||||
</file>
|
||||
<file>
|
||||
<filename>chunkworx_web.lua</filename>
|
||||
</file>
|
||||
</project>
|
||||
@@ -1,128 +0,0 @@
|
||||
-- Global variables
|
||||
PLUGIN = {} -- Reference to own plugin object
|
||||
GENERATION_STATE = 0
|
||||
OPERATION_CODE = 0 -- 0 = generation
|
||||
CX = 0
|
||||
CZ = 0
|
||||
CURRENT = 0
|
||||
TOTAL = 0
|
||||
|
||||
-- AREA Variables
|
||||
AreaStartX = -10
|
||||
AreaStartZ = -10
|
||||
AreaEndX = 10
|
||||
AreaEndZ = 10
|
||||
|
||||
-- RADIAL Variables
|
||||
RadialX = 0
|
||||
RadialZ = 0
|
||||
Radius = 10
|
||||
|
||||
-- WORLD
|
||||
WORK_WORLD = cRoot:Get():GetDefaultWorld():GetName()
|
||||
WW_instance = cRoot:Get():GetDefaultWorld()
|
||||
WORLDS = {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function Initialize(Plugin)
|
||||
PLUGIN = Plugin
|
||||
|
||||
PLUGIN:SetName("ChunkWorx")
|
||||
PLUGIN:SetVersion(6)
|
||||
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick)
|
||||
|
||||
Plugin:AddWebTab("(Re)Generation", HandleRequest_Generation)
|
||||
|
||||
GENERATION_STATE = 0
|
||||
WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
|
||||
if (WW_instance == nil) then
|
||||
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
|
||||
end
|
||||
|
||||
-- Read the stored values:
|
||||
local SettingsIni = cIniFile();
|
||||
SettingsIni:ReadFile("ChunkWorx.ini"); -- ignore any read errors
|
||||
AreaStartX = SettingsIni:GetValueSetI("Area data", "StartX", AreaStartX)
|
||||
AreaStartZ = SettingsIni:GetValueSetI("Area data", "StartZ", AreaStartZ)
|
||||
AreaEndX = SettingsIni:GetValueSetI("Area data", "EndX", AreaEndX)
|
||||
AreaEndZ = SettingsIni:GetValueSetI("Area data", "EndZ", AreaEndZ)
|
||||
RadialX = SettingsIni:GetValueSetI("Radial data", "RadialX", RadialX)
|
||||
RadialZ = SettingsIni:GetValueSetI("Radial data", "RadialZ", RadialZ)
|
||||
Radius = SettingsIni:GetValueSetI("Radial data", "Radius", Radius)
|
||||
SettingsIni:WriteFile("ChunkWorx.ini");
|
||||
|
||||
LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function OnTick( DeltaTime )
|
||||
if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then
|
||||
LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works STARTED!")
|
||||
LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": At world: " .. WORK_WORLD)
|
||||
WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
|
||||
if (GENERATION_STATE == 1) then GENERATION_STATE = 2 end
|
||||
if (GENERATION_STATE == 3) then GENERATION_STATE = 4 end
|
||||
|
||||
-- Changing in case coordinates are flipped
|
||||
local shifter = AreaEndX
|
||||
if (AreaStartX > AreaEndX) then
|
||||
AreaEndX = AreaStartX
|
||||
AreaStartX = shifter
|
||||
end
|
||||
shifter = AreaEndZ
|
||||
if (AreaStartZ > AreaEndZ) then
|
||||
AreaEndZ = AreaStartZ
|
||||
AreaStartZ = shifter
|
||||
end
|
||||
|
||||
CX = AreaStartX
|
||||
CZ = AreaStartZ
|
||||
CURRENT = 0
|
||||
|
||||
if (WW_instance == nil) then
|
||||
LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED")
|
||||
LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(")
|
||||
GENERATION_STATE = 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
if (GENERATION_STATE == 2 or GENERATION_STATE == 4) then
|
||||
if (WW_instance:GetGeneratorQueueLength() < 200
|
||||
and WW_instance:GetLightingQueueLength() < 200
|
||||
and (WW_instance:GetStorageSaveQueueLength() + WW_instance:GetStorageLoadQueueLength()) < 80) then
|
||||
local chunk_sum = (1+ AreaEndX - AreaStartX) * (1+ AreaEndZ - AreaStartZ)
|
||||
TOTAL = chunk_sum
|
||||
LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": PROCESSING 100 chunks, (" .. CURRENT .. "/" .. chunk_sum .. ")")
|
||||
for C = 1, 100 do
|
||||
if (GENERATION_STATE == 2) then WW_instance:GenerateChunk(CX, CZ) end
|
||||
if (GENERATION_STATE == 4) then WW_instance:RegenerateChunk(CX, CZ) end
|
||||
|
||||
CX = CX + 1
|
||||
CURRENT = CURRENT + 1
|
||||
if (CX > AreaEndX) then
|
||||
CX = AreaStartX
|
||||
CZ = CZ + 1
|
||||
if (CZ > AreaEndZ) then
|
||||
if (GENERATION_STATE == 2) then LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " - generation ENDED!") end
|
||||
if (GENERATION_STATE == 4) then LOGINFO("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " - REgeneration ENDED!") end
|
||||
|
||||
GENERATION_STATE = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
WW_instance:QueueSaveAllChunks()
|
||||
WW_instance:QueueUnloadUnusedChunks()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,274 +0,0 @@
|
||||
|
||||
-- chunkworx_web.lua
|
||||
|
||||
-- WebAdmin-related functions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local function Buttons_Player( Name )
|
||||
return "<form method='POST'><input type='hidden' name='PlayerName' value='"..Name.."'><input type='submit' name='PlayerExact' value='Exact'><input type='submit' name='Player3x3' value='3x3'></form>"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local function Button_World( Name )
|
||||
return "<form method='POST'><input type='hidden' name='WorldName' value='"..Name.."'><input type='submit' name='SelectWorld' value='Select'></form>"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local function SaveSettings()
|
||||
local SettingsIni = cIniFile()
|
||||
SettingsIni:SetValueI("Area data", "StartX", AreaStartX)
|
||||
SettingsIni:SetValueI("Area data", "StartZ", AreaStartZ)
|
||||
SettingsIni:SetValueI("Area data", "EndX", AreaEndX)
|
||||
SettingsIni:SetValueI("Area data", "EndZ", AreaEndZ)
|
||||
SettingsIni:SetValueI("Radial data", "RadialX", RadialX)
|
||||
SettingsIni:SetValueI("Radial data", "RadialZ", RadialZ)
|
||||
SettingsIni:SetValueI("Radial data", "Radius", Radius)
|
||||
SettingsIni:WriteFile("ChunkWorx.ini")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleRequest_Generation( Request )
|
||||
local Content = ""
|
||||
if (Request.PostParams["AGHRRRR"] ~= nil) then
|
||||
GENERATION_STATE = 0
|
||||
WW_instance:QueueSaveAllChunks()
|
||||
WW_instance:QueueUnloadUnusedChunks()
|
||||
LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED by admin")
|
||||
end
|
||||
--Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
|
||||
-- PROCESSING
|
||||
--------------------------------------------------------------------------------------------------
|
||||
local function ProcessingContent()
|
||||
local _small_content = ""
|
||||
_small_content = _small_content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
|
||||
_small_content = _small_content .. "<h4>World for operations:</h4>"..WORK_WORLD
|
||||
if (OPERATION_CODE == 0) then
|
||||
_small_content = _small_content .. "<h4>Operation:</h4>Generation"
|
||||
elseif (OPERATION_CODE == 1) then
|
||||
_small_content = _small_content .. "<h4>Operation:</h4>Regeneration"
|
||||
end
|
||||
_small_content = _small_content .. "<h4>Area: </h4>["..AreaStartX..":"..AreaStartZ.."] ["..AreaEndX..":"..AreaEndZ.."]"
|
||||
_small_content = _small_content .. "<h4>Progress:</h4>"..CURRENT.."/"..TOTAL
|
||||
_small_content = _small_content .. "<br>"
|
||||
_small_content = _small_content .. "<form method='POST'>"
|
||||
_small_content = _small_content .. "<input type='submit' name='AGHRRRR' value='Stop'>"
|
||||
_small_content = _small_content .. "</form>"
|
||||
return _small_content
|
||||
end
|
||||
if (GENERATION_STATE == 2 or GENERATION_STATE == 4) then
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
-- SELECTING
|
||||
--------------------------------------------------------------------------------------------------
|
||||
if ( Request.PostParams["FormSetWorld"] ) then
|
||||
WORK_WORLD = Request.PostParams["FormWorldName"]
|
||||
WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
|
||||
end
|
||||
|
||||
if( Request.PostParams["SelectWorld"] ~= nil
|
||||
and Request.PostParams["WorldName"] ~= nil ) then -- World is selected!
|
||||
WORK_WORLD = Request.PostParams["WorldName"]
|
||||
WW_instance = cRoot:Get():GetWorld(WORK_WORLD)
|
||||
end
|
||||
|
||||
if(Request.PostParams["OperationGenerate"] ~= nil) then
|
||||
OPERATION_CODE = 0
|
||||
end
|
||||
if(Request.PostParams["OperationReGenerate"] ~= nil) then
|
||||
OPERATION_CODE = 1
|
||||
end
|
||||
|
||||
if (GENERATION_STATE == 0) then
|
||||
if( Request.PostParams["FormAreaStartX"] ~= nil
|
||||
and Request.PostParams["FormAreaStartZ"] ~= nil
|
||||
and Request.PostParams["FormAreaEndX"] ~= nil
|
||||
and Request.PostParams["FormAreaEndZ"] ~= nil ) then --(Re)Generation valid!
|
||||
-- COMMON (Re)gen
|
||||
if( Request.PostParams["StartArea"]) then
|
||||
AreaStartX = tonumber(Request.PostParams["FormAreaStartX"])
|
||||
AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"])
|
||||
AreaEndX = tonumber(Request.PostParams["FormAreaEndX"])
|
||||
AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"])
|
||||
SaveSettings();
|
||||
if (OPERATION_CODE == 0) then
|
||||
GENERATION_STATE = 1
|
||||
elseif (OPERATION_CODE == 1) then
|
||||
GENERATION_STATE = 3
|
||||
end
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
end
|
||||
if( Request.PostParams["FormRadialX"] ~= nil
|
||||
and Request.PostParams["FormRadialZ"] ~= nil
|
||||
and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid!
|
||||
-- COMMON (Re)gen
|
||||
if( Request.PostParams["StartRadial"]) then
|
||||
RadialX = tonumber(Request.PostParams["FormRadialX"]) or 0
|
||||
RadialZ = tonumber(Request.PostParams["FormRadialZ"]) or 0
|
||||
Radius = tonumber(Request.PostParams["FormRadius"]) or 10
|
||||
AreaStartX = RadialX - Radius
|
||||
AreaStartZ = RadialZ - Radius
|
||||
AreaEndX = RadialX + Radius
|
||||
AreaEndZ = RadialZ + Radius
|
||||
SaveSettings()
|
||||
if (OPERATION_CODE == 0) then
|
||||
GENERATION_STATE = 1
|
||||
elseif (OPERATION_CODE == 1) then
|
||||
GENERATION_STATE = 3
|
||||
end
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
end
|
||||
-- POINT REGEN!
|
||||
if( Request.PostParams["FormPointX"] ~= nil
|
||||
and Request.PostParams["FormPointZ"] ~= nil ) then --ReGeneration valid!
|
||||
-- EXACT
|
||||
if ( Request.PostParams["PointExact"] ~= nil) then
|
||||
AreaStartX = tonumber(Request.PostParams["FormPointX"])
|
||||
AreaStartZ = tonumber(Request.PostParams["FormPointZ"])
|
||||
AreaEndX = AreaStartX
|
||||
AreaEndZ = AreaStartZ
|
||||
GENERATION_STATE = 3
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
-- 3x3
|
||||
if ( Request.PostParams["Point3x3"] ~= nil) then
|
||||
AreaStartX = tonumber(Request.PostParams["FormPointX"]) - 1
|
||||
AreaStartZ = tonumber(Request.PostParams["FormPointZ"]) - 1
|
||||
AreaEndX = AreaStartX + 2
|
||||
AreaEndZ = AreaStartZ + 2
|
||||
GENERATION_STATE = 3
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
end
|
||||
|
||||
local GetAreaByPlayer = function(Player)
|
||||
-- Player is valid only within this function, it cannot be stord and used later!
|
||||
AreaStartX = Player:GetChunkX()
|
||||
AreaStartZ = Player:GetChunkZ()
|
||||
end
|
||||
-- PLAYERS REGEN!
|
||||
if( Request.PostParams["PlayerExact"] ~= nil
|
||||
and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
|
||||
cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer)
|
||||
AreaEndX = AreaStartX
|
||||
AreaEndZ = AreaStartZ
|
||||
GENERATION_STATE = 3
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
if( Request.PostParams["Player3x3"] ~= nil
|
||||
and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate...
|
||||
cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer)
|
||||
AreaStartX = AreaStartX - 1
|
||||
AreaStartZ = AreaStartZ - 1
|
||||
AreaEndX = AreaStartX + 2
|
||||
AreaEndZ = AreaStartZ + 2
|
||||
GENERATION_STATE = 3
|
||||
Content = ProcessingContent()
|
||||
return Content
|
||||
end
|
||||
end
|
||||
|
||||
--Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>"
|
||||
--Content = Content .. "<form method='POST'>"
|
||||
--Content = Content .. "<input type='text' name='FormWorldName' value='Input world name here'><input type='submit' name='FormSetWorld' value='Set world'>"
|
||||
--Content = Content .. "</form>"
|
||||
|
||||
-- SELECTING WORK_WORLD
|
||||
Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>"
|
||||
Content = Content .. "<table>"
|
||||
local WorldNum = 0
|
||||
local AddWorldToTable = function(World)
|
||||
WorldNum = WorldNum + 1
|
||||
Content = Content .. "<tr>"
|
||||
Content = Content .. "<td style='width: 10px;'>" .. WorldNum .. ".</td>"
|
||||
Content = Content .. "<td>" .. World:GetName() .. "</td>"
|
||||
Content = Content .. "<td>" .. Button_World(World:GetName()) .. "</td>"
|
||||
Content = Content .. "</tr>"
|
||||
end
|
||||
cRoot:Get():ForEachWorld(AddWorldToTable)
|
||||
if( WorldNum == 0 ) then
|
||||
Content = Content .. "<tr><td>No worlds! O_O</td></tr>"
|
||||
end
|
||||
Content = Content .. "</table>"
|
||||
Content = Content .. "<br>"
|
||||
|
||||
-- SELECTING OPERATION
|
||||
if (OPERATION_CODE == 0) then
|
||||
Content = Content .. "<h4>Operation: Generation</h4>"
|
||||
elseif (OPERATION_CODE == 1) then
|
||||
Content = Content .. "<h4>Operation: Regeneration</h4>"
|
||||
end
|
||||
Content = Content .. "<form method='POST'>"
|
||||
Content = Content .. "<input type='submit' name='OperationGenerate' value='Generation'>"
|
||||
Content = Content .. "<input type='submit' name='OperationReGenerate' value='Regeneration'>"
|
||||
Content = Content .. "</form>"
|
||||
|
||||
-- SELECTING AREA
|
||||
Content = Content .. "<h4>Area: </h4>Start X, Start Z; End X, End Z"
|
||||
Content = Content .. "<form method='POST'>"
|
||||
Content = Content .. "<input type='text' name='FormAreaStartX' value='" .. AreaStartX .. "'><input type='text' name='FormAreaStartZ' value='" .. AreaStartZ .. "'>"
|
||||
Content = Content .. "<input type='text' name='FormAreaEndX' value='" .. AreaEndX .. "'><input type='text' name='FormAreaEndZ' value='" .. AreaEndZ .. "'>"
|
||||
Content = Content .. "<input type='submit' name='StartArea' value='Start'>"
|
||||
Content = Content .. "</form>"
|
||||
|
||||
-- SELECTING RADIAL
|
||||
Content = Content .. "<h4>Radial: </h4>Center X, Center Z, Radius"
|
||||
Content = Content .. "<form method='POST'>"
|
||||
Content = Content .. "<input type='text' name='FormRadialX' value='" .. RadialX .. "'><input type='text' name='FormRadialZ' value='" .. RadialZ .. "'><input type='text' name='FormRadius' value='" .. Radius .. "'>"
|
||||
Content = Content .. "<input type='submit' name='StartRadial' value='Start'>"
|
||||
Content = Content .. "</form>"
|
||||
Content = Content .. "<br>"
|
||||
Content = Content .. "<br>"
|
||||
Content = Content .. "<br>"
|
||||
|
||||
-- SELECTING POINT
|
||||
Content = Content .. "<h4>Point regeneration:</h4> X, Z"
|
||||
Content = Content .. "<form method='POST'>"
|
||||
Content = Content .. "<input type='text' name='FormPointX' value='0'><input type='text' name='FormPointZ' value='0'>"
|
||||
Content = Content .. "<input type='submit' name='PointExact' value='Exact'>"
|
||||
Content = Content .. "<input type='submit' name='Point3x3' value='3x3'>"
|
||||
Content = Content .. "</form>"
|
||||
|
||||
-- SELECTING PLAYERS
|
||||
Content = Content .. "<h4>Player-based regeneration:</h4>"
|
||||
Content = Content .. "<table>"
|
||||
local PlayerNum = 0
|
||||
local AddPlayerToTable = function( Player )
|
||||
PlayerNum = PlayerNum + 1
|
||||
Content = Content .. "<tr>"
|
||||
Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
|
||||
Content = Content .. "<td>" .. Player:GetName() .. "</td>"
|
||||
Content = Content .. "<td>" .. Buttons_Player(Player:GetName()) .. "</td>"
|
||||
Content = Content .. "</tr>"
|
||||
end
|
||||
if (cRoot:Get():GetWorld(WORK_WORLD) == nil) then
|
||||
Content = Content .. "<tr><td>Incorrect world selection</td></tr>"
|
||||
else
|
||||
cRoot:Get():GetWorld(WORK_WORLD):ForEachPlayer( AddPlayerToTable )
|
||||
if( PlayerNum == 0 ) then
|
||||
Content = Content .. "<tr><td>No connected players</td></tr>"
|
||||
end
|
||||
end
|
||||
Content = Content .. "</table>"
|
||||
Content = Content .. "<br>"
|
||||
return Content
|
||||
end
|
||||
@@ -10,9 +10,6 @@ g_ShowFoodStats = false; -- When true, each player's food stats are sent to the
|
||||
|
||||
|
||||
function Initialize(Plugin)
|
||||
Plugin:SetName("Debuggers")
|
||||
Plugin:SetVersion(1)
|
||||
|
||||
--[[
|
||||
-- Test multiple hook handlers:
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick1);
|
||||
@@ -68,6 +65,8 @@ function Initialize(Plugin)
|
||||
PM:BindCommand("/rmitem", "debuggers", HandleRMItem, "- Remove the specified item from the inventory.");
|
||||
PM:BindCommand("/pickups", "debuggers", HandlePickups, "- Spawns random pickups around you");
|
||||
PM:BindCommand("/poof", "debuggers", HandlePoof, "- Nudges pickups close to you away from you");
|
||||
|
||||
PM:BindConsoleCommand("sched", HandleConsoleSchedule, "Tests the world scheduling");
|
||||
|
||||
Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers)
|
||||
Plugin:AddWebTab("StressTest", HandleRequest_StressTest)
|
||||
@@ -1630,3 +1629,17 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleConsoleSchedule(a_Split)
|
||||
LOG("Scheduling a task for 2 seconds in the future")
|
||||
cRoot:Get():GetDefaultWorld():ScheduleTask(40,
|
||||
function ()
|
||||
LOG("Scheduled function is called.")
|
||||
end
|
||||
)
|
||||
return true, "Task scheduled"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1
MCServer/Plugins/Handy
Submodule
@@ -1,28 +0,0 @@
|
||||
-- Global variables
|
||||
PLUGIN = {} -- Reference to own plugin object
|
||||
CHEST_WIDTH = 9
|
||||
HANDY_VERSION = 2
|
||||
--[[
|
||||
|
||||
Handy is a plugin for other plugins. It contain no commands, no hooks, but functions to ease plugins developers' life.
|
||||
|
||||
API:
|
||||
|
||||
|
||||
TODO:
|
||||
1. GetChestSlot wrapper, so it will detect double chest neighbour chest and will be able to access it.
|
||||
]]
|
||||
|
||||
function Initialize(Plugin)
|
||||
PLUGIN = Plugin
|
||||
PLUGIN:SetName("Handy")
|
||||
PLUGIN:SetVersion(HANDY_VERSION)
|
||||
|
||||
PluginManager = cRoot:Get():GetPluginManager()
|
||||
LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion())
|
||||
return true
|
||||
end
|
||||
|
||||
function OnDisable()
|
||||
LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...")
|
||||
end
|
||||
@@ -1,216 +0,0 @@
|
||||
--[[
|
||||
General stuff
|
||||
]]
|
||||
-- Returns Handy plugin version number
|
||||
function GetHandyVersion()
|
||||
return HANDY_VERSION
|
||||
end
|
||||
-- Checks if handy is in proper version
|
||||
function CheckForRequiredVersion( inVersion )
|
||||
if( inVersion > HANDY_VERSION ) then return false end
|
||||
return true
|
||||
end
|
||||
--[[
|
||||
MCS-specific _functions and nasty hacks :D
|
||||
]]
|
||||
function GetChestHeightCheat( inChest )
|
||||
local chestGrid = inChest:GetContents()
|
||||
LOGINFO( "This function serves no purpose now! You should consider chest:GetContents():GetHeight() now!" )
|
||||
LOGINFO( "Also, you might find Handy's new 'IsChestDouble()' useful for your case" )
|
||||
return chestGrid:GetHeight()
|
||||
end
|
||||
function IsChestDouble( inChest )
|
||||
local chestHeight = inChest:GetContents():GetHeight()
|
||||
if( chestHeight == 3 ) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
-- Those two checks how many items of given inItemID chest and player have, and how much they could fit inside them
|
||||
function ReadChestForItem( inChest, inItemID )
|
||||
return ReadGridForItems( inChest:GetContents(), inItemID )
|
||||
end
|
||||
function ReadPlayerForItem( inPlayer, inItemID )
|
||||
local inventoryFound, inventoryFree = ReadGridForItems( inPlayer:GetInventory():GetInventoryGrid(), inItemID )
|
||||
local hotbarFound, hotbarFree = ReadGridForItems( inPlayer:GetInventory():GetHotbarGrid(), inItemID )
|
||||
local itemsFound = inventoryFound + hotbarFound
|
||||
local freeSpace = inventoryFree + hotbarFree
|
||||
return itemsFound, freeSpace
|
||||
end
|
||||
-- Following functions are for chest-related operations
|
||||
-- BEWARE! Those assume you did checked if chest has items/space in it!
|
||||
function ReadGridForItems( inGrid, inItemID )
|
||||
local itemsFound = 0
|
||||
local freeSpace = 0
|
||||
local slotsCount = inGrid:GetNumSlots()
|
||||
local testerItem = cItem( inItemID )
|
||||
local maxStackSize = testerItem:GetMaxStackSize()
|
||||
for index = 0, (slotsCount - 1) do
|
||||
slotItem = inGrid:GetSlot( index )
|
||||
if( slotItem:IsEmpty() ) then
|
||||
freeSpace = freeSpace + maxStackSize
|
||||
else
|
||||
if( slotItem:IsStackableWith( testerItem ) ) then
|
||||
itemsFound = itemsFound + slotItem.m_ItemCount
|
||||
freeSpace = maxStackSize - slotItem.m_ItemCount
|
||||
end
|
||||
end
|
||||
end
|
||||
return itemsFound, freeSpace
|
||||
end
|
||||
|
||||
function TakeItemsFromGrid( inGrid, inItem )
|
||||
local slotsCount = inGrid:GetNumSlots()
|
||||
local removedItem = cItem( inItem )
|
||||
for index = 0, (slotsCount - 1) do
|
||||
slotItem = inGrid:GetSlot( index )
|
||||
if( slotItem:IsSameType( removedItem ) ) then
|
||||
if( slotItem.m_ItemCount <= removedItem.m_ItemCount ) then
|
||||
removedItem.m_ItemCount = removedItem.m_ItemCount - slotItem.m_ItemCount
|
||||
inGrid:EmptySlot( index )
|
||||
else
|
||||
removedItem.m_ItemCount = slotItem.m_ItemCount - removedItem.m_ItemCount
|
||||
inGrid:SetSlot( index, removedItem )
|
||||
removedItem.m_ItemCount = 0
|
||||
end
|
||||
if( removedItem.m_ItemCount <= 0 ) then break end
|
||||
end
|
||||
end
|
||||
return removedItem.m_ItemCount
|
||||
end
|
||||
--------------
|
||||
function TakeItemsFromChest( inChest, inItemID, inAmount ) -- MIGHT BE UNSAFE! CHECK FOR ITEMS FIRST!!
|
||||
local chestGrid = inChest:GetContents()
|
||||
local removedItem = cItem( inItemID, inAmount )
|
||||
TakeItemsFromGrid( chestGrid, removedItem )
|
||||
end
|
||||
function PutItemsToChest( inChest, inItemID, inAmount )
|
||||
local chestGrid = inChest:GetContents()
|
||||
local addedItem = cItem( inItemID, inAmount )
|
||||
chestGrid:AddItem( addedItem )
|
||||
end
|
||||
-- Similar to chest-related.
|
||||
function TakeItemsFromPlayer( inPlayer, inItemID, inAmount ) -- MIGHT BE UNSAFE! CHECK FIRST!
|
||||
local removedItem = cItem( inItemID, inAmount )
|
||||
local inventoryGrid = inPlayer:GetInventory():GetInventoryGrid()
|
||||
local hotbarGrid = inPlayer:GetInventory():GetHotbarGrid()
|
||||
local itemsLeft = TakeItemsFromGrid( inventoryGrid, removedItem )
|
||||
if( itemsLeft > 0 ) then
|
||||
removedItem = cItem( inItemID, itemsLeft )
|
||||
TakeItemsFromGrid( hotbarGrid, removedItem )
|
||||
end
|
||||
end
|
||||
function GiveItemsToPlayer( inPlayer, inItemID, inAmount )
|
||||
local addedItem = cItem( inItemID, inAmount )
|
||||
local inventoryGrid = inPlayer:GetInventory():GetInventoryGrid()
|
||||
local hotbarGrid = inPlayer:GetInventory():GetHotbarGrid()
|
||||
local itemsAdded = inventoryGrid:AddItem( addedItem )
|
||||
if( itemsAdded < inAmount ) then
|
||||
addedItem.m_ItemCount = addedItem.m_ItemCount - itemsAdded
|
||||
hotbarGrid:AddItem( addedItem )
|
||||
end
|
||||
end
|
||||
-- This function returns item max stack for a given itemID. It uses vanilla max stack size, and uses several non-common items notations;
|
||||
-- Those are:
|
||||
-- oneonerecord( because aparently 11record wasn't the best idea in lua scripting application )
|
||||
-- carrotonastick( because it wasn't added to items.txt yet )
|
||||
-- waitrecord( for same reason )
|
||||
-- Feel free to ignore the difference, or to add those to items.txt
|
||||
function GetItemMaxStack( inItemID )
|
||||
local testerItem = cItem( inItemID )
|
||||
LOGINFO( "This function serves no real purpose now, maybe consider using cItem:GetMaxStackSize()?" )
|
||||
return testerItem:GetMaxStackSize()
|
||||
end
|
||||
function ItemIsArmor( inItemID, inCheckForHorseArmor )
|
||||
inCheckForHorseArmor = inCheckForHorseArmor or false
|
||||
if( inItemID == E_ITEM_LEATHER_CAP ) then return true end
|
||||
if( inItemID == E_ITEM_LEATHER_TUNIC ) then return true end
|
||||
if( inItemID == E_ITEM_LEATHER_PANTS ) then return true end
|
||||
if( inItemID == E_ITEM_LEATHER_BOOTS ) then return true end
|
||||
|
||||
if( inItemID == E_ITEM_CHAIN_HELMET ) then return true end
|
||||
if( inItemID == E_ITEM_CHAIN_CHESTPLATE ) then return true end
|
||||
if( inItemID == E_ITEM_CHAIN_LEGGINGS ) then return true end
|
||||
if( inItemID == E_ITEM_CHAIN_BOOTS ) then return true end
|
||||
|
||||
if( inItemID == E_ITEM_IRON_HELMET ) then return true end
|
||||
if( inItemID == E_ITEM_IRON_CHESTPLATE ) then return true end
|
||||
if( inItemID == E_ITEM_IRON_LEGGINGS ) then return true end
|
||||
if( inItemID == E_ITEM_IRON_BOOTS ) then return true end
|
||||
|
||||
if( inItemID == E_ITEM_DIAMOND_HELMET ) then return true end
|
||||
if( inItemID == E_ITEM_DIAMOND_CHESTPLATE ) then return true end
|
||||
if( inItemID == E_ITEM_DIAMOND_LEGGINGS ) then return true end
|
||||
if( inItemID == E_ITEM_DIAMOND_BOOTS ) then return true end
|
||||
|
||||
if( inItemID == E_ITEM_GOLD_HELMET ) then return true end
|
||||
if( inItemID == E_ITEM_GOLD_CHESTPLATE ) then return true end
|
||||
if( inItemID == E_ITEM_GOLD_LEGGINGS ) then return true end
|
||||
if( inItemID == E_ITEM_GOLD_BOOTS ) then return true end
|
||||
|
||||
if( inCheckForHorseArmor ) then
|
||||
if( inItemID == E_ITEM_IRON_HORSE_ARMOR ) then return true end
|
||||
if( inItemID == E_ITEM_GOLD_HORSE_ARMOR ) then return true end
|
||||
if( inItemID == E_ITEM_DIAMOND_HORSE_ARMOR ) then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
-- Returns full-length playername for a short name( usefull for parsing commands )
|
||||
function GetExactPlayername( inPlayerName )
|
||||
local _result = inPlayerName
|
||||
local function SetProcessingPlayername( inPlayer )
|
||||
_result = inPlayer:GetName()
|
||||
end
|
||||
cRoot:Get():FindAndDoWithPlayer( inPlayerName, SetProcessingPlayername )
|
||||
return _result
|
||||
end
|
||||
function GetPlayerByName( inPlayerName )
|
||||
local _player
|
||||
local PlayerSetter = function( Player )
|
||||
_player = Player
|
||||
end
|
||||
cRoot:Get():FindAndDoWithPlayer( inPlayerName, PlayerSetter )
|
||||
return _player
|
||||
end
|
||||
--[[
|
||||
Not-so-usual math _functions
|
||||
]]
|
||||
-- Rounds floating point number. Because lua guys think this function doesn't deserve to be presented in lua's math
|
||||
function round( inX )
|
||||
if( inX%2 ~= 0.5 ) then
|
||||
return math.floor( inX + 0.5 )
|
||||
end
|
||||
return inX - 0.5
|
||||
end
|
||||
--[[
|
||||
Functions I use for filework and stringswork
|
||||
]]
|
||||
function PluralString( inValue, inSingularString, inPluralString )
|
||||
local _value_string = tostring( inValue )
|
||||
if( _value_string[#_value_string] == "1" ) then
|
||||
return inSingularString
|
||||
end
|
||||
return inPluralString
|
||||
end
|
||||
function PluralItemName( inItemID, inAmount ) -- BEWARE! TEMPORAL SOLUTION THERE! :D
|
||||
local _value_string = tostring( inValue )
|
||||
local _name = ""
|
||||
if( _value_string[#_value_string] == "1" ) then
|
||||
-- singular names
|
||||
_name = ItemTypeToString( inItemID )
|
||||
else
|
||||
-- plural names
|
||||
_name = ItemTypeToString( inItemID ).."s"
|
||||
end
|
||||
return _name
|
||||
end
|
||||
-- for filewriting purposes. 0 = false, 1 = true
|
||||
function StringToBool( inValue )
|
||||
if( inValue == "1" ) then return true end
|
||||
return false
|
||||
end
|
||||
-- same, but reversal
|
||||
function BoolToString( inValue )
|
||||
if( inValue == true ) then return 1 end
|
||||
return 0
|
||||
end
|
||||
@@ -20,8 +20,8 @@ only that one plugin's documentation. This mode of operation doesn't require Lua
|
||||
|
||||
-- Check Lua version. We use 5.1-specific construct when loading the plugin info, 5.2 is not compatible!
|
||||
if (_VERSION ~= "Lua 5.1") then
|
||||
print("Unsupported Lua version. This script requires Lua version 5.1, this Lua is version " .. (_VERSION or "<nil>"));
|
||||
return;
|
||||
print("Unsupported Lua version. This script requires Lua version 5.1, this Lua is version " .. (_VERSION or "<nil>"))
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -31,38 +31,38 @@ end
|
||||
--- Replaces generic formatting with forum-specific formatting
|
||||
-- Also removes the single line-ends
|
||||
local function ForumizeString(a_Str)
|
||||
assert(type(a_Str) == "string");
|
||||
assert(type(a_Str) == "string")
|
||||
|
||||
-- Remove the indentation, unless in the code tag:
|
||||
-- Only one code or /code tag per line is supported!
|
||||
local IsInCode = false;
|
||||
local IsInCode = false
|
||||
local function RemoveIndentIfNotInCode(s)
|
||||
if (IsInCode) then
|
||||
-- we're in code section, check if this line terminates it
|
||||
IsInCode = (s:find("{%%/code}") ~= nil);
|
||||
return s .. "\n";
|
||||
IsInCode = (s:find("{%%/code}") ~= nil)
|
||||
return s .. "\n"
|
||||
else
|
||||
-- we're not in code section, check if this line starts it
|
||||
IsInCode = (s:find("{%%code}") ~= nil);
|
||||
return s:gsub("^%s*", "") .. "\n";
|
||||
IsInCode = (s:find("{%%code}") ~= nil)
|
||||
return s:gsub("^%s*", "") .. "\n"
|
||||
end
|
||||
end
|
||||
a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode);
|
||||
a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode)
|
||||
|
||||
-- Replace multiple line ends with {%p} and single line ends with a space,
|
||||
-- so that manual word-wrap in the Info.lua file doesn't wrap in the forum.
|
||||
a_Str = a_Str:gsub("\n\n", "{%%p}");
|
||||
a_Str = a_Str:gsub("\n", " ");
|
||||
a_Str = a_Str:gsub("\n\n", "{%%p}")
|
||||
a_Str = a_Str:gsub("\n", " ")
|
||||
|
||||
-- Replace the generic formatting:
|
||||
a_Str = a_Str:gsub("{%%p}", "\n\n");
|
||||
a_Str = a_Str:gsub("{%%b}", "[b]"):gsub("{%%/b}", "[/b]");
|
||||
a_Str = a_Str:gsub("{%%i}", "[i]"):gsub("{%%/i}", "[/i]");
|
||||
a_Str = a_Str:gsub("{%%list}", "[list]"):gsub("{%%/list}", "[/list]");
|
||||
a_Str = a_Str:gsub("{%%li}", "[*]"):gsub("{%%/li}", "");
|
||||
a_Str = a_Str:gsub("{%%p}", "\n\n")
|
||||
a_Str = a_Str:gsub("{%%b}", "[b]"):gsub("{%%/b}", "[/b]")
|
||||
a_Str = a_Str:gsub("{%%i}", "[i]"):gsub("{%%/i}", "[/i]")
|
||||
a_Str = a_Str:gsub("{%%list}", "[list]"):gsub("{%%/list}", "[/list]")
|
||||
a_Str = a_Str:gsub("{%%li}", "[*]"):gsub("{%%/li}", "")
|
||||
-- TODO: Other formatting
|
||||
|
||||
return a_Str;
|
||||
return a_Str
|
||||
end
|
||||
|
||||
|
||||
@@ -72,38 +72,38 @@ end
|
||||
--- Replaces generic formatting with forum-specific formatting
|
||||
-- Also removes the single line-ends
|
||||
local function GithubizeString(a_Str)
|
||||
assert(type(a_Str) == "string");
|
||||
assert(type(a_Str) == "string")
|
||||
|
||||
-- Remove the indentation, unless in the code tag:
|
||||
-- Only one code or /code tag per line is supported!
|
||||
local IsInCode = false;
|
||||
local IsInCode = false
|
||||
local function RemoveIndentIfNotInCode(s)
|
||||
if (IsInCode) then
|
||||
-- we're in code section, check if this line terminates it
|
||||
IsInCode = (s:find("{%%/code}") ~= nil);
|
||||
return s .. "\n";
|
||||
IsInCode = (s:find("{%%/code}") ~= nil)
|
||||
return s .. "\n"
|
||||
else
|
||||
-- we're not in code section, check if this line starts it
|
||||
IsInCode = (s:find("{%%code}") ~= nil);
|
||||
return s:gsub("^%s*", "") .. "\n";
|
||||
IsInCode = (s:find("{%%code}") ~= nil)
|
||||
return s:gsub("^%s*", "") .. "\n"
|
||||
end
|
||||
end
|
||||
a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode);
|
||||
a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode)
|
||||
|
||||
-- Replace multiple line ends with {%p} and single line ends with a space,
|
||||
-- so that manual word-wrap in the Info.lua file doesn't wrap in the forum.
|
||||
a_Str = a_Str:gsub("\n\n", "{%%p}");
|
||||
a_Str = a_Str:gsub("\n", " ");
|
||||
a_Str = a_Str:gsub("\n\n", "{%%p}")
|
||||
a_Str = a_Str:gsub("\n", " ")
|
||||
|
||||
-- Replace the generic formatting:
|
||||
a_Str = a_Str:gsub("{%%p}", "\n\n");
|
||||
a_Str = a_Str:gsub("{%%b}", "**"):gsub("{%%/b}", "**");
|
||||
a_Str = a_Str:gsub("{%%i}", "*"):gsub("{%%/i}", "*");
|
||||
a_Str = a_Str:gsub("{%%list}", ""):gsub("{%%/list}", "");
|
||||
a_Str = a_Str:gsub("{%%li}", " - "):gsub("{%%/li}", "");
|
||||
a_Str = a_Str:gsub("{%%p}", "\n\n")
|
||||
a_Str = a_Str:gsub("{%%b}", "**"):gsub("{%%/b}", "**")
|
||||
a_Str = a_Str:gsub("{%%i}", "*"):gsub("{%%/i}", "*")
|
||||
a_Str = a_Str:gsub("{%%list}", ""):gsub("{%%/list}", "")
|
||||
a_Str = a_Str:gsub("{%%li}", " - "):gsub("{%%/li}", "")
|
||||
-- TODO: Other formatting
|
||||
|
||||
return a_Str;
|
||||
return a_Str
|
||||
end
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ end
|
||||
local function BuildCategories(a_PluginInfo)
|
||||
-- The returned result
|
||||
-- This will contain both an array and a dict of the categories, to allow fast search
|
||||
local res = {};
|
||||
local res = {}
|
||||
|
||||
-- For each command add a reference to it into all of its categories:
|
||||
local function AddCommands(a_CmdPrefix, a_Commands)
|
||||
@@ -130,39 +130,39 @@ local function BuildCategories(a_PluginInfo)
|
||||
|
||||
if ((info.HelpString ~= nil) and (info.HelpString ~= "")) then
|
||||
-- Add to each specified category:
|
||||
local Category = info.Category;
|
||||
local Category = info.Category
|
||||
if (type(Category) == "string") then
|
||||
Category = {Category};
|
||||
Category = {Category}
|
||||
end
|
||||
for idx, cat in ipairs(Category or {""}) do
|
||||
local CatEntry = res[cat];
|
||||
local CatEntry = res[cat]
|
||||
if (CatEntry == nil) then
|
||||
-- First time we came across this category, create it:
|
||||
local NewCat = {Name = cat, Description = "", Commands = {NewCmd}};
|
||||
table.insert(res, NewCat);
|
||||
res[cat] = NewCat;
|
||||
local NewCat = {Name = cat, Description = "", Commands = {NewCmd}}
|
||||
table.insert(res, NewCat)
|
||||
res[cat] = NewCat
|
||||
else
|
||||
-- We already have this category, just add the command to its list of commands:
|
||||
table.insert(CatEntry.Commands, NewCmd);
|
||||
table.insert(CatEntry.Commands, NewCmd)
|
||||
end
|
||||
end -- for idx, cat - Category[]
|
||||
end -- if (HelpString valid)
|
||||
|
||||
-- Recurse all subcommands:
|
||||
if (info.Subcommands ~= nil) then
|
||||
AddCommands(a_CmdPrefix .. cmd .. " ", info.Subcommands);
|
||||
AddCommands(a_CmdPrefix .. cmd .. " ", info.Subcommands)
|
||||
end
|
||||
end -- for cmd, info - a_Commands[]
|
||||
end -- AddCommands()
|
||||
|
||||
AddCommands("", a_PluginInfo.Commands);
|
||||
AddCommands("", a_PluginInfo.Commands)
|
||||
|
||||
-- Assign descriptions to categories:
|
||||
for name, desc in pairs(a_PluginInfo.Categories or {}) do
|
||||
local CatEntry = res[name];
|
||||
local CatEntry = res[name]
|
||||
if (CatEntry ~= nil) then
|
||||
-- The result has this category, add the description:
|
||||
CatEntry.Description = desc.Description;
|
||||
CatEntry.Description = desc.Description
|
||||
end
|
||||
end
|
||||
|
||||
@@ -170,12 +170,12 @@ local function BuildCategories(a_PluginInfo)
|
||||
for idx, cat in ipairs(res) do
|
||||
table.sort(cat.Commands,
|
||||
function (cmd1, cmd2)
|
||||
return (string.lower(cmd1.CommandString) < string.lower(cmd2.CommandString));
|
||||
return (string.lower(cmd1.CommandString) < string.lower(cmd2.CommandString))
|
||||
end
|
||||
);
|
||||
)
|
||||
end
|
||||
|
||||
return res;
|
||||
return res
|
||||
end
|
||||
|
||||
|
||||
@@ -188,9 +188,9 @@ end
|
||||
-- colorizes command name blue and params green
|
||||
local function GetCommandRefForum(a_Command)
|
||||
if (type(a_Command) == "string") then
|
||||
return "[color=blue]" .. a_Command .. "[/color]";
|
||||
return "[color=blue]" .. a_Command .. "[/color]"
|
||||
end
|
||||
return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. (a_Command.Params or "") .. "[/color]";
|
||||
return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. (a_Command.Params or "") .. "[/color]"
|
||||
end
|
||||
|
||||
|
||||
@@ -201,18 +201,18 @@ end
|
||||
-- If a_CommandParams is nil, returns a_CommandName apostrophed
|
||||
-- If a_CommandParams is a string, apostrophes a_CommandName with a_CommandParams
|
||||
local function GetCommandRefGithub(a_CommandName, a_CommandParams)
|
||||
assert(type(a_CommandName) == "string");
|
||||
assert(type(a_CommandName) == "string")
|
||||
if (a_CommandParams == nil) then
|
||||
return "`" .. a_CommandName .. "`";
|
||||
return "`" .. a_CommandName .. "`"
|
||||
end
|
||||
|
||||
assert(type(a_CommandParams) == "table");
|
||||
assert(type(a_CommandParams) == "table")
|
||||
if ((a_CommandParams.Params == nil) or (a_CommandParams.Params == "")) then
|
||||
return "`" .. a_CommandName .. "`";
|
||||
return "`" .. a_CommandName .. "`"
|
||||
end
|
||||
|
||||
assert(type(a_CommandParams.Params) == "string");
|
||||
return "`" .. a_CommandName .. " " .. a_CommandParams.Params .. "`";
|
||||
assert(type(a_CommandParams.Params) == "string")
|
||||
return "`" .. a_CommandName .. " " .. a_CommandParams.Params .. "`"
|
||||
end
|
||||
|
||||
|
||||
@@ -221,25 +221,25 @@ end
|
||||
|
||||
--- Writes the specified command detailed help array to the output file, in the forum dump format
|
||||
local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCombinations, f)
|
||||
assert(type(a_CmdString) == "string");
|
||||
assert(type(a_ParameterCombinations) == "table");
|
||||
assert(f ~= nil);
|
||||
assert(type(a_CmdString) == "string")
|
||||
assert(type(a_ParameterCombinations) == "table")
|
||||
assert(f ~= nil)
|
||||
|
||||
if (#a_ParameterCombinations == 0) then
|
||||
-- No explicit parameter combinations to write
|
||||
return;
|
||||
return
|
||||
end
|
||||
|
||||
f:write("The following parameter combinations are recognized:\n");
|
||||
f:write("The following parameter combinations are recognized:\n")
|
||||
for idx, combination in ipairs(a_ParameterCombinations) do
|
||||
f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params or "", "[/color]");
|
||||
f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params or "", "[/color]")
|
||||
if (combination.Help ~= nil) then
|
||||
f:write(" - ", ForumizeString(combination.Help));
|
||||
f:write(" - ", ForumizeString(combination.Help))
|
||||
end
|
||||
if (combination.Permission ~= nil) then
|
||||
f:write(" (Requires permission '[color=red]", combination.Permission, "[/color]')");
|
||||
f:write(" (Requires permission '[color=red]", combination.Permission, "[/color]')")
|
||||
end
|
||||
f:write("\n");
|
||||
f:write("\n")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -249,25 +249,25 @@ end
|
||||
|
||||
--- Writes the specified command detailed help array to the output file, in the forum dump format
|
||||
local function WriteCommandParameterCombinationsGithub(a_CmdString, a_ParameterCombinations, f)
|
||||
assert(type(a_CmdString) == "string");
|
||||
assert(type(a_ParameterCombinations) == "table");
|
||||
assert(f ~= nil);
|
||||
assert(type(a_CmdString) == "string")
|
||||
assert(type(a_ParameterCombinations) == "table")
|
||||
assert(f ~= nil)
|
||||
|
||||
if (#a_ParameterCombinations == 0) then
|
||||
-- No explicit parameter combinations to write
|
||||
return;
|
||||
return
|
||||
end
|
||||
|
||||
f:write("The following parameter combinations are recognized:\n\n");
|
||||
f:write("The following parameter combinations are recognized:\n\n")
|
||||
for idx, combination in ipairs(a_ParameterCombinations) do
|
||||
f:write(GetCommandRefGithub(a_CmdString, combination));
|
||||
f:write(GetCommandRefGithub(a_CmdString, combination))
|
||||
if (combination.Help ~= nil) then
|
||||
f:write(" - ", GithubizeString(combination.Help));
|
||||
f:write(" - ", GithubizeString(combination.Help))
|
||||
end
|
||||
if (combination.Permission ~= nil) then
|
||||
f:write(" (Requires permission '**", combination.Permission, "**')");
|
||||
f:write(" (Requires permission '**", combination.Permission, "**')")
|
||||
end
|
||||
f:write("\n");
|
||||
f:write("\n")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -278,29 +278,29 @@ end
|
||||
--- Writes all commands in the specified category to the output file, in the forum dump format
|
||||
local function WriteCommandsCategoryForum(a_Category, f)
|
||||
-- Write category name:
|
||||
local CategoryName = a_Category.Name;
|
||||
local CategoryName = a_Category.Name
|
||||
if (CategoryName == "") then
|
||||
CategoryName = "General";
|
||||
CategoryName = "General"
|
||||
end
|
||||
f:write("\n[size=Large]", ForumizeString(a_Category.DisplayName or CategoryName), "[/size]\n");
|
||||
f:write("\n[size=Large]", ForumizeString(a_Category.DisplayName or CategoryName), "[/size]\n")
|
||||
|
||||
-- Write description:
|
||||
if (a_Category.Description ~= "") then
|
||||
f:write(ForumizeString(a_Category.Description), "\n");
|
||||
f:write(ForumizeString(a_Category.Description), "\n")
|
||||
end
|
||||
|
||||
-- Write commands:
|
||||
f:write("\n[list]");
|
||||
f:write("\n[list]")
|
||||
for idx2, cmd in ipairs(a_Category.Commands) do
|
||||
f:write("\n[b]", cmd.CommandString, "[/b] - ", ForumizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "\n");
|
||||
f:write("\n[b]", cmd.CommandString, "[/b] - ", ForumizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "\n")
|
||||
if (cmd.Info.Permission ~= nil) then
|
||||
f:write("Permission required: [color=red]", cmd.Info.Permission, "[/color]\n");
|
||||
f:write("Permission required: [color=red]", cmd.Info.Permission, "[/color]\n")
|
||||
end
|
||||
if (cmd.Info.DetailedDescription ~= nil) then
|
||||
f:write(ForumizeString(cmd.Info.DetailedDescription));
|
||||
f:write(ForumizeString(cmd.Info.DetailedDescription))
|
||||
end
|
||||
if (cmd.Info.ParameterCombinations ~= nil) then
|
||||
WriteCommandParameterCombinationsForum(cmd.CommandString, cmd.Info.ParameterCombinations, f);
|
||||
WriteCommandParameterCombinationsForum(cmd.CommandString, cmd.Info.ParameterCombinations, f)
|
||||
end
|
||||
end
|
||||
f:write("[/list]\n\n")
|
||||
@@ -313,23 +313,23 @@ end
|
||||
--- Writes all commands in the specified category to the output file, in the Github dump format
|
||||
local function WriteCommandsCategoryGithub(a_Category, f)
|
||||
-- Write category name:
|
||||
local CategoryName = a_Category.Name;
|
||||
local CategoryName = a_Category.Name
|
||||
if (CategoryName == "") then
|
||||
CategoryName = "General";
|
||||
CategoryName = "General"
|
||||
end
|
||||
f:write("\n### ", GithubizeString(a_Category.DisplayName or CategoryName), "\n");
|
||||
f:write("\n### ", GithubizeString(a_Category.DisplayName or CategoryName), "\n")
|
||||
|
||||
-- Write description:
|
||||
if (a_Category.Description ~= "") then
|
||||
f:write(GithubizeString(a_Category.Description), "\n\n");
|
||||
f:write(GithubizeString(a_Category.Description), "\n\n")
|
||||
end
|
||||
|
||||
f:write("| Command | Permission | Description | \n")
|
||||
f:write("| ------- | ---------- | ----------- | \n")
|
||||
f:write("| Command | Permission | Description |\n")
|
||||
f:write("| ------- | ---------- | ----------- |\n")
|
||||
|
||||
-- Write commands:
|
||||
for idx2, cmd in ipairs(a_Category.Commands) do
|
||||
f:write("|", cmd.CommandString, " | ", cmd.Info.Permission or "", " | ", GithubizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "| \n")
|
||||
f:write("|", cmd.CommandString, " | ", cmd.Info.Permission or "", " | ", GithubizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "|\n")
|
||||
end
|
||||
f:write("\n\n")
|
||||
end
|
||||
@@ -340,24 +340,24 @@ end
|
||||
|
||||
local function DumpCommandsForum(a_PluginInfo, f)
|
||||
-- Copy all Categories from a dictionary into an array:
|
||||
local Categories = BuildCategories(a_PluginInfo);
|
||||
local Categories = BuildCategories(a_PluginInfo)
|
||||
|
||||
-- Sort the categories by name:
|
||||
table.sort(Categories,
|
||||
function(cat1, cat2)
|
||||
return (string.lower(cat1.Name) < string.lower(cat2.Name));
|
||||
return (string.lower(cat1.Name) < string.lower(cat2.Name))
|
||||
end
|
||||
);
|
||||
)
|
||||
|
||||
if (#Categories == 0) then
|
||||
return;
|
||||
return
|
||||
end
|
||||
|
||||
f:write("\n[size=X-Large]Commands[/size]\n");
|
||||
f:write("\n[size=X-Large]Commands[/size]\n")
|
||||
|
||||
-- Dump per-category commands:
|
||||
for idx, cat in ipairs(Categories) do
|
||||
WriteCommandsCategoryForum(cat, f);
|
||||
WriteCommandsCategoryForum(cat, f)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -367,24 +367,24 @@ end
|
||||
|
||||
local function DumpCommandsGithub(a_PluginInfo, f)
|
||||
-- Copy all Categories from a dictionary into an array:
|
||||
local Categories = BuildCategories(a_PluginInfo);
|
||||
local Categories = BuildCategories(a_PluginInfo)
|
||||
|
||||
-- Sort the categories by name:
|
||||
table.sort(Categories,
|
||||
function(cat1, cat2)
|
||||
return (string.lower(cat1.Name) < string.lower(cat2.Name));
|
||||
return (string.lower(cat1.Name) < string.lower(cat2.Name))
|
||||
end
|
||||
);
|
||||
)
|
||||
|
||||
if (#Categories == 0) then
|
||||
return;
|
||||
return
|
||||
end
|
||||
|
||||
f:write("\n# Commands\n");
|
||||
f:write("\n# Commands\n")
|
||||
|
||||
-- Dump per-category commands:
|
||||
for idx, cat in ipairs(Categories) do
|
||||
WriteCommandsCategoryGithub(cat, f);
|
||||
WriteCommandsCategoryGithub(cat, f)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -393,16 +393,16 @@ end
|
||||
|
||||
|
||||
local function DumpAdditionalInfoForum(a_PluginInfo, f)
|
||||
local AInfo = a_PluginInfo.AdditionalInfo;
|
||||
local AInfo = a_PluginInfo.AdditionalInfo
|
||||
if (type(AInfo) ~= "table") then
|
||||
-- There is no AdditionalInfo in a_PluginInfo
|
||||
return;
|
||||
return
|
||||
end
|
||||
|
||||
for idx, info in ipairs(a_PluginInfo.AdditionalInfo) do
|
||||
if ((info.Title ~= nil) and (info.Contents ~= nil)) then
|
||||
f:write("\n[size=X-Large]", ForumizeString(info.Title), "[/size]\n");
|
||||
f:write(ForumizeString(info.Contents), "\n");
|
||||
f:write("\n[size=X-Large]", ForumizeString(info.Title), "[/size]\n")
|
||||
f:write(ForumizeString(info.Contents), "\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -412,16 +412,16 @@ end
|
||||
|
||||
|
||||
local function DumpAdditionalInfoGithub(a_PluginInfo, f)
|
||||
local AInfo = a_PluginInfo.AdditionalInfo;
|
||||
local AInfo = a_PluginInfo.AdditionalInfo
|
||||
if (type(AInfo) ~= "table") then
|
||||
-- There is no AdditionalInfo in a_PluginInfo
|
||||
return;
|
||||
return
|
||||
end
|
||||
|
||||
for idx, info in ipairs(a_PluginInfo.AdditionalInfo) do
|
||||
if ((info.Title ~= nil) and (info.Contents ~= nil)) then
|
||||
f:write("\n# ", GithubizeString(info.Title), "\n");
|
||||
f:write(GithubizeString(info.Contents), "\n");
|
||||
f:write("\n# ", GithubizeString(info.Title), "\n")
|
||||
f:write(GithubizeString(info.Contents), "\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -434,53 +434,53 @@ end
|
||||
-- Each array item is {Name = "PermissionName", Info = { PermissionInfo }}
|
||||
local function BuildPermissions(a_PluginInfo)
|
||||
-- Collect all used permissions from Commands, reference the commands that use the permission:
|
||||
local Permissions = a_PluginInfo.Permissions or {};
|
||||
local Permissions = a_PluginInfo.Permissions or {}
|
||||
local function CollectPermissions(a_CmdPrefix, a_Commands)
|
||||
for cmd, info in pairs(a_Commands) do
|
||||
CommandString = a_CmdPrefix .. cmd;
|
||||
CommandString = a_CmdPrefix .. cmd
|
||||
if ((info.Permission ~= nil) and (info.Permission ~= "")) then
|
||||
-- Add the permission to the list of permissions:
|
||||
local Permission = Permissions[info.Permission] or {};
|
||||
Permissions[info.Permission] = Permission;
|
||||
local Permission = Permissions[info.Permission] or {}
|
||||
Permissions[info.Permission] = Permission
|
||||
-- Add the command to the list of commands using this permission:
|
||||
Permission.CommandsAffected = Permission.CommandsAffected or {};
|
||||
table.insert(Permission.CommandsAffected, CommandString);
|
||||
Permission.CommandsAffected = Permission.CommandsAffected or {}
|
||||
table.insert(Permission.CommandsAffected, CommandString)
|
||||
end
|
||||
|
||||
-- Process the command param combinations for permissions:
|
||||
local ParamCombinations = info.ParameterCombinations or {};
|
||||
local ParamCombinations = info.ParameterCombinations or {}
|
||||
for idx, comb in ipairs(ParamCombinations) do
|
||||
if ((comb.Permission ~= nil) and (comb.Permission ~= "")) then
|
||||
-- Add the permission to the list of permissions:
|
||||
local Permission = Permissions[comb.Permission] or {};
|
||||
Permissions[info.Permission] = Permission;
|
||||
local Permission = Permissions[comb.Permission] or {}
|
||||
Permissions[info.Permission] = Permission
|
||||
-- Add the command to the list of commands using this permission:
|
||||
Permission.CommandsAffected = Permission.CommandsAffected or {};
|
||||
table.insert(Permission.CommandsAffected, {Name = CommandString, Params = comb.Params});
|
||||
Permission.CommandsAffected = Permission.CommandsAffected or {}
|
||||
table.insert(Permission.CommandsAffected, {Name = CommandString, Params = comb.Params})
|
||||
end
|
||||
end
|
||||
|
||||
-- Process subcommands:
|
||||
if (info.Subcommands ~= nil) then
|
||||
CollectPermissions(CommandString .. " ", info.Subcommands);
|
||||
CollectPermissions(CommandString .. " ", info.Subcommands)
|
||||
end
|
||||
end
|
||||
end
|
||||
CollectPermissions("", a_PluginInfo.Commands);
|
||||
CollectPermissions("", a_PluginInfo.Commands)
|
||||
|
||||
-- Copy the list of permissions to an array:
|
||||
local PermArray = {};
|
||||
local PermArray = {}
|
||||
for name, perm in pairs(Permissions) do
|
||||
table.insert(PermArray, {Name = name, Info = perm});
|
||||
table.insert(PermArray, {Name = name, Info = perm})
|
||||
end
|
||||
|
||||
-- Sort the permissions array:
|
||||
table.sort(PermArray,
|
||||
function(p1, p2)
|
||||
return (p1.Name < p2.Name);
|
||||
return (p1.Name < p2.Name)
|
||||
end
|
||||
);
|
||||
return PermArray;
|
||||
)
|
||||
return PermArray
|
||||
end
|
||||
|
||||
|
||||
@@ -489,32 +489,32 @@ end
|
||||
|
||||
local function DumpPermissionsForum(a_PluginInfo, f)
|
||||
-- Get the processed sorted array of permissions:
|
||||
local Permissions = BuildPermissions(a_PluginInfo);
|
||||
local Permissions = BuildPermissions(a_PluginInfo)
|
||||
if ((Permissions == nil) or (#Permissions <= 0)) then
|
||||
return;
|
||||
return
|
||||
end
|
||||
|
||||
-- Dump the permissions:
|
||||
f:write("\n[size=X-Large]Permissions[/size]\n[list]\n");
|
||||
f:write("\n[size=X-Large]Permissions[/size]\n[list]\n")
|
||||
for idx, perm in ipairs(Permissions) do
|
||||
f:write(" - [color=red]", perm.Name, "[/color] - ");
|
||||
f:write(ForumizeString(perm.Info.Description or ""));
|
||||
local CommandsAffected = perm.Info.CommandsAffected or {};
|
||||
f:write(" - [color=red]", perm.Name, "[/color] - ")
|
||||
f:write(ForumizeString(perm.Info.Description or ""))
|
||||
local CommandsAffected = perm.Info.CommandsAffected or {}
|
||||
if (#CommandsAffected > 0) then
|
||||
f:write("\n[list] Commands affected:\n- ");
|
||||
local Affects = {};
|
||||
f:write("\n[list] Commands affected:\n- ")
|
||||
local Affects = {}
|
||||
for idx2, cmd in ipairs(CommandsAffected) do
|
||||
table.insert(Affects, GetCommandRefForum(cmd));
|
||||
table.insert(Affects, GetCommandRefForum(cmd))
|
||||
end
|
||||
f:write(table.concat(Affects, "\n - "));
|
||||
f:write("\n[/list]");
|
||||
f:write(table.concat(Affects, "\n - "))
|
||||
f:write("\n[/list]")
|
||||
end
|
||||
if (perm.Info.RecommendedGroups ~= nil) then
|
||||
f:write("\n[list] Recommended groups: ", perm.Info.RecommendedGroups, "[/list]");
|
||||
f:write("\n[list] Recommended groups: ", perm.Info.RecommendedGroups, "[/list]")
|
||||
end
|
||||
f:write("\n");
|
||||
f:write("\n")
|
||||
end
|
||||
f:write("[/list]");
|
||||
f:write("[/list]")
|
||||
end
|
||||
|
||||
|
||||
@@ -523,34 +523,35 @@ end
|
||||
|
||||
local function DumpPermissionsGithub(a_PluginInfo, f)
|
||||
-- Get the processed sorted array of permissions:
|
||||
local Permissions = BuildPermissions(a_PluginInfo);
|
||||
local Permissions = BuildPermissions(a_PluginInfo)
|
||||
if ((Permissions == nil) or (#Permissions <= 0)) then
|
||||
return;
|
||||
return
|
||||
end
|
||||
|
||||
-- Dump the permissions:
|
||||
f:write("\n# Permissions\n");
|
||||
f:write("\n# Permissions\n")
|
||||
f:write("| Permissions | Description | Commands | Recommended groups |\n")
|
||||
f:write("| ----------- | ----------- | -------- | ------------------ |\n")
|
||||
for idx, perm in ipairs(Permissions) do
|
||||
f:write(perm.Name, " | ");
|
||||
f:write(GithubizeString(perm.Info.Description or ""), " | ");
|
||||
local CommandsAffected = perm.Info.CommandsAffected or {};
|
||||
f:write("| ", perm.Name, " | ")
|
||||
f:write(GithubizeString(perm.Info.Description or ""), " | ")
|
||||
local CommandsAffected = perm.Info.CommandsAffected or {}
|
||||
if (#CommandsAffected > 0) then
|
||||
local Affects = {};
|
||||
local Affects = {}
|
||||
for idx2, cmd in ipairs(CommandsAffected) do
|
||||
if (type(cmd) == "string") then
|
||||
table.insert(Affects, GetCommandRefGithub(cmd));
|
||||
table.insert(Affects, GetCommandRefGithub(cmd))
|
||||
else
|
||||
table.insert(Affects, GetCommandRefGithub(cmd.Name, cmd));
|
||||
table.insert(Affects, GetCommandRefGithub(cmd.Name, cmd))
|
||||
end
|
||||
end
|
||||
f:write(table.concat(Affects, ", "), " | ");
|
||||
f:write(table.concat(Affects, ", "))
|
||||
end
|
||||
f:write(" | ")
|
||||
if (perm.Info.RecommendedGroups ~= nil) then
|
||||
f:write(perm.Info.RecommendedGroups, " |");
|
||||
f:write(perm.Info.RecommendedGroups)
|
||||
end
|
||||
f:write("\n");
|
||||
f:write(" |\n")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -558,45 +559,53 @@ end
|
||||
|
||||
|
||||
|
||||
--- Dumps the forum-format info for the plugin
|
||||
-- Returns true on success, nil and error message on failure
|
||||
local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo)
|
||||
-- Open the output file:
|
||||
local f, msg = io.open(a_PluginInfo.Name .. "_forum.txt", "w");
|
||||
local f, msg = io.open(a_PluginFolder .. "/forum_info.txt", "w")
|
||||
if (f == nil) then
|
||||
print("\tCannot dump forum info for plugin " .. a_PluginFolder .. ": " .. msg);
|
||||
return;
|
||||
return nil, msg
|
||||
end
|
||||
|
||||
-- Write the description:
|
||||
f:write(ForumizeString(a_PluginInfo.Description), "\n");
|
||||
DumpAdditionalInfoForum(a_PluginInfo, f);
|
||||
DumpCommandsForum(a_PluginInfo, f);
|
||||
DumpPermissionsForum(a_PluginInfo, f);
|
||||
f:write(ForumizeString(a_PluginInfo.Description), "\n")
|
||||
DumpAdditionalInfoForum(a_PluginInfo, f)
|
||||
DumpCommandsForum(a_PluginInfo, f)
|
||||
DumpPermissionsForum(a_PluginInfo, f)
|
||||
if (a_PluginInfo.SourceLocation ~= nil) then
|
||||
f:write("[b][color=blue]Source:[/color] [url=", a_PluginInfo.SourceLocation, "]Link[/url][/b]");
|
||||
f:write("[b][color=blue]Source:[/color] [url=", a_PluginInfo.SourceLocation, "]Link[/url][/b]")
|
||||
end
|
||||
|
||||
f:close();
|
||||
f:close()
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--- Dumps the README.md file into the plugin's folder with the GitHub Markdown format
|
||||
-- Returns true on success, nil and error message on failure
|
||||
local function DumpPluginInfoGithub(a_PluginFolder, a_PluginInfo)
|
||||
-- Check the params:
|
||||
assert(type(a_PluginFolder) == "string")
|
||||
assert(type(a_PluginInfo) == "table")
|
||||
|
||||
-- Open the output file:
|
||||
local f, msg = io.open(a_PluginInfo.Name .. ".md", "w"); -- TODO: Save to a_PluginFolder .. "/Readme.md" instead
|
||||
local f, msg = io.open(a_PluginFolder .. "/README.md", "w")
|
||||
if (f == nil) then
|
||||
print("\tCannot dump github info for plugin " .. a_PluginFolder .. ": " .. msg);
|
||||
return;
|
||||
print("\tCannot dump github info for plugin " .. a_PluginFolder .. ": " .. msg)
|
||||
return nil, msg
|
||||
end
|
||||
|
||||
-- Write the description:
|
||||
f:write(GithubizeString(a_PluginInfo.Description), "\n");
|
||||
DumpAdditionalInfoGithub(a_PluginInfo, f);
|
||||
DumpCommandsGithub(a_PluginInfo, f);
|
||||
DumpPermissionsGithub(a_PluginInfo, f);
|
||||
f:write(GithubizeString(a_PluginInfo.Description), "\n")
|
||||
DumpAdditionalInfoGithub(a_PluginInfo, f)
|
||||
DumpCommandsGithub(a_PluginInfo, f)
|
||||
DumpPermissionsGithub(a_PluginInfo, f)
|
||||
|
||||
f:close();
|
||||
f:close()
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -607,36 +616,54 @@ end
|
||||
-- Returns the g_PluginInfo table on success, or nil and error message on failure
|
||||
local function LoadPluginInfo(a_FolderName)
|
||||
-- Load and compile the Info file:
|
||||
local cfg, err = loadfile(a_FolderName .. "/Info.lua");
|
||||
local cfg, err = loadfile(a_FolderName .. "/Info.lua")
|
||||
if (cfg == nil) then
|
||||
return nil, "Cannot open 'Info.lua': " .. err;
|
||||
return nil, "Cannot open 'Info.lua': " .. err
|
||||
end
|
||||
|
||||
-- Execute the loaded file in a sandbox:
|
||||
-- This is Lua-5.1-specific and won't work in Lua 5.2!
|
||||
local Sandbox = {};
|
||||
setfenv(cfg, Sandbox);
|
||||
cfg();
|
||||
if (Sandbox.g_PluginInfo == nil) then
|
||||
return nil, "Info.lua doesn't contain the g_PluginInfo declaration";
|
||||
local Sandbox = {}
|
||||
setfenv(cfg, Sandbox)
|
||||
local isSuccess, errMsg = pcall(cfg)
|
||||
if not(isSuccess) then
|
||||
return nil, "Cannot load Info.lua: " .. (errMsg or "<unknown error>")
|
||||
end
|
||||
return Sandbox.g_PluginInfo;
|
||||
|
||||
if (Sandbox.g_PluginInfo == nil) then
|
||||
return nil, "Info.lua doesn't contain the g_PluginInfo declaration"
|
||||
end
|
||||
return Sandbox.g_PluginInfo
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--- Processes the info for one plugin
|
||||
-- Returns true on success, nil and error message on failure
|
||||
local function ProcessPluginFolder(a_FolderName)
|
||||
local PluginInfo, Msg = LoadPluginInfo(a_FolderName);
|
||||
-- Load the plugin info:
|
||||
local PluginInfo, Msg = LoadPluginInfo(a_FolderName)
|
||||
if (PluginInfo == nil) then
|
||||
if (Msg ~= nil) then
|
||||
print("\t" .. Msg);
|
||||
end
|
||||
return;
|
||||
return nil, "Cannot load info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>")
|
||||
end
|
||||
DumpPluginInfoForum(a_FolderName, PluginInfo);
|
||||
DumpPluginInfoGithub(a_FolderName, PluginInfo);
|
||||
|
||||
-- Dump the forum format:
|
||||
local isSuccess
|
||||
isSuccess, Msg = DumpPluginInfoForum(a_FolderName, PluginInfo)
|
||||
if not(isSuccess) then
|
||||
return nil, "Cannot dump forum info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>")
|
||||
end
|
||||
|
||||
-- Dump the GitHub format:
|
||||
isSuccess, Msg = DumpPluginInfoGithub(a_FolderName, PluginInfo)
|
||||
if not(isSuccess) then
|
||||
return nil, "Cannot dump GitHub info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>")
|
||||
end
|
||||
|
||||
-- All OK, return success
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -650,7 +677,7 @@ local function LoadLFS()
|
||||
function()
|
||||
return require("lfs")
|
||||
end
|
||||
);
|
||||
)
|
||||
|
||||
-- ... rather, print a nice message with instructions:
|
||||
if not(lfs) then
|
||||
@@ -663,44 +690,50 @@ local function LoadLFS()
|
||||
If you don't have luarocks installed, you need to install them using your OS's package manager, usually:
|
||||
sudo apt-get install luarocks (Ubuntu / Debian)
|
||||
On windows, a binary distribution can be downloaded from the LuaRocks homepage, http://luarocks.org/en/Download
|
||||
]]);
|
||||
]])
|
||||
|
||||
print("Original error text: ", err);
|
||||
return nil;
|
||||
print("Original error text: ", err)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- We now know that LFS is present, get it normally:
|
||||
return require("lfs");
|
||||
return require("lfs")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local Arg1 = ...;
|
||||
local Arg1 = arg[1]
|
||||
if ((Arg1 ~= nil) and (Arg1 ~= "")) then
|
||||
-- Called with a plugin folder name, export only that one
|
||||
ProcessPluginFolder(Arg1)
|
||||
local isSuccess, msg = ProcessPluginFolder(Arg1)
|
||||
if not(isSuccess) then
|
||||
print(msg or "<unknown error>")
|
||||
end
|
||||
else
|
||||
-- Called without any arguments, process all subfolders:
|
||||
local lfs = LoadLFS();
|
||||
local lfs = LoadLFS()
|
||||
if (lfs == nil) then
|
||||
-- LFS not loaded, error has already been printed, just bail out
|
||||
return;
|
||||
return
|
||||
end
|
||||
print("Processing plugin subfolders:");
|
||||
print("Processing plugin subfolders:")
|
||||
for fnam in lfs.dir(".") do
|
||||
if ((fnam ~= ".") and (fnam ~= "..")) then
|
||||
local Attributes = lfs.attributes(fnam);
|
||||
local Attributes = lfs.attributes(fnam)
|
||||
if (Attributes ~= nil) then
|
||||
if (Attributes.mode == "directory") then
|
||||
print(fnam);
|
||||
ProcessPluginFolder(fnam);
|
||||
print(fnam)
|
||||
local isSuccess, msg = ProcessPluginFolder(fnam)
|
||||
if not(isSuccess) then
|
||||
print(" " .. (msg or "<unknown error>"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
print("Done.");
|
||||
print("Done.")
|
||||
|
||||
|
||||
|
||||
1
MCServer/Plugins/MagicCarpet
Submodule
@@ -1,97 +0,0 @@
|
||||
-- Location object
|
||||
cLocation = {}
|
||||
function cLocation:new( x, y, z )
|
||||
local object = { x = x, y = y, z = z }
|
||||
setmetatable(object, { __index = cLocation })
|
||||
return object
|
||||
end
|
||||
|
||||
-- Offsets
|
||||
cFibers = { }
|
||||
function cFibers:new()
|
||||
local object = {
|
||||
cLocation:new( 2, -1, 2 ),
|
||||
cLocation:new( 2, -1, 1 ),
|
||||
cLocation:new( 2, -1, 0 ),
|
||||
cLocation:new( 2, -1, -1 ),
|
||||
cLocation:new( 2, -1, -2 ),
|
||||
cLocation:new( 1, -1, 2 ),
|
||||
cLocation:new( 1, -1, 1 ),
|
||||
cLocation:new( 1, -1, 0 ),
|
||||
cLocation:new( 1, -1, -1 ),
|
||||
cLocation:new( 1, -1, -2 ),
|
||||
cLocation:new( 0, -1, 2 ),
|
||||
cLocation:new( 0, -1, 1 ),
|
||||
cLocation:new( 0, -1, 0 ),
|
||||
cLocation:new( 0, -1, -1 ),
|
||||
cLocation:new( 0, -1, -2 ),
|
||||
cLocation:new( -1, -1, 2 ),
|
||||
cLocation:new( -1, -1, 1 ),
|
||||
cLocation:new( -1, -1, 0 ),
|
||||
cLocation:new( -1, -1, -1 ),
|
||||
cLocation:new( -1, -1, -2 ),
|
||||
cLocation:new( -2, -1, 2 ),
|
||||
cLocation:new( -2, -1, 1 ),
|
||||
cLocation:new( -2, -1, 0 ),
|
||||
cLocation:new( -2, -1, -1 ),
|
||||
cLocation:new( -2, -1, -2 ),
|
||||
imadeit = false,
|
||||
}
|
||||
setmetatable(object, { __index = cFibers })
|
||||
return object;
|
||||
end
|
||||
|
||||
-- Carpet object
|
||||
cCarpet = {}
|
||||
function cCarpet:new()
|
||||
local object = { Location = cLocation:new(0,0,0),
|
||||
Fibers = cFibers:new(),
|
||||
}
|
||||
setmetatable(object, { __index = cCarpet })
|
||||
return object
|
||||
end
|
||||
|
||||
function cCarpet:remove()
|
||||
local World = cRoot:Get():GetDefaultWorld()
|
||||
for i, fib in ipairs( self.Fibers ) do
|
||||
local x = self.Location.x + fib.x
|
||||
local y = self.Location.y + fib.y
|
||||
local z = self.Location.z + fib.z
|
||||
local BlockID = World:GetBlock( x, y, z )
|
||||
if( fib.imadeit == true and BlockID == E_BLOCK_GLASS ) then
|
||||
World:SetBlock( x, y, z, 0, 0 )
|
||||
fib.imadeit = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function cCarpet:draw()
|
||||
local World = cRoot:Get():GetDefaultWorld()
|
||||
for i, fib in ipairs( self.Fibers ) do
|
||||
local x = self.Location.x + fib.x
|
||||
local y = self.Location.y + fib.y
|
||||
local z = self.Location.z + fib.z
|
||||
local BlockID = World:GetBlock( x, y, z )
|
||||
if( BlockID == 0 ) then
|
||||
fib.imadeit = true
|
||||
World:SetBlock( x, y, z, E_BLOCK_GLASS, 0 )
|
||||
else
|
||||
fib.imadeit = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function cCarpet:moveTo( NewPos )
|
||||
local x = math.floor( NewPos.x )
|
||||
local y = math.floor( NewPos.y )
|
||||
local z = math.floor( NewPos.z )
|
||||
if( self.Location.x ~= x or self.Location.y ~= y or self.Location.z ~= z ) then
|
||||
self:remove()
|
||||
self.Location = cLocation:new( x, y, z )
|
||||
self:draw()
|
||||
end
|
||||
end
|
||||
|
||||
function cCarpet:getY()
|
||||
return self.Location.y
|
||||
end
|
||||
@@ -1,81 +0,0 @@
|
||||
local Carpets = {}
|
||||
local PLUGIN
|
||||
|
||||
function Initialize( Plugin )
|
||||
Plugin:SetName( "MagicCarpet" )
|
||||
Plugin:SetVersion( 2 )
|
||||
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving)
|
||||
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_DESTROYED, OnDisconnect)
|
||||
|
||||
local PluginManager = cPluginManager:Get()
|
||||
PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet");
|
||||
|
||||
PLUGIN = Plugin
|
||||
|
||||
LOG( "Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function OnDisable()
|
||||
LOG( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." )
|
||||
for i, Carpet in pairs( Carpets ) do
|
||||
Carpet:remove()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function HandleCarpetCommand( Split, Player )
|
||||
Carpet = Carpets[ Player ]
|
||||
|
||||
if( Carpet == nil ) then
|
||||
Carpets[ Player ] = cCarpet:new()
|
||||
Player:SendMessageSuccess("You're on a magic carpet!")
|
||||
Player:SendMessageInfo("Look straight down to descend. Jump to ascend.")
|
||||
else
|
||||
Carpet:remove()
|
||||
Carpets[ Player ] = nil
|
||||
Player:SendMessageSuccess("The carpet vanished!")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function OnDisconnect( Reason, Player )
|
||||
local Carpet = Carpets[ Player ]
|
||||
if( Carpet ~= nil ) then
|
||||
Carpet:remove()
|
||||
end
|
||||
Carpets[ Player ] = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function OnPlayerMoving(Player)
|
||||
local Carpet = Carpets[ Player ]
|
||||
if( Carpet == nil ) then
|
||||
return
|
||||
end
|
||||
|
||||
if( Player:GetPitch() == 90 ) then
|
||||
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY() - 1, Player:GetPosZ() ) )
|
||||
else
|
||||
if( Player:GetPosY() < Carpet:getY() ) then
|
||||
Player:TeleportToCoords(Player:GetPosX(), Carpet:getY() + 0.2, Player:GetPosZ())
|
||||
end
|
||||
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
|
||||
end
|
||||
end
|
||||
2
MCServer/webadmin/files/guest.html
Normal file
@@ -0,0 +1,2 @@
|
||||
Hello! Welcome to the MCServer WebAdmin.<br>
|
||||
This is a default message, edit <b>files/guest.html</b> to add your own custom message.
|
||||
BIN
MCServer/webadmin/files/header.png
Normal file
|
After Width: | Height: | Size: 221 B |
BIN
MCServer/webadmin/files/home.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
MCServer/webadmin/files/loading.gif
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
MCServer/webadmin/files/log_out.png
Normal file
|
After Width: | Height: | Size: 995 B |
219
MCServer/webadmin/files/login.css
Normal file
@@ -0,0 +1,219 @@
|
||||
/* Copyright Justin S and MCServer Team, licensed under CC-BY-SA 3.0 */
|
||||
* {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
background: #fff url(header.png) repeat-x top left;
|
||||
width: 100%;
|
||||
min-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #555;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #444;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover, a:active {
|
||||
color: #000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #069;
|
||||
}
|
||||
|
||||
.row1 {
|
||||
border-bottom: 1px solid #000;
|
||||
height: 100px;
|
||||
max-height: 100px;
|
||||
}
|
||||
|
||||
.row2 {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.contention {
|
||||
color: #000;
|
||||
text-align: left;
|
||||
line-height: 1.4;
|
||||
margin: 0;
|
||||
font-family: Tahoma,Verdana,Arial,Sans-Serif;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
button {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
border: 1px solid #ccc;
|
||||
padding: 3px;
|
||||
font-family: Tahoma,Verdana,Arial,Sans-Serif;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
margin: -3px 0;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
border-top-color: #28597a;
|
||||
background: #28597a;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
button:active {
|
||||
border-top-color: #1b435e;
|
||||
background: #1b435e;
|
||||
}
|
||||
|
||||
.push10 {
|
||||
padding-bottom: 75px;
|
||||
}
|
||||
|
||||
#panel .upper {
|
||||
background: #dcdbdc url(tcat.png) repeat-x;
|
||||
border-top: 1px solid #fff;
|
||||
border-bottom: 1px solid #bbb;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
z-index: 99999;
|
||||
}
|
||||
|
||||
#footer ul.menu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#footer ul.menu li {
|
||||
margin: 0 5px;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#footer .upper {
|
||||
background: #dcdbdc url(tcat.png) repeat-x;
|
||||
border-top: 1px solid #bbb;
|
||||
padding: 6px;
|
||||
overflow: hidden;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#footer .upper ul.bottom_links {
|
||||
float: left;
|
||||
margin: 3px 0 0 -5px;
|
||||
}
|
||||
|
||||
#footer .lower {
|
||||
background: #a1a2a2 url(thead.png) top left repeat-x;
|
||||
color: #fff;
|
||||
border-top: 1px solid #ccc;
|
||||
border-bottom: 1px solid #ddd;
|
||||
overflow: hidden;
|
||||
padding: 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#footer .lower a:link, #footer .lower a:visited {
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#footer .lower a:hover, #footer .lower a:active {
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#footer .lower #current_time {
|
||||
float: right;
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
width: 85%;
|
||||
min-width: 970px;
|
||||
max-width: 1500px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#footer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
height: 60px;
|
||||
width: 100%;
|
||||
background: #999;
|
||||
border-top: 1px #000 solid;
|
||||
}
|
||||
|
||||
* html #footer {
|
||||
position: absolute;
|
||||
top: expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
|
||||
}
|
||||
|
||||
tr td.trow2:first-child {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
tr td.trow2:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.tborder {
|
||||
-moz-border-radius: 7px;
|
||||
-webkit-border-radius: 7px;
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
.thead, .rounded_top {
|
||||
-moz-border-radius-topleft: 6px;
|
||||
-moz-border-radius-topright: 6px;
|
||||
-webkit-border-top-left-radius: 6px;
|
||||
-webkit-border-top-right-radius: 6px;
|
||||
border-top-left-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
}
|
||||
|
||||
table {
|
||||
color: #000;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.tborder {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
border: 1px solid #ccc;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.thead {
|
||||
background: #a1a2a2 url(thead.png) top left repeat-x;
|
||||
color: #fff;
|
||||
border-bottom: 1px solid #8e8f8f;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.trow2 {
|
||||
background: #efefef;
|
||||
border: 1px solid;
|
||||
border-color: #fff #ddd #ddd #fff;
|
||||
}
|
||||
|
||||
.padtopp {
|
||||
padding-top: 25px;
|
||||
}
|
||||
BIN
MCServer/webadmin/files/login.gif
Normal file
|
After Width: | Height: | Size: 586 B |
BIN
MCServer/webadmin/files/logo_login.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
MCServer/webadmin/files/pmfolder.gif
Normal file
|
After Width: | Height: | Size: 995 B |
@@ -1,326 +1,427 @@
|
||||
/* reset CSS */
|
||||
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
/* Copyright Justin S and MCServer Team, licensed under CC-BY-SA 3.0 */
|
||||
* {
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
|
||||
/* remember to define focus styles! */
|
||||
:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
/* remove textarea resize at Safari */
|
||||
textarea {
|
||||
resize: none;
|
||||
}
|
||||
|
||||
/* remember to highlight inserts somehow! */
|
||||
ins {
|
||||
text-decoration: none;
|
||||
}
|
||||
del {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
/* tables still need 'cellspacing="0"' in the markup */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Origional from http://www.perspectived.com/
|
||||
Modified by Ben Phelps
|
||||
Made for FakeTruth - MCServer
|
||||
*/
|
||||
|
||||
/* Basic ---------------------------------------- */
|
||||
|
||||
.clear { clear: both; }
|
||||
|
||||
body {
|
||||
background: white;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
color: #646464;
|
||||
text-align: center;
|
||||
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
min-width: 100%;
|
||||
height:100%;
|
||||
min-height:100%;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
text-align: left;
|
||||
width: 930px;
|
||||
margin: 0 auto;
|
||||
a:link {
|
||||
color: #555;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Logo ---------------------------------------- */
|
||||
a:visited {
|
||||
color: #444;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover, a:active {
|
||||
color: #000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 15px 0 10px 5px;
|
||||
width: 180px;
|
||||
height: 36px;
|
||||
background: url(logo.png) no-repeat left top;
|
||||
color: #069;
|
||||
text-shadow: 2px 2px #000;
|
||||
}
|
||||
|
||||
h1 a {
|
||||
display: block;
|
||||
width: 225px;
|
||||
height: 28px;
|
||||
.row1 {
|
||||
border-bottom: 1px #000 solid;
|
||||
height: 100px;
|
||||
max-height: 100px;
|
||||
background: #fff url(header.png) repeat-x top left;
|
||||
}
|
||||
|
||||
h1 span { display: none; }
|
||||
.row2 {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
margin-top: 25px;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.contention {
|
||||
color: #000;
|
||||
text-align: left;
|
||||
line-height: 1.4;
|
||||
margin: 0;
|
||||
font-family: Tahoma,Verdana,Arial,Sans-Serif;
|
||||
font-size: 13px;
|
||||
margin-bottom:75px;
|
||||
}
|
||||
|
||||
.push25 {
|
||||
}
|
||||
|
||||
#panel ul.menu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#panel ul.menu li {
|
||||
margin: 0 5px;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#panel ul.menu li a {
|
||||
padding-left: 20px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
}
|
||||
|
||||
#panel .upper ul.top_links {
|
||||
float: right;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#panel .upper {
|
||||
background: #dcdbdc url(tcat.png) repeat-x;
|
||||
border-top: 1px solid #fff;
|
||||
border-bottom: 1px solid #bbb;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
#footer ul.menu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#footer ul.menu li {
|
||||
margin: 0 5px;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#footer .upper {
|
||||
background: #dcdbdc url(tcat.png) repeat-x;
|
||||
border-top: 1px solid #bbb;
|
||||
padding: 6px;
|
||||
overflow: hidden;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#footer .upper ul.bottom_links {
|
||||
float: left;
|
||||
margin: 3px 0 0 -5px;
|
||||
}
|
||||
|
||||
#footer .lower {
|
||||
background: #a1a2a2 url(thead.png) top left repeat-x;
|
||||
color: #fff;
|
||||
border-top: 1px solid #ccc;
|
||||
border-bottom: 1px solid #ddd;
|
||||
overflow: hidden;
|
||||
padding: 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#footer .lower a:link,#footer .lower a:visited {
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#footer .lower a:hover,#footer .lower a:active {
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#footer .lower #current_time {
|
||||
float: right;
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
width: 85%;
|
||||
min-width: 970px;
|
||||
max-width: 1500px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#footer {
|
||||
position: fixed;
|
||||
left:0;
|
||||
bottom:0;
|
||||
height: 61px;
|
||||
width: 100%;
|
||||
background: #999;
|
||||
border-top: 1px #000 solid;
|
||||
border-bottom: 1px #000 solid;
|
||||
}
|
||||
|
||||
* html #footer {
|
||||
position: absolute;
|
||||
top: expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
|
||||
}
|
||||
|
||||
tr td.trow1:first-child, tr td.trow2:first-child {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
tr td.trow1:last-child, tr td.trow2:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.tborder {
|
||||
-moz-border-radius: 7px;
|
||||
-webkit-border-radius: 7px;
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
.thead {
|
||||
-moz-border-radius-topleft: 6px;
|
||||
-moz-border-radius-topright: 6px;
|
||||
-webkit-border-top-left-radius: 6px;
|
||||
-webkit-border-top-right-radius: 6px;
|
||||
border-top-left-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
}
|
||||
|
||||
table {
|
||||
color: #000;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.tborder {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
border: 1px solid #ccc;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.thead {
|
||||
background: #a1a2a2 url(thead.png) top left repeat-x;
|
||||
color: #fff;
|
||||
border-bottom: 1px solid #8e8f8f;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.tcat {
|
||||
background: #dcdbdc url(tcat.png) repeat-x;
|
||||
color: #fff;
|
||||
border-bottom: 1px solid #bbb;
|
||||
padding: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.trow1 {
|
||||
background: #f5f5f5;
|
||||
border: 1px solid;
|
||||
border-color: #fff #ddd #ddd #fff;
|
||||
}
|
||||
|
||||
.trow2 {
|
||||
background: #efefef;
|
||||
border: 1px solid;
|
||||
border-color: #fff #ddd #ddd #fff;
|
||||
padding: 15px;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
}
|
||||
|
||||
table {
|
||||
color: #000;
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tborder {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
border: 1px solid #ccc;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
.thead {
|
||||
background: #a1a2a2 url(thead.png) top left repeat-x;
|
||||
color: #fff;
|
||||
border-bottom: 1px solid #8e8f8f;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.tcat {
|
||||
background: #dcdbdc url(tcat.png) repeat-x;
|
||||
color: #fff;
|
||||
border-bottom: 1px solid #bbb;
|
||||
padding: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.trow1 {
|
||||
background: #f5f5f5;
|
||||
border: 1px solid;
|
||||
border-color: #fff #ddd #ddd #fff;
|
||||
}
|
||||
|
||||
.trow2 {
|
||||
background: #efefef;
|
||||
border: 1px solid;
|
||||
border-color: #fff #ddd #ddd #fff;
|
||||
}
|
||||
|
||||
.smalltext {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
border: 1px solid #ccc;
|
||||
padding: 2px;
|
||||
line-height: 1.4;
|
||||
font-family: Tahoma,Verdana,Arial,Sans-Serif;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
select {
|
||||
background: #fff;
|
||||
padding: 3px;
|
||||
border: 1px solid #ccc;
|
||||
font-family: Tahoma,Verdana,Arial,Sans-Serif;
|
||||
}
|
||||
|
||||
.usercp_nav_item {
|
||||
display: block;
|
||||
padding: 1px 0 1px 23px;
|
||||
}
|
||||
|
||||
.usercp_nav_pmfolder {
|
||||
background: url(pmfolder.gif) no-repeat left center;
|
||||
}
|
||||
|
||||
.usercp_nav_sub_pmfolder {
|
||||
padding-left: 40px;
|
||||
background: url(sub_pmfolder.gif) no-repeat left center;
|
||||
}
|
||||
|
||||
.usercp_nav_home {
|
||||
background: url(home.gif) no-repeat left center;
|
||||
}
|
||||
|
||||
.pagehead {
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table th {
|
||||
border-bottom: 1px solid rgba(0,0,0,0.12);
|
||||
padding: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
table tr:nth-child(odd) {
|
||||
background-color: rgba(0,0,0,0.015);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0;
|
||||
padding: 4px 3px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #646464;
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
-webkit-transition: color .1s linear;
|
||||
-moz-transition: color .1s linear;
|
||||
transition: color .1s linear;
|
||||
}
|
||||
|
||||
/* Container ---------------------------------------- */
|
||||
|
||||
#containerHolder {
|
||||
background: #eee;
|
||||
padding: 5px;
|
||||
a:hover {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
|
||||
#container {
|
||||
background: #fff url(background.gif) repeat-y left top;
|
||||
border: 1px solid #ddd;
|
||||
width: 918px;
|
||||
|
||||
input[type="text"] {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
border: 1px solid #ccc;
|
||||
padding: 2px;
|
||||
line-height: 1.4;
|
||||
font-family: Tahoma,Verdana,Arial,Sans-Serif;
|
||||
font-size: 13px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#connectHolder {
|
||||
background: #eee;
|
||||
padding: 5px;
|
||||
margin-bottom:8px;
|
||||
input[type="text"]:hover {
|
||||
background-color: #E5E4E2;
|
||||
}
|
||||
|
||||
|
||||
#connect {
|
||||
border: 1px solid #ddd;
|
||||
background-color: #fff;
|
||||
padding:5px;
|
||||
width: 908px;
|
||||
input[type="text"]:focus {
|
||||
background-color: #E5E4E2;
|
||||
}
|
||||
|
||||
.pics {
|
||||
height: 375px;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
.pics img {
|
||||
padding: 5px;
|
||||
border: 1px solid #ddd;
|
||||
background-color: #eee;
|
||||
width: 600px;
|
||||
height: 375px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
/* Login -------------------------------------- */
|
||||
|
||||
#loginLogo {
|
||||
margin: 0 auto;
|
||||
margin-top:100px;
|
||||
width: 180px;
|
||||
height: 36px;
|
||||
background-image: url(logo.png);
|
||||
}
|
||||
|
||||
#loginHolder {
|
||||
background: #eee;
|
||||
padding: 5px;
|
||||
width: 310px;
|
||||
margin: 0 auto;
|
||||
height: 90px;
|
||||
margin-top:20px;
|
||||
}
|
||||
|
||||
#login {
|
||||
padding:10px;
|
||||
width: 288px;
|
||||
height: 68px;
|
||||
border: 1px solid #ddd;
|
||||
background:#fff;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
/* Sidebar ---------------------------------------- */
|
||||
|
||||
#sidebar {
|
||||
width: 179px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#sidebar .sideNav { width: 179px; }
|
||||
|
||||
#sidebar .sideNav li { border-bottom: 1px solid #ddd; width: 179px; }
|
||||
|
||||
#sidebar .sideNav li a {
|
||||
display: block;
|
||||
color: #646464;
|
||||
background: #f6f6f6;
|
||||
text-decoration: none;
|
||||
height: 29px;
|
||||
line-height: 29px;
|
||||
padding: 0 19px;
|
||||
width: 141px;
|
||||
}
|
||||
|
||||
#sidebar .sideNav li a:hover { background: #fdfcf6; }
|
||||
|
||||
#sidebar .sideNav li a.active, #sidebar .sideNav li a.active:hover {
|
||||
background: #f0f7fa;
|
||||
color: #c66653;
|
||||
}
|
||||
|
||||
/* Breadcrumb ---------------------------------------- */
|
||||
|
||||
h2 {
|
||||
width: 718px;
|
||||
float: right;
|
||||
color: #646464;
|
||||
font-size: 16px;
|
||||
line-height: 16px;
|
||||
font-weight: bold;
|
||||
margin: 20px 0 0 0;
|
||||
padding: 0 0 10px 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
h2 a {
|
||||
color: #646464;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h2 a.active { color: #c66653; }
|
||||
|
||||
h2 a:hover { text-decoration: underline; }
|
||||
|
||||
/* Content ---------------------------------------- */
|
||||
|
||||
#main {
|
||||
width: 700px;
|
||||
float: right;
|
||||
padding: 0 19px 0 0;
|
||||
}
|
||||
|
||||
#main p {
|
||||
|
||||
padding: 10px;
|
||||
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 14px;
|
||||
line-height: 14px;
|
||||
font-weight: bold;
|
||||
color: #5494af;
|
||||
padding: 0 0 0 10px;
|
||||
margin: 20px 0 10px;
|
||||
hr {
|
||||
border: none;
|
||||
height: 1px;
|
||||
background-color: rgba(0,0,0,0.12);
|
||||
}
|
||||
|
||||
h4 {
|
||||
padding: 0 0 0 10px;
|
||||
margin: 20px 0 10px;
|
||||
padding-bottom: 10px;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid rgba(0,0,0,0.12);
|
||||
}
|
||||
|
||||
#main ul {
|
||||
padding: 0 0 0 10px;
|
||||
list-style-type: circle;
|
||||
list-style-position: inside;
|
||||
#ChatDiv {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#main table {
|
||||
border-top: 1px solid #ddd;
|
||||
width: 700px;
|
||||
#ChatMessage {
|
||||
width: 92%;
|
||||
margin-right: 5px;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
}
|
||||
|
||||
#main table tr th {
|
||||
text-align: left;
|
||||
background: #f6f6f6;
|
||||
padding: 0px 20px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
input[type="submit"] {
|
||||
padding: 3px;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
cursor: pointer;
|
||||
font-family: Tahoma,Verdana,Arial,Sans-Serif;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
background: #f5f5f5;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
#main table tr td {
|
||||
background: #f6f6f6;
|
||||
padding: 0px 20px;
|
||||
height: 29px;
|
||||
line-height: 29px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
input[type="submit"]:hover {
|
||||
background-color: #E5E4E2;
|
||||
}
|
||||
|
||||
#main table tr.odd td {
|
||||
background: #fbfbfb;
|
||||
button:disabled,input:disabled {
|
||||
padding: 3px;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
cursor: pointer;
|
||||
font-family: Tahoma,Verdana,Arial,Sans-Serif;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
border: none!important;
|
||||
color: #fff!important;
|
||||
background-color: #ccc!important;
|
||||
}
|
||||
|
||||
#main table tr:hover td { background: #fdfcf6; }
|
||||
|
||||
#main table .action {
|
||||
text-align: right;
|
||||
padding: 0 20px 0 10px;
|
||||
}
|
||||
|
||||
#main table tr .action a { margin: 0 0 0 10px; text-decoration: none; color: #9b9b9b; }
|
||||
#main table tr:hover .action .edit { color: #c5a059; }
|
||||
#main table tr:hover .action .delete { color: #a02b2b; }
|
||||
#main table tr:hover .action .view { color: #55a34a; }
|
||||
|
||||
#main table tr:hover .action a:hover { text-decoration: underline; }
|
||||
|
||||
fieldset {
|
||||
border: 1px solid #ddd;
|
||||
padding: 19px;
|
||||
margin: 0 0 20px 0;
|
||||
background: #fbfbfb;
|
||||
}
|
||||
|
||||
form p { margin: 0 0 14px 0; float: left; width: 100%; }
|
||||
|
||||
label {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin: 0 0 7px 0;
|
||||
line-height: 12px;
|
||||
}
|
||||
|
||||
/* Footer ---------------------------------------- */
|
||||
|
||||
#footer {
|
||||
margin: 10px 0 30px 0;
|
||||
font-size: 11px;
|
||||
line-height: 11px;
|
||||
color: #9B9B9B;
|
||||
padding: 0 0 0 5px;
|
||||
}
|
||||
|
||||
#footer a { color: #9B9B9B; }
|
||||
|
||||
#footer a:hover { text-decoration: none; }
|
||||
|
||||
BIN
MCServer/webadmin/files/sub_pmfolder.gif
Normal file
|
After Width: | Height: | Size: 1022 B |
BIN
MCServer/webadmin/files/tcat.png
Normal file
|
After Width: | Height: | Size: 183 B |
BIN
MCServer/webadmin/files/thead.png
Normal file
|
After Width: | Height: | Size: 132 B |
@@ -1,25 +1,69 @@
|
||||
<!-- Copyright Justin S and MCServer Team, licensed under CC-BY-SA 3.0 */ -->
|
||||
<html>
|
||||
<head>
|
||||
<title>MCServer WebAdmin - Login</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link href="login.css" rel="stylesheet" type="text/css">
|
||||
<link rel="icon" href="favicon.ico">
|
||||
<style type="text/css">
|
||||
header {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<img src="mc-logo.png" alt="MCServer Logo" class="logo">
|
||||
<h1>MCServer - WebAdmin</h1>
|
||||
<form method="get" action="webadmin/">
|
||||
<input type="submit" value="Log in">
|
||||
</form>
|
||||
</header>
|
||||
<div class="contention">
|
||||
<div class="row1">
|
||||
<div class="wrapper">
|
||||
<img src="logo_login.png" alt="MCServer Logo" class="logo">
|
||||
</div>
|
||||
</div>
|
||||
<div id="panel">
|
||||
<div class="upper">
|
||||
<div class="wrapper">
|
||||
<div>
|
||||
<form method="get" action="webadmin/" />
|
||||
<button type="submit" value="Log in" style="width:150px;height:25px;font-family:'Source Sans Pro',sans-serif;background:transparent;border:none!important;vertical-align:middle">
|
||||
<strong><img src="login.gif" style="vertical-align:bottom" /> WebAdmin Log in</strong>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row2 push10">
|
||||
<div class="wrapper padtopp">
|
||||
<table border="0" cellspacing="0" cellpadding="5" class="tborder" style="margin-bottom:5px">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="thead rounded_top">
|
||||
<div style="float:left!important"><strong>MCServer WebAdmin</strong></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow2 post_content">
|
||||
<div class="post_body">
|
||||
<iframe width="100%" height="100%" style="border:none;min-height:350px;max-height:450px" src="/guest.html"></iframe>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div class="upper">
|
||||
<div class="wrapper">
|
||||
<ul class="menu bottom_links">
|
||||
<li><a href="http://www.mc-server.org" target="_blank">MCServer</a></li>
|
||||
<li><a href="http://forum.mc-server.org" target="_blank">Forums</a></li>
|
||||
<li><a href="http://builds.cuberite.org" target="_blank">Buildserver</a></li>
|
||||
<li><a href="http://mc-server.xoft.cz/LuaAPI" target="_blank">API Documentation</a></li>
|
||||
<li><a href="http://book.mc-server.org/" target="_blank">User's Manual</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lower">
|
||||
<div class="wrapper">
|
||||
<span id="copyright">Copyright © <a href="http://www.mc-server.org" target="_blank">MCServer Team</a> 2014.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -1,129 +1,140 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{TITLE} | {PLUGIN_NAME}</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
line-height: 1;
|
||||
background: #B8B8B8;
|
||||
}
|
||||
|
||||
#maincontent {
|
||||
padding: 0px 25px 10px 25px;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
min-width: 850px;
|
||||
width: 75%;
|
||||
margin: 10px auto;
|
||||
background-color: white;
|
||||
border: 4px #888888 solid;
|
||||
border-radius: 10px;
|
||||
font-family: Calibri, Trebuchet MS;
|
||||
}
|
||||
|
||||
header {
|
||||
text-align:center;
|
||||
padding: 10px; 0px;
|
||||
}
|
||||
|
||||
span {
|
||||
text-align: right;
|
||||
float: right;
|
||||
border-left: 2px #C8C8C8 solid;
|
||||
border-bottom: 2px #C8C8C8 solid;
|
||||
padding: 2px 10px;
|
||||
}
|
||||
|
||||
footer {
|
||||
font-family: helvetica;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
border-top: 1px #000 dotted;
|
||||
padding: 1px 0px 1px 0px;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 10;
|
||||
}
|
||||
|
||||
table {
|
||||
border-top: 1px solid #ddd;
|
||||
width: 700px;
|
||||
}
|
||||
|
||||
table tr th {
|
||||
text-align: left;
|
||||
background: #f6f6f6;
|
||||
padding: 0px 20px;
|
||||
height: 25px;
|
||||
line-height: 25px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
table tr td {
|
||||
background: #f6f6f6;
|
||||
padding: 0px 20px;
|
||||
height: 29px;
|
||||
line-height: 29px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
}
|
||||
#main table tr.odd td {
|
||||
background: #fbfbfb;
|
||||
}
|
||||
|
||||
table tr:hover td { background: #fdfcf6; }
|
||||
table .action {
|
||||
text-align: right;
|
||||
padding: 0 20px 0 10px;
|
||||
}
|
||||
|
||||
table tr .action a { color: #9b9b9b; }
|
||||
|
||||
#cssmenu{ height:10px; display:table; padding:0; margin: 0 auto; border:1px #707070 solid; border-radius:5px; }
|
||||
#cssmenu > ul {list-style:inside none; padding:0; margin:0;}
|
||||
#cssmenu > ul > li {list-style:inside none; padding:0; margin:0; float:left; display:block; position:relative;}
|
||||
#cssmenu > ul > li > a{ outline:none; display:block; position:relative; color:#E8E8E8; padding:10px 10px; font:bold 13px/100% Arial, Helvetica, sans-serif; text-align:center; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.4); }
|
||||
#cssmenu > ul > li:first-child > a{border-radius:5px 0 0 5px;}
|
||||
/* #cssmenu > ul > li > a:after{ content:''; position:absolute; border-right:1px solid #FFFFFF; top:-1px; bottom:-1px; right:-2px; z-index:99; } */
|
||||
#cssmenu ul li.has-sub:hover > a:after{top:0; bottom:0;}
|
||||
#cssmenu > ul > li.has-sub > a:before{ content:''; position:absolute; top:18px; right:6px; border:5px solid transparent; border-top:5px solid #707070; }
|
||||
#cssmenu > ul > li.has-sub:hover > a:before{top:19px;}
|
||||
#cssmenu ul li.has-sub:hover > a{ background:#3f3f3f; border-color:#707070; padding-bottom:13px; padding-top:13px; top:-1px; z-index:999; }
|
||||
#cssmenu ul li.has-sub:hover > ul, #cssmenu ul li.has-sub:hover > div{display:block;}
|
||||
#cssmenu ul li.has-sub > a:hover{background:#3f3f3f; border-color:#3f3f3f;}
|
||||
#cssmenu ul li > ul, #cssmenu ul li > div{ display:none; width:auto; position:absolute; top:38px; padding:10px 0; background:#3f3f3f; border-radius:0 0 5px 5px; z-index:999; }
|
||||
#cssmenu ul li > ul{width:200px;}
|
||||
#cssmenu ul li > ul li{display:block; list-style:inside none; padding:0; margin:0; position:relative;}
|
||||
#cssmenu ul li > ul li a{ outline:none; display:block; position:relative; margin:0; padding:8px 20px; font:10pt Arial, Helvetica, sans-serif; color:#fff; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.5); }
|
||||
#cssmenu, #cssmenu > ul > li > ul > li a:hover{ background:#C8C8C8;}
|
||||
#cssmenu > ul > li > a{border-right:1px solid #707070; color:#FFFFFF;}
|
||||
#cssmenu > ul > li > a:after{border-color:#707070;}
|
||||
#cssmenu > ul > li > a:hover{background:#B8B8B8;}
|
||||
</style>
|
||||
<meta name="msapplication-tooltip" content="MCServer WebAdministrator"/>
|
||||
<meta name="msapplication-navbutton-color" content="#B8B8B8" />
|
||||
<link rel="shortcut icon" href="http://mc-server.org/favicon.ico" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<span><b>Login: {USERNAME}</b></span><br />
|
||||
<header>
|
||||
<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAAkCAMAAAAXdeBDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAuVQTFRFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs7OzAAAAAAAAoqKiAAAAvLy8AAAAlZWVtbW1j4+Pra2tiYmJp6enAAAAhISEoaGhAAAAgICAm5ube3t7lZWVd3d3kZGRc3NzjIyMbGxsg4ODgICAeHh43NzcdXV1cnJyy8vLWVlZbGxswcHB09PTvLy8uLi4tLS0sLCwvLy8uLi4tbW1oaGhnp6era2tm5ubqqqq39/f29vblZWV09PT4ODgz8/P3NzckZGRxcXF0tLSwsLCzs7Oy8vLyMjIt7e3vLy85ubm7u7u3d3d5+fn2tra5OTk19fX1dXV3t7e29vb2dnZ1tbW0dHRv7+/8PDw7u7u6+vr8fHx5ubm4+Pj7Ozs4eHh3t7e5+fn5OTk2tra4uLi39/f1dXV3d3d29vb2dnZ19fX1dXV0tLS9fX18/Pzzs7O7u7u8/PzycnJ6urq6Ojo7+/v5ubm7Ozs4+Pj4eHh39/f5ubm5OTk4uLi4ODg2NjY3Nzc29vb19fX8vLy9/f39fX17e3t8/Pz6+vr8fHx7+/v5+fn7e3t5eXl6+vr6enp6Ojo4ODg39/f9PT0+Pj48fHx9vb27+/v9PT07e3t8/Pz7Ozs8fHx7+/v6Ojo7u7u5+fn7Ozs5eXl6urq5OTk6enp5+fn5ubm5OTk+Pj49/f39fX19PT0+fn58vLy8fHx9fX19PT08vLy8fHx6urq+Pj49vb29fX19PT08vLy8PDw+/v7+vr6+Pj49/f39vb29fX18/Pz/f39+/v7+vr6+fn5+Pj49/f3/f39/Pz8+vr6/v7+/f39a5KrdZmxf6G2iai8kq/BnLbHpr7NsMXSuszYxNPdxmZTynBeznpqztvj0YV11Y+B2OLp2ZmM3aOY4a2j4enu5Liv6MK66/D07MzG8NbR9ODd9fj59+vo+/X0ucu1kQAAANl0Uk5TAAECAwQFBgcICQoLDA0ODxAREhMUFBUWFhcXGBgYGRkaGhsbGxwcHB0dHh4fHyEhIiQkJSYnKCgpKSorLC0uLzAxMjIzMzc4Ojo6Ozs8Pj4/P0BBQ0VISUtLTExNTk5PUFFTV1dYWVpbXFxdXl5fYGBhYmJjZGVmZ2doaWprbGxtbW5ub3BxcXJzdHV2d3l6e3x9fX5+f4CAgYGCg4SIi4yNjY6Oj4+QkJGSkpOTlJSVlZaXmJqbnJ2dnp+foKGip6+wsbKztb6/wMHCw8TOz9DR0tPf4OHv8LXp8fEAAAi/SURBVHja3Zh/dBRXFcdhZ+a9eTPzZnaXmJam0FYUEQWLrVVbqdZaf6EWQW2txN/SWiAmxFqtIlWr9bdWqkbwF6WQYIq/+WFpwSZqTahhg6RhNptkl9nsbjeb2eyv+dv73g6wlcyewXMazvGek3Dm5jLv8+689733vTn/q81ldr5zzsWxuVWr55sbCAiiBCYKAeZ1nYIgigJ4Zh2Zj+0OXesTgQ987pOEZUVVVYXISIJQPi3mJETG0kXADggIL5CRWDMy57kCaDgdBMgK1de0gi2jGsESZJt5iXpjS8utGkHiLFMDIHrNgfJBFYs1i0Ei73iifIAggIEHrNDWnuGpFFg50vEKVYbcArNye0+lUCj13aUgYbahRbInbqbu1zAf2XXpR8bN1CZZYItA1jb0pcaiJrdYorxzIRYFYN7qZC2wTOVXMuR+dqGR2hU3Y4NLFSlwJtGIfmbKNFOt4BIkQndOj5rR8dMpsETMjCae+gASJbLKSSftUsWeSJbWz3aqgXBvPGomOnWWajfRoWOjAN2uIWBedOh0NJoYPvJgW1tb+47I1Jg5Vl6AsPrkZLLU+f5bdjjpzNOzDo1pdzw2Fi2vVlBVFgRMf5oyYXl8lmIk00MJc7S8e6mhU02jerC5JzFavgyRlztWbl9j2NC3lvJbpMDFgJ6Ojh/VZb4XA5KycmhkNAXQOpG1ncDfv9HQQNsQZsK3cNvTn5SQ0lKwCveEdYWQd25BrugxUQHjAl/fPKL9Q2t747F/x82pjSpXC0Gme+EJoNt1Vb2jHI1FVlMmawFWYiQgB6mWCIcOaVgCA2ZX3BEGQyI4vAsXWN1of9Bd8diJZ0dG+3QiwuSRsq4cHf8rgzao3jMWnX5Al88oMdNnAQRPlOlwMrcvrBMYk2WrWmyIqlGqqYRJPE+kwK2a0Jr8wo9nNPzRL/QvTpupH4HsAQ4DLX+ZQQeNN02b8W6DSLWVh5mA+EbcHaKkWhF5sdGWdfREIj0dyzSCBDAJY1nGCKo/r/9uguEB/uQZLQZ8Qe+JxwZffGx0ZGixgiSsbXzOTDz2RQYdDm1PmFNrNXTee+ZKMpO8fP+DhiYjAGLF5oYux86m01nb6bqBACr+4Id1/cZHH7pUxne+HkE63fp7522A5xn9IiHgF7ppM6DuokRWjD7Av+7zDHrevEgsFgkq0vndnVtcMvmhjkUKJFvEyqf7ckkrmU7Dr1zfXQTLXyoWv95ZydnblB8UKut5BYL/Rw4Uih9S6Qav6B9CnD/oSGPj0fFouVmn+sOwUH7W9DmmHg0Nw9H4Xp0IM1Z/KOOFjDVhR7ZqMpbVO5yMlS2eGhw8VYTJOC9RtOPp9Ak7adk/picnMv/UZL5jyO0ly+4INntGP+QfOhxeXY6O9c4L31QeGettaLyHQTeuKJsALQdm3PyI0Na+UtZKl3ZSjS7uzVr23z7e0Nj00t8Wk2nnZaoeSadtK1s6uJD+xLYKLSBOTJp6sklnxXLP6AOXin6XRyRoGLsS5nObm34HctccCrdz6GsYNJ0JmquFrOjNvcV0srQrFN5tW/bh5aHQvPm/KQHFVkULDsK3n/x7s0bURZDqPtAg+DxrSlau+5JOz2gVCX434nGod4uhpDzzielo/HFdD7bXzbSbbBHJmvEAbMjK5qZTyUz/8qCuhzsZxf0qUUODaSt94n06rB3aYVulZhVLMgXRcd5SL1oM+IamCtEeTpmn/wFyt1JV9ba6a9qlZtgKUE9kjn0vb+W/FdapsYtTaBgrDCP/3bAiQX4XD01ke6B8qisdkPf5364TDcy+oQkmRu/YyGmmITKhbXXVwy10DFtSgjsgjX/KWc41IeMshQj+wTT4dBxg3cx2iGHbvCuXdN58yb560XP8Q8sSUpunzOho/xICX73trE5P33yeTgOre0KDNYLp1Y5l/xkwrm0In6UICMSArTUYVmHGMLNlTjLbGw69chj+aWjorhftHxoECWrh43HoouEluAodNNZMzVQRWQty2wJJ5NRIexU0fAz6tU2dVQomyVUM+ExCtXGspvjnLOGh0N460RcELQQkcn15/AnAFxCHbvPqPUSE9xedKyBDHPpqBm1blXc/5lKwfkRSOIbBNwQ8vQEW8x+uexaWtqEb2z2jLxSaadjb/vJWLAUCLnRtlye4bQ7CYPK7Slb+ayrMhfUqt1Ss/PeLlv17RvFVqsisEcQqx2C7+FyqfwmJXqcp2ke9oi8YGl4tSkgSAM6Fph799KcU7SSkLEgJxoSGYYVW3v5MZqIAFN8I65qqvu6RLUQLcgx4r9ukO0n7X5lsr04w0fu9on1CI5VDY4F/fN5DAnRriq3u2pMLrTm5XKVBjcvvDoPTCO8uJSePzr+3YFlp5ztNDUEjuO6pXP4rtAaDp/rI5ETBKn5MRbDl2zyifUMrDFrFgdoeTuHQyrkz4hCcEcF29PMz4lXKlVAk8r3fXHtzey8rw+8JzTtsW5POH++9dkV7twM1ehtlH/w4K6duqteWLCgphiyyJeUd7cMAkDwK0AQ9D5psAuhN5NxpfMQ9jY/y07gsK6ucSSubL1UKWYttJ5UuBY5kruA4BWjf7IOXqxRaoLPJgK5Dh36j0Mo6EJjBEo9on9AifiQeG8BSLbSA7wbou7HHvYcsSUhZ9aQ9YYFN5CJbVRnJ6pLDxYzFLVM8dDkhykA6PSDDe91UQ39X7fV4i+gZ7ceA6tW/HviCVNumwAh4f3k/ljxvmAQBkSs7TpYKheLQnusVJIIMErqxr1TI5QqVvg0gZAjfNzBwH3Lfy0DJeod31ezBO9qXsfOPexqqnQlagGa8y1MJFqviB85bW1o+QiHNTHEENrn3tnZ1tb6RsmMBkyJUcznJ5PIyyRX8OtF+jEsGG/S/fPyIOdOtKZuf2+NhonAPBLqTI6qmKQTDLPhrmbjXjnPmuW60/wtqryt07/tp3oA8z8MdCHHXjBcC7mOd6Bfk7r3udC94aDf6/9T+AzWzIkAbVeu4AAAAAElFTkSuQmCC" />
|
||||
</header>
|
||||
<nav id="cssmenu">
|
||||
<ul>
|
||||
{MENU}
|
||||
</ul>
|
||||
</nav>
|
||||
<div id="maincontent">
|
||||
{CONTENT}
|
||||
<head>
|
||||
<title>{TITLE} | {PLUGIN_NAME}</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
line-height: 1;
|
||||
background: #B8B8B8;
|
||||
}
|
||||
|
||||
#maincontent {
|
||||
padding: 0px 25px 10px 25px;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
min-width: 850px;
|
||||
width: 75%;
|
||||
margin: 10px auto;
|
||||
background-color: white;
|
||||
border: 4px #888888 solid;
|
||||
border-radius: 10px;
|
||||
font-family: Calibri, Trebuchet MS;
|
||||
}
|
||||
|
||||
header {
|
||||
text-align:center;
|
||||
padding: 10px; 0px;
|
||||
}
|
||||
|
||||
span {
|
||||
text-align: right;
|
||||
float: right;
|
||||
border-left: 2px #C8C8C8 solid;
|
||||
border-bottom: 2px #C8C8C8 solid;
|
||||
padding: 2px 10px;
|
||||
}
|
||||
|
||||
footer {
|
||||
font-family: helvetica;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
border-top: 1px #000 dotted;
|
||||
padding: 1px 0px 1px 0px;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 10;
|
||||
}
|
||||
|
||||
table {
|
||||
border-top: 1px solid #ddd;
|
||||
width: 700px;
|
||||
}
|
||||
|
||||
table tr th {
|
||||
text-align: left;
|
||||
background: #f6f6f6;
|
||||
padding: 0px 20px;
|
||||
height: 25px;
|
||||
line-height: 25px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
table tr td {
|
||||
background: #f6f6f6;
|
||||
padding: 0px 20px;
|
||||
height: 29px;
|
||||
line-height: 29px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
#main table tr.odd td {
|
||||
background: #fbfbfb;
|
||||
}
|
||||
|
||||
table tr:hover td {
|
||||
background: #fdfcf6;
|
||||
}
|
||||
|
||||
table .action {
|
||||
text-align: right;
|
||||
padding: 0 20px 0 10px;
|
||||
}
|
||||
|
||||
table tr .action a {
|
||||
color: #9b9b9b;
|
||||
}
|
||||
|
||||
#cssmenu{ height:10px; display:table; padding:0; margin: 0 auto; border:1px #707070 solid; border-radius:5px; }
|
||||
#cssmenu > ul {list-style:inside none; padding:0; margin:0;}
|
||||
#cssmenu > ul > li {list-style:inside none; padding:0; margin:0; float:left; display:block; position:relative;}
|
||||
#cssmenu > ul > li > a{ outline:none; display:block; position:relative; color:#E8E8E8; padding:10px 10px; font:bold 13px/100% Arial, Helvetica, sans-serif; text-align:center; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.4); }
|
||||
#cssmenu > ul > li:first-child > a{border-radius:5px 0 0 5px;}
|
||||
/* #cssmenu > ul > li > a:after{ content:''; position:absolute; border-right:1px solid #FFFFFF; top:-1px; bottom:-1px; right:-2px; z-index:99; } */
|
||||
#cssmenu ul li.has-sub:hover > a:after{top:0; bottom:0;}
|
||||
#cssmenu > ul > li.has-sub > a:before{ content:''; position:absolute; top:18px; right:6px; border:5px solid transparent; border-top:5px solid #707070; }
|
||||
#cssmenu > ul > li.has-sub:hover > a:before{top:19px;}
|
||||
#cssmenu ul li.has-sub:hover > a{ background:#3f3f3f; border-color:#707070; padding-bottom:13px; padding-top:13px; top:-1px; z-index:999; }
|
||||
#cssmenu ul li.has-sub:hover > ul, #cssmenu ul li.has-sub:hover > div{display:block;}
|
||||
#cssmenu ul li.has-sub > a:hover{background:#3f3f3f; border-color:#3f3f3f;}
|
||||
#cssmenu ul li > ul, #cssmenu ul li > div{ display:none; width:auto; position:absolute; top:38px; padding:10px 0; background:#3f3f3f; border-radius:0 0 5px 5px; z-index:999; }
|
||||
#cssmenu ul li > ul{width:200px;}
|
||||
#cssmenu ul li > ul li{display:block; list-style:inside none; padding:0; margin:0; position:relative;}
|
||||
#cssmenu ul li > ul li a{ outline:none; display:block; position:relative; margin:0; padding:8px 20px; font:10pt Arial, Helvetica, sans-serif; color:#fff; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.5); }
|
||||
#cssmenu, #cssmenu > ul > li > ul > li a:hover{ background:#C8C8C8;}
|
||||
#cssmenu > ul > li > a { border-right:1px solid #707070; color:#FFFFFF; }
|
||||
#cssmenu > ul > li > a:after { border-color:#707070; }
|
||||
#cssmenu > ul > li > a:hover { background:#B8B8B8; }
|
||||
</style>
|
||||
<meta name="msapplication-tooltip" content="MCServer WebAdministrator"/>
|
||||
<meta name="msapplication-navbutton-color" content="#B8B8B8" />
|
||||
<link rel="shortcut icon" href="http://mc-server.org/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<span>
|
||||
<b>Login: {USERNAME}</b>
|
||||
</span>
|
||||
<br />
|
||||
<header>
|
||||
<img alt="" src="files/logo.png" />
|
||||
</header>
|
||||
<nav id="cssmenu">
|
||||
<ul>
|
||||
{MENU}
|
||||
</ul>
|
||||
</nav>
|
||||
<div id="maincontent">
|
||||
{CONTENT}
|
||||
</div>
|
||||
<footer>
|
||||
<p>MCServer is using {MEM}MB of memory, with {NUMCHUNKS} chunks loaded.</p>
|
||||
<p>Web Design by <a href="https://github.com/WebFreak001"@WebFreak001</a></p>
|
||||
</footer>
|
||||
</div>
|
||||
<footer><p>MCServer is using {MEM}MB of memory, with {NUMCHUNKS} chunks loaded.</p><p>Web Design by Tiger</p></footer>
|
||||
</div>
|
||||
</head>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -33,7 +33,7 @@ function GetDefaultPage()
|
||||
local AllPlugins = PM:GetAllPlugins()
|
||||
for key,value in pairs(AllPlugins) do
|
||||
if( value ~= nil and value ~= false ) then
|
||||
Content = Content .. "<li>" .. key .. " V." .. value:GetVersion() .. "</li>"
|
||||
Content = Content .. "<li>" .. key .. " (version " .. value:GetVersion() .. ")</li>"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,25 +70,67 @@ function ShowPage(WebAdmin, TemplateRequest)
|
||||
PageContent, SubTitle = GetDefaultPage()
|
||||
end
|
||||
|
||||
local reqParamsClass = ""
|
||||
|
||||
for key,value in pairs(TemplateRequest.Request.Params) do
|
||||
reqParamsClass = reqParamsClass .. " param-" .. string.lower(string.gsub(key, "[^a-zA-Z0-9]+", "-") .. "-" .. string.gsub(value, "[^a-zA-Z0-9]+", "-"))
|
||||
end
|
||||
|
||||
if (string.gsub(reqParamsClass, "%s", "") == "") then
|
||||
reqParamsClass = " no-param"
|
||||
end
|
||||
|
||||
Output([[
|
||||
<!DOCTYPE html>
|
||||
<!-- Copyright Justin S and MCServer Team, licensed under CC-BY-SA 3.0 -->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<title>]] .. Title .. [[</title>
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="/style.css">
|
||||
<title>]] .. Title .. [[</title>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
|
||||
<h1>
|
||||
<a href="]] .. BaseURL .. [["><span>MCServer</span></a>
|
||||
</h1>
|
||||
<div id="containerHolder">
|
||||
<div id="container">
|
||||
<div id="sidebar">
|
||||
<ul class="sideNav">
|
||||
<div class="contention push25">
|
||||
<div class="pagehead">
|
||||
<div class="row1">
|
||||
<div class="wrapper">
|
||||
<img src="/logo_login.png" alt="MCServer Logo" class="logo">
|
||||
</div>
|
||||
</div>
|
||||
<div id="panel">
|
||||
<div class="upper">
|
||||
<div class="wrapper">
|
||||
<ul class="menu top_links">
|
||||
<li><a>Server Name: <strong>]] .. cRoot:Get():GetServer():GetServerID() .. [[</strong></a></li>
|
||||
<li><a>Memory: <strong>]] .. MemoryUsageKiB / 1024 .. [[MB</strong></a></li>
|
||||
<li><a>Chunks: <strong>]] .. NumChunks .. [[</strong></a></li>
|
||||
</ul>
|
||||
<div class="welcome"><strong>Welcome back, ]] .. TemplateRequest.Request.Username .. [[</strong> <a href=".././"><img src="/log_out.png" style="vertical-align:bottom;"> Log Out</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row2">
|
||||
<div class="wrapper">
|
||||
<table width="100%" border="0" align="center">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="180" valign="top">
|
||||
<table border="0" cellspacing="0" cellpadding="5" class="tborder">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="thead"><strong>Menu</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow1 smalltext"><a href=']] .. BaseURL .. [[' class='usercp_nav_item usercp_nav_home'>Home</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tcat"><div><span class="smalltext"><strong><font color="#000">Server Management</font></strong></span></div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody style="" id="usercppms_e">
|
||||
<tr>
|
||||
<td class="trow1 smalltext">
|
||||
]])
|
||||
|
||||
|
||||
@@ -97,41 +139,62 @@ function ShowPage(WebAdmin, TemplateRequest)
|
||||
local PluginWebTitle = value:GetWebTitle()
|
||||
local TabNames = value:GetTabNames()
|
||||
if (GetTableSize(TabNames) > 0) then
|
||||
Output("<li>"..PluginWebTitle.."</li>\n");
|
||||
Output("<div><a class='usercp_nav_item usercp_nav_pmfolder' style='text-decoration:none;'><b>"..PluginWebTitle.."</b></a></div>\n");
|
||||
|
||||
for webname,prettyname in pairs(TabNames) do
|
||||
Output("<li><a href='" .. BaseURL .. PluginWebTitle .. "/" .. webname .. "'>" .. prettyname .. "</a></li>\n")
|
||||
Output("<div><a href='" .. BaseURL .. PluginWebTitle .. "/" .. webname .. "' class='usercp_nav_item usercp_nav_sub_pmfolder'>" .. prettyname .. "</a></div>\n")
|
||||
end
|
||||
|
||||
Output("<br>\n");
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Output([[
|
||||
</ul>
|
||||
<!-- // .sideNav -->
|
||||
</div>
|
||||
<!-- // #sidebar -->
|
||||
<!-- h2 stays for breadcrumbs -->
|
||||
<h2>Welcome ]] .. TemplateRequest.Request.Username .. [[</h2>
|
||||
<div id="main">
|
||||
<h3>]] .. SubTitle .. [[</h3>
|
||||
]] .. PageContent .. [[
|
||||
</div>
|
||||
<!-- // #main -->
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
<!-- // #container -->
|
||||
</div>
|
||||
<!-- // #containerHolder -->
|
||||
|
||||
<p id="footer">MCServer is using: ]] .. MemoryUsageKiB / 1024 .. [[ MiB of memory; Current chunk count: ]] .. NumChunks .. [[ </p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
<td valign="top" style='padding-left:25px;'>
|
||||
<table border="0" cellspacing="0" cellpadding="5" class="tborder">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="thead" colspan="2"><strong>]] .. SubTitle .. [[</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="trow2">]] .. PageContent .. [[</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- // #wrapper -->
|
||||
<div id="footer">
|
||||
<div class="upper">
|
||||
<div class="wrapper">
|
||||
<ul class="menu bottom_links">
|
||||
<li><a href="http://www.mc-server.org" target="_blank">MCServer</a></li>
|
||||
<li><a href="http://forum.mc-server.org" target="_blank">Forums</a></li>
|
||||
<li><a href="http://builds.cuberite.org" target="_blank">Buildserver</a></li>
|
||||
<li><a href="http://mc-server.xoft.cz/LuaAPI" target="_blank">API Documentation</a></li>
|
||||
<li><a href="http://book.mc-server.org/" target="_blank">User's Manual</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lower">
|
||||
<div class="wrapper">
|
||||
<span id="copyright">Copyright © <a href="http://www.mc-server.org" target="_blank">MCServer Team</a> 2014.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
]])
|
||||
]])
|
||||
|
||||
return table.concat(SiteContent)
|
||||
end
|
||||
|
||||
137
MCServer/webadmin/template_orig.lua
Normal file
@@ -0,0 +1,137 @@
|
||||
-- Use a table for fast concatenation of strings
|
||||
local SiteContent = {}
|
||||
function Output(String)
|
||||
table.insert(SiteContent, String)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function GetTableSize(Table)
|
||||
local Size = 0
|
||||
for key,value in pairs(Table) do
|
||||
Size = Size + 1
|
||||
end
|
||||
return Size
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function GetDefaultPage()
|
||||
local PM = cRoot:Get():GetPluginManager()
|
||||
|
||||
local SubTitle = "Current Game"
|
||||
local Content = ""
|
||||
|
||||
Content = Content .. "<h4>Server Name:</h4>"
|
||||
Content = Content .. "<p>" .. cRoot:Get():GetServer():GetServerID() .. "</p>"
|
||||
|
||||
Content = Content .. "<h4>Plugins:</h4><ul>"
|
||||
local AllPlugins = PM:GetAllPlugins()
|
||||
for key,value in pairs(AllPlugins) do
|
||||
if( value ~= nil and value ~= false ) then
|
||||
Content = Content .. "<li>" .. key .. " V." .. value:GetVersion() .. "</li>"
|
||||
end
|
||||
end
|
||||
|
||||
Content = Content .. "</ul>"
|
||||
Content = Content .. "<h4>Players:</h4><ul>"
|
||||
|
||||
local AddPlayerToTable = function( Player )
|
||||
Content = Content .. "<li>" .. Player:GetName() .. "</li>"
|
||||
end
|
||||
cRoot:Get():ForEachPlayer( AddPlayerToTable )
|
||||
|
||||
Content = Content .. "</ul><br>";
|
||||
|
||||
return Content, SubTitle
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function ShowPage(WebAdmin, TemplateRequest)
|
||||
SiteContent = {}
|
||||
local BaseURL = WebAdmin:GetBaseURL(TemplateRequest.Request.Path)
|
||||
local Title = "MCServer WebAdmin"
|
||||
local MemoryUsageKiB = cRoot:GetPhysicalRAMUsage()
|
||||
local NumChunks = cRoot:Get():GetTotalChunkCount()
|
||||
local PluginPage = WebAdmin:GetPage(TemplateRequest.Request)
|
||||
local PageContent = PluginPage.Content
|
||||
local SubTitle = PluginPage.PluginName
|
||||
if (PluginPage.TabName ~= "") then
|
||||
SubTitle = PluginPage.PluginName .. " - " .. PluginPage.TabName
|
||||
end
|
||||
if (PageContent == "") then
|
||||
PageContent, SubTitle = GetDefaultPage()
|
||||
end
|
||||
|
||||
Output([[
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<title>]] .. Title .. [[</title>
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<!-- h1 tag stays for the logo, you can use the a tag for linking the index page -->
|
||||
<h1>
|
||||
<a href="]] .. BaseURL .. [["><span>MCServer</span></a>
|
||||
</h1>
|
||||
<div id="containerHolder">
|
||||
<div id="container">
|
||||
<div id="sidebar">
|
||||
<ul class="sideNav">
|
||||
]])
|
||||
|
||||
|
||||
local AllPlugins = WebAdmin:GetPlugins()
|
||||
for key,value in pairs(AllPlugins) do
|
||||
local PluginWebTitle = value:GetWebTitle()
|
||||
local TabNames = value:GetTabNames()
|
||||
if (GetTableSize(TabNames) > 0) then
|
||||
Output("<li>"..PluginWebTitle.."</li>\n");
|
||||
|
||||
for webname,prettyname in pairs(TabNames) do
|
||||
Output("<li><a href='" .. BaseURL .. PluginWebTitle .. "/" .. webname .. "'>" .. prettyname .. "</a></li>\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Output([[
|
||||
</ul>
|
||||
<!-- // .sideNav -->
|
||||
</div>
|
||||
<!-- // #sidebar -->
|
||||
<!-- h2 stays for breadcrumbs -->
|
||||
<h2>Welcome ]] .. TemplateRequest.Request.Username .. [[</h2>
|
||||
<div id="main">
|
||||
<h3>]] .. SubTitle .. [[</h3>
|
||||
]] .. PageContent .. [[
|
||||
</div>
|
||||
<!-- // #main -->
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
<!-- // #container -->
|
||||
</div>
|
||||
<!-- // #containerHolder -->
|
||||
|
||||
<p id="footer">MCServer is using: ]] .. MemoryUsageKiB / 1024 .. [[ MiB of memory; Current chunk count: ]] .. NumChunks .. [[ </p>
|
||||
</div>
|
||||
<!-- // #wrapper -->
|
||||
</body>
|
||||
</html>
|
||||
]])
|
||||
|
||||
return table.concat(SiteContent)
|
||||
end
|
||||
26
README.md
@@ -1,28 +1,34 @@
|
||||
MCServer [](https://travis-ci.org/mc-server/MCServer) [](https://scan.coverity.com/projects/1930) [](http://tip4commit.com/projects/74)
|
||||
MCServer [](https://travis-ci.org/mc-server/MCServer) [](https://scan.coverity.com/projects/1930) [](http://gratipay.com/cuberite_team) [](http://tip4commit.com/projects/74)
|
||||
========
|
||||
|
||||
MCServer is a Minecraft server that is written in C++ and designed to be efficient with memory and CPU, as well as having a flexible Lua Plugin API.
|
||||
|
||||
MCServer can run on PCs, Macs, and *nix. This includes android phones and tablets as well as Raspberry Pis.
|
||||
MCServer can run on Windows, *nix and Android operating systems. This includes Android phones and tablets as well as Raspberry Pis.
|
||||
|
||||
We currently support the protocol from Minecraft 1.2 all the way up to Minecraft 1.8.
|
||||
We currently support Release 1.7 and 1.8 (not beta) Minecraft protocol versions.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Normally, you will want to download a pre-compiled version of MCServer from one of the buildservers:
|
||||
[](http://doinstall.bearbin.net/install?url=https://github.com/mc-server/MCServer)
|
||||
|
||||
* [Windows and Linux](http://builds.mc-server.org)
|
||||
* [Raspberry Pi](http://ci.bearbin.net)
|
||||
For Linux there is an easy installation method, just run this in your terminal:
|
||||
|
||||
You simply need to download and extract these files before you can use the server.
|
||||
curl -s https://raw.githubusercontent.com/mc-server/MCServer/master/easyinstall.sh | sh
|
||||
|
||||
If you're a more advanced user, you may want to compile the server yourself for more performance. See the [COMPILING.md](https://github.com/mc-server/MCServer/blob/master/COMPILING.md) file for more details.
|
||||
For Windows, you just need to download a file and extract it:
|
||||
|
||||
- [Windows 32 bit](http://builds.cuberite.org/job/MCServer%20Windows%20x86/lastSuccessfulBuild/artifact/Install/MCServer.zip)
|
||||
- [Windows 64 bit](http://builds.cuberite.org/job/MCServer%20Windows%20x64/lastSuccessfulBuild/artifact/Install/MCServer.zip)
|
||||
|
||||
For other operating systems you need to download and compile yourself. There is also an archive of binary builds on the buildserver: http://builds.cuberite.org
|
||||
|
||||
Compiling the server yourself has other benefits: you may get better performance performance (1.5-3x as fast) and it supports more operating systems. See the [COMPILING.md](https://github.com/mc-server/MCServer/blob/master/COMPILING.md) file for more details.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
MCServer is licensed under the Apache license V2, and we welcome anybody to fork and submit a Pull Request back with their changes, and if you want to join as a permanent member we can add you to the team.
|
||||
MCServer is licensed under the Apache License V2, and we welcome anybody to fork and submit a Pull Request back with their changes, and if you want to join as a permanent member we can add you to the team.
|
||||
|
||||
Check out the [CONTRIBUTING.md](https://github.com/mc-server/MCServer/blob/master/CONTRIBUTING.md) file for more details.
|
||||
|
||||
@@ -33,7 +39,7 @@ For other stuff, including plugins and discussion, check the [forums](http://for
|
||||
|
||||
Earn bitcoins for commits or donate to reward the MCServer developers: [](http://tip4commit.com/projects/74)
|
||||
|
||||
Support Us on Gratipay: [](https://www.gittip.com/mcs_team)
|
||||
Support Us on Gratipay: [](https://www.gratipay.com/cuberite_team)
|
||||
|
||||
Travis CI: [](https://travis-ci.org/mc-server/MCServer)
|
||||
|
||||
|
||||
@@ -59,12 +59,25 @@ macro(set_flags)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG")
|
||||
elseif(APPLE)
|
||||
#on os x clang adds pthread for us but we need to add it for gcc
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GCC_VERSION)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND (NOT GCC_VERSION VERSION_GREATER 4.6))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++0x")
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++0x")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++0x")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
|
||||
endif()
|
||||
#on os x clang adds pthread for us but we need to add it for gcc
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_flags_cxx("-stdlib=libc++")
|
||||
add_flags_lnk("-stdlib=libc++")
|
||||
else()
|
||||
@@ -77,8 +90,17 @@ macro(set_flags)
|
||||
add_flags_cxx("-pthread")
|
||||
endif()
|
||||
|
||||
# Make CLang use C++11, otherwise MSVC2008-supported extensions don't work ("override" keyword etc.):
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GCC_VERSION)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND (NOT GCC_VERSION VERSION_GREATER 4.6))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++0x")
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++0x")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++0x")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++11")
|
||||
|
||||
@@ -1819,8 +1819,7 @@ bool cConnection::HandleServerKick(void)
|
||||
Reason.append(Split[4]);
|
||||
Reason.push_back(0);
|
||||
Reason.append(Split[5]);
|
||||
AString ReasonBE16;
|
||||
UTF8ToRawBEUTF16(Reason.data(), Reason.size(), ReasonBE16);
|
||||
AString ReasonBE16 = UTF8ToRawBEUTF16(Reason.data(), Reason.size());
|
||||
AString PacketStart("\xff");
|
||||
PacketStart.push_back((ReasonBE16.size() / 2) / 256);
|
||||
PacketStart.push_back((ReasonBE16.size() / 2) % 256);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "Globals.h"
|
||||
#include "BiomeView.h"
|
||||
#include "QtChunk.h"
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
#include "Region.h"
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,116 @@ static const int DELTA_STEP = 120; // The normal per-notch wheel delta
|
||||
|
||||
|
||||
|
||||
/** Map for converting biome values to colors. Initialized from biomeColors[]. */
|
||||
static uchar biomeToColor[256 * 4];
|
||||
|
||||
/** Map for converting biome values to colors. Used to initialize biomeToColor[].*/
|
||||
static struct
|
||||
{
|
||||
EMCSBiome m_Biome;
|
||||
uchar m_Color[3];
|
||||
} biomeColors[] =
|
||||
{
|
||||
{ biOcean, { 0x00, 0x00, 0x70 }, },
|
||||
{ biPlains, { 0x8d, 0xb3, 0x60 }, },
|
||||
{ biDesert, { 0xfa, 0x94, 0x18 }, },
|
||||
{ biExtremeHills, { 0x60, 0x60, 0x60 }, },
|
||||
{ biForest, { 0x05, 0x66, 0x21 }, },
|
||||
{ biTaiga, { 0x0b, 0x66, 0x59 }, },
|
||||
{ biSwampland, { 0x2f, 0xff, 0xda }, },
|
||||
{ biRiver, { 0x30, 0x30, 0xaf }, },
|
||||
{ biHell, { 0x7f, 0x00, 0x00 }, },
|
||||
{ biSky, { 0x00, 0x7f, 0xff }, },
|
||||
{ biFrozenOcean, { 0xa0, 0xa0, 0xdf }, },
|
||||
{ biFrozenRiver, { 0xa0, 0xa0, 0xff }, },
|
||||
{ biIcePlains, { 0xff, 0xff, 0xff }, },
|
||||
{ biIceMountains, { 0xa0, 0xa0, 0xa0 }, },
|
||||
{ biMushroomIsland, { 0xff, 0x00, 0xff }, },
|
||||
{ biMushroomShore, { 0xa0, 0x00, 0xff }, },
|
||||
{ biBeach, { 0xfa, 0xde, 0x55 }, },
|
||||
{ biDesertHills, { 0xd2, 0x5f, 0x12 }, },
|
||||
{ biForestHills, { 0x22, 0x55, 0x1c }, },
|
||||
{ biTaigaHills, { 0x16, 0x39, 0x33 }, },
|
||||
{ biExtremeHillsEdge, { 0x7f, 0x8f, 0x7f }, },
|
||||
{ biJungle, { 0x53, 0x7b, 0x09 }, },
|
||||
{ biJungleHills, { 0x2c, 0x42, 0x05 }, },
|
||||
|
||||
{ biJungleEdge, { 0x62, 0x8b, 0x17 }, },
|
||||
{ biDeepOcean, { 0x00, 0x00, 0x30 }, },
|
||||
{ biStoneBeach, { 0xa2, 0xa2, 0x84 }, },
|
||||
{ biColdBeach, { 0xfa, 0xf0, 0xc0 }, },
|
||||
{ biBirchForest, { 0x30, 0x74, 0x44 }, },
|
||||
{ biBirchForestHills, { 0x1f, 0x5f, 0x32 }, },
|
||||
{ biRoofedForest, { 0x40, 0x51, 0x1a }, },
|
||||
{ biColdTaiga, { 0x31, 0x55, 0x4a }, },
|
||||
{ biColdTaigaHills, { 0x59, 0x7d, 0x72 }, },
|
||||
{ biMegaTaiga, { 0x59, 0x66, 0x51 }, },
|
||||
{ biMegaTaigaHills, { 0x59, 0x66, 0x59 }, },
|
||||
{ biExtremeHillsPlus, { 0x50, 0x70, 0x50 }, },
|
||||
{ biSavanna, { 0xbd, 0xb2, 0x5f }, },
|
||||
{ biSavannaPlateau, { 0xa7, 0x9d, 0x64 }, },
|
||||
{ biMesa, { 0xd9, 0x45, 0x15 }, },
|
||||
{ biMesaPlateauF, { 0xb0, 0x97, 0x65 }, },
|
||||
{ biMesaPlateau, { 0xca, 0x8c, 0x65 }, },
|
||||
|
||||
// M variants:
|
||||
{ biSunflowerPlains, { 0xb5, 0xdb, 0x88 }, },
|
||||
{ biDesertM, { 0xff, 0xbc, 0x40 }, },
|
||||
{ biExtremeHillsM, { 0x88, 0x88, 0x88 }, },
|
||||
{ biFlowerForest, { 0x2d, 0x8e, 0x49 }, },
|
||||
{ biTaigaM, { 0x33, 0x8e, 0x81 }, },
|
||||
{ biSwamplandM, { 0x07, 0xf9, 0xb2 }, },
|
||||
{ biIcePlainsSpikes, { 0xb4, 0xdc, 0xdc }, },
|
||||
{ biJungleM, { 0x7b, 0xa3, 0x31 }, },
|
||||
{ biJungleEdgeM, { 0x62, 0x8b, 0x17 }, },
|
||||
{ biBirchForestM, { 0x58, 0x9c, 0x6c }, },
|
||||
{ biBirchForestHillsM, { 0x47, 0x87, 0x5a }, },
|
||||
{ biRoofedForestM, { 0x68, 0x79, 0x42 }, },
|
||||
{ biColdTaigaM, { 0x24, 0x3f, 0x36 }, },
|
||||
{ biMegaSpruceTaiga, { 0x45, 0x4f, 0x3e }, },
|
||||
{ biMegaSpruceTaigaHills, { 0x45, 0x4f, 0x4e }, },
|
||||
{ biExtremeHillsPlusM, { 0x78, 0x98, 0x78 }, },
|
||||
{ biSavannaM, { 0xe5, 0xda, 0x87 }, },
|
||||
{ biSavannaPlateauM, { 0xa7, 0x9d, 0x74 }, },
|
||||
{ biMesaBryce, { 0xff, 0x6d, 0x3d }, },
|
||||
{ biMesaPlateauFM, { 0xd8, 0xbf, 0x8d }, },
|
||||
{ biMesaPlateauM, { 0xf2, 0xb4, 0x8d }, },
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static class BiomeColorsInitializer
|
||||
{
|
||||
public:
|
||||
BiomeColorsInitializer(void)
|
||||
{
|
||||
// Reset all colors to gray:
|
||||
for (size_t i = 0; i < ARRAYCOUNT(biomeToColor); i++)
|
||||
{
|
||||
biomeToColor[i] = 0x7f;
|
||||
}
|
||||
|
||||
// Set known biomes to their colors:
|
||||
for (size_t i = 0; i < ARRAYCOUNT(biomeColors); i++)
|
||||
{
|
||||
uchar * color = &biomeToColor[4 * biomeColors[i].m_Biome];
|
||||
color[0] = biomeColors[i].m_Color[2];
|
||||
color[1] = biomeColors[i].m_Color[1];
|
||||
color[2] = biomeColors[i].m_Color[0];
|
||||
color[3] = 0xff;
|
||||
}
|
||||
}
|
||||
} biomeColorInitializer;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// BiomeView:
|
||||
|
||||
BiomeView::BiomeView(QWidget * parent) :
|
||||
super(parent),
|
||||
m_X(0),
|
||||
@@ -40,10 +150,11 @@ BiomeView::BiomeView(QWidget * parent) :
|
||||
redraw();
|
||||
|
||||
// Add a chunk-update callback mechanism:
|
||||
connect(&m_Cache, SIGNAL(chunkAvailable(int, int)), this, SLOT(chunkAvailable(int, int)));
|
||||
connect(&m_Cache, SIGNAL(regionAvailable(int, int)), this, SLOT(regionAvailable(int, int)));
|
||||
|
||||
// Allow keyboard interaction:
|
||||
// Allow mouse and keyboard interaction:
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +191,27 @@ void BiomeView::setChunkSource(std::shared_ptr<ChunkSource> a_ChunkSource)
|
||||
|
||||
|
||||
|
||||
void BiomeView::setPosition(int a_BlockX, int a_BlockZ)
|
||||
{
|
||||
m_X = a_BlockX;
|
||||
m_Z = a_BlockZ;
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BiomeView::setZoomLevel(double a_ZoomLevel)
|
||||
{
|
||||
m_Zoom = a_ZoomLevel;
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BiomeView::redraw()
|
||||
{
|
||||
if (!hasData())
|
||||
@@ -121,9 +253,15 @@ void BiomeView::redraw()
|
||||
|
||||
|
||||
|
||||
void BiomeView::chunkAvailable(int a_ChunkX, int a_ChunkZ)
|
||||
void BiomeView::regionAvailable(int a_RegionX, int a_RegionZ)
|
||||
{
|
||||
drawChunk(a_ChunkX, a_ChunkZ);
|
||||
for (int z = 0; z < 32; z++)
|
||||
{
|
||||
for (int x = 0; x < 32; x++)
|
||||
{
|
||||
drawChunk(a_RegionX * 32 + x, a_RegionZ * 32 + z);
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -153,8 +291,11 @@ void BiomeView::drawChunk(int a_ChunkX, int a_ChunkZ)
|
||||
return;
|
||||
}
|
||||
|
||||
//fetch the chunk:
|
||||
ChunkPtr chunk = m_Cache.fetch(a_ChunkX, a_ChunkZ);
|
||||
// Fetch the region:
|
||||
int regionX;
|
||||
int regionZ;
|
||||
Region::chunkToRegion(a_ChunkX, a_ChunkZ, regionX, regionZ);
|
||||
RegionPtr region = m_Cache.fetch(regionX, regionZ);
|
||||
|
||||
// Figure out where on the screen this chunk should be drawn:
|
||||
// first find the center chunk
|
||||
@@ -172,11 +313,10 @@ void BiomeView::drawChunk(int a_ChunkX, int a_ChunkZ)
|
||||
centerx += (a_ChunkX - centerchunkx) * chunksize;
|
||||
centery += (a_ChunkZ - centerchunkz) * chunksize;
|
||||
|
||||
int srcoffset = 0;
|
||||
uchar * bits = m_Image.bits();
|
||||
int imgstride = m_Image.bytesPerLine();
|
||||
|
||||
int skipx = 0,skipy = 0;
|
||||
int skipx = 0, skipy = 0;
|
||||
int blockwidth = chunksize, blockheight = chunksize;
|
||||
// now if we're off the screen we need to crop
|
||||
if (centerx < 0)
|
||||
@@ -205,29 +345,52 @@ void BiomeView::drawChunk(int a_ChunkX, int a_ChunkZ)
|
||||
int imgoffset = centerx * 4 + centery * imgstride;
|
||||
|
||||
// If the chunk is valid, use its data; otherwise use the empty placeholder:
|
||||
const uchar * src = m_EmptyChunkImage;
|
||||
if (chunk.get() != nullptr)
|
||||
const short * src = m_EmptyChunkBiomes;
|
||||
if (region.get() != nullptr)
|
||||
{
|
||||
src = chunk->getImage();
|
||||
int relChunkX = a_ChunkX - regionX * 32;
|
||||
int relChunkZ = a_ChunkZ - regionZ * 32;
|
||||
Chunk & chunk = region->getRelChunk(relChunkX, relChunkZ);
|
||||
if (chunk.isValid())
|
||||
{
|
||||
src = chunk.getBiomes();
|
||||
}
|
||||
}
|
||||
|
||||
// Blit or scale-blit the image:
|
||||
// Scale-blit the image:
|
||||
for (int z = skipy; z < blockheight; z++, imgoffset += imgstride)
|
||||
{
|
||||
srcoffset = floor((double)z / m_Zoom) * 16 * 4;
|
||||
if (m_Zoom == 1.0)
|
||||
size_t srcoffset = static_cast<size_t>(std::floor((double)z / m_Zoom)) * 16;
|
||||
int imgxoffset = imgoffset;
|
||||
for (int x = skipx; x < blockwidth; x++)
|
||||
{
|
||||
memcpy(bits + imgoffset, src + srcoffset + skipx * 4, (blockwidth - skipx) * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
int xofs = 0;
|
||||
for (int x = skipx; x < blockwidth; x++, xofs +=4)
|
||||
short biome = src[srcoffset + static_cast<size_t>(std::floor((double)x / m_Zoom))];
|
||||
const uchar * color;
|
||||
if (biome < 0)
|
||||
{
|
||||
memcpy(bits + imgoffset + xofs, src + srcoffset + (int)floor((double)x / m_Zoom) * 4, 4);
|
||||
static const uchar emptyBiome1[] = { 0x44, 0x44, 0x44, 0xff };
|
||||
static const uchar emptyBiome2[] = { 0x88, 0x88, 0x88, 0xff };
|
||||
color = ((x & 8) ^ (z & 8)) ? emptyBiome1 : emptyBiome2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (biome * 4 >= ARRAYCOUNT(biomeToColor))
|
||||
{
|
||||
static const uchar errorImage[] = { 0xff, 0x00, 0x00, 0xff };
|
||||
color = errorImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = biomeToColor + biome * 4;
|
||||
}
|
||||
}
|
||||
bits[imgxoffset] = color[0];
|
||||
bits[imgxoffset + 1] = color[1];
|
||||
bits[imgxoffset + 2] = color[2];
|
||||
bits[imgxoffset + 3] = color[3];
|
||||
imgxoffset += 4;
|
||||
} // for x
|
||||
} // for z
|
||||
}
|
||||
|
||||
|
||||
@@ -275,6 +438,12 @@ void BiomeView::mousePressEvent(QMouseEvent * a_Event)
|
||||
|
||||
void BiomeView::mouseMoveEvent(QMouseEvent * a_Event)
|
||||
{
|
||||
// If there's no data displayed, bail out:
|
||||
if (!hasData())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_IsMouseDragging)
|
||||
{
|
||||
// The user is dragging the mouse, move the view around:
|
||||
@@ -286,7 +455,16 @@ void BiomeView::mouseMoveEvent(QMouseEvent * a_Event)
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Update the status bar info for the biome currently pointed at
|
||||
// Update the status bar info text:
|
||||
int blockX = floor((a_Event->x() - width() / 2) / m_Zoom + m_X);
|
||||
int blockZ = floor((a_Event->y() - height() / 2) / m_Zoom + m_Z);
|
||||
int regionX, regionZ;
|
||||
Region::blockToRegion(blockX, blockZ, regionX, regionZ);
|
||||
int relX = blockX - regionX * 512;
|
||||
int relZ = blockZ - regionZ * 512;
|
||||
auto region = m_Cache.fetch(regionX, regionZ);
|
||||
int biome = (region.get() != nullptr) ? region->getRelBiome(relX, relZ) : biInvalidBiome;
|
||||
emit hoverChanged(blockX, blockZ, biome);
|
||||
}
|
||||
|
||||
|
||||
@@ -307,12 +485,12 @@ void BiomeView::wheelEvent(QWheelEvent * a_Event)
|
||||
m_MouseWheelDelta += a_Event->delta();
|
||||
while (m_MouseWheelDelta >= DELTA_STEP)
|
||||
{
|
||||
increaseZoom();
|
||||
emit wheelUp();
|
||||
m_MouseWheelDelta -= DELTA_STEP;
|
||||
}
|
||||
while (m_MouseWheelDelta <= -DELTA_STEP)
|
||||
{
|
||||
decreaseZoom();
|
||||
emit wheelDown();
|
||||
m_MouseWheelDelta += DELTA_STEP;
|
||||
}
|
||||
}
|
||||
@@ -360,14 +538,14 @@ void BiomeView::keyPressEvent(QKeyEvent * a_Event)
|
||||
case Qt::Key_PageUp:
|
||||
case Qt::Key_Q:
|
||||
{
|
||||
increaseZoom();
|
||||
emit increaseZoom();
|
||||
break;
|
||||
}
|
||||
|
||||
case Qt::Key_PageDown:
|
||||
case Qt::Key_E:
|
||||
{
|
||||
decreaseZoom();
|
||||
emit decreaseZoom();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -376,52 +554,3 @@ void BiomeView::keyPressEvent(QKeyEvent * a_Event)
|
||||
|
||||
|
||||
|
||||
|
||||
void BiomeView::decreaseZoom()
|
||||
{
|
||||
if (m_Zoom > 1.001)
|
||||
{
|
||||
m_Zoom--;
|
||||
if (m_Zoom < 1.0)
|
||||
{
|
||||
// Just crossed the 100%, fixate the 100% threshold:
|
||||
m_Zoom = 1.0;
|
||||
}
|
||||
}
|
||||
else if (m_Zoom > 0.01)
|
||||
{
|
||||
m_Zoom = m_Zoom / 2;
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BiomeView::increaseZoom()
|
||||
{
|
||||
if (m_Zoom > 0.99)
|
||||
{
|
||||
if (m_Zoom > 20.0)
|
||||
{
|
||||
// Zoom too large
|
||||
return;
|
||||
}
|
||||
m_Zoom++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Zoom = m_Zoom * 2;
|
||||
if (m_Zoom > 1.0)
|
||||
{
|
||||
// Just crossed the 100%, fixate the 100% threshold:
|
||||
m_Zoom = 1.0;
|
||||
}
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
#include "ChunkCache.h"
|
||||
#include "RegionCache.h"
|
||||
#include "ChunkSource.h"
|
||||
|
||||
|
||||
@@ -25,14 +25,34 @@ public:
|
||||
The entire view is then invalidated and regenerated. */
|
||||
void setChunkSource(std::shared_ptr<ChunkSource> a_ChunkSource);
|
||||
|
||||
/** Sets the position of the central pixel of the map to the specified point and redraws the view. */
|
||||
void setPosition(int a_BlockX, int a_BlockZ);
|
||||
|
||||
/** Sets the zoom level to the specified value and redraws the view. */
|
||||
void setZoomLevel(double a_ZoomLevel);
|
||||
|
||||
signals:
|
||||
/** Signalled when the user uses the wheel to scroll upwards. */
|
||||
void wheelUp();
|
||||
|
||||
/** Signalled when the user uses the wheel to scroll downwards. */
|
||||
void wheelDown();
|
||||
|
||||
/** Signalled when the user presses a key to increase zoom. */
|
||||
void increaseZoom();
|
||||
|
||||
/** Signalled when the user presses a key to decrease zoom. */
|
||||
void decreaseZoom();
|
||||
|
||||
/** Emitted when the user moves the mouse, to reflect the current block under the cursor. */
|
||||
void hoverChanged(int a_BlockX, int a_BlockZ, int a_Biome);
|
||||
|
||||
public slots:
|
||||
/** Redraw the entire widget area. */
|
||||
void redraw();
|
||||
|
||||
/** A specified chunk has become available, redraw it. */
|
||||
void chunkAvailable(int a_ChunkX, int a_ChunkZ);
|
||||
/** A specified region has become available, redraw it. */
|
||||
void regionAvailable(int a_RegionX, int a_RegionZ);
|
||||
|
||||
/** Reloads the current chunk source and redraws the entire workspace. */
|
||||
void reload();
|
||||
@@ -42,7 +62,7 @@ protected:
|
||||
double m_Zoom;
|
||||
|
||||
/** Cache for the loaded chunk data. */
|
||||
ChunkCache m_Cache;
|
||||
RegionCache m_Cache;
|
||||
|
||||
/** The entire view's contents in an offscreen image. */
|
||||
QImage m_Image;
|
||||
@@ -59,6 +79,9 @@ protected:
|
||||
/** Data used for rendering a chunk that hasn't been loaded yet */
|
||||
uchar m_EmptyChunkImage[16 * 16 * 4];
|
||||
|
||||
/** Data placeholder for chunks that aren't valid. */
|
||||
short m_EmptyChunkBiomes[16 * 16];
|
||||
|
||||
|
||||
/** Draws the specified chunk into m_Image */
|
||||
void drawChunk(int a_ChunkX, int a_ChunkZ);
|
||||
@@ -86,12 +109,6 @@ protected:
|
||||
|
||||
/** Called when the user presses a key. */
|
||||
virtual void keyPressEvent(QKeyEvent * a_Event) override;
|
||||
|
||||
/** Decreases the zoom level and queues a redraw. */
|
||||
void decreaseZoom();
|
||||
|
||||
/** Increases the zoom level and queues a redraw. */
|
||||
void increaseZoom();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
#include "Globals.h"
|
||||
#include "ChunkCache.h"
|
||||
#include <QMutexLocker>
|
||||
#include <QThreadPool>
|
||||
#include "ChunkSource.h"
|
||||
#include "ChunkLoader.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ChunkCache::ChunkCache(QObject * parent) :
|
||||
super(parent)
|
||||
{
|
||||
m_Cache.setMaxCost(1024 * 1024 * 1024); // 1 GiB of memory for the cache
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ChunkPtr ChunkCache::fetch(int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
// Retrieve from the cache:
|
||||
quint32 hash = getChunkHash(a_ChunkX, a_ChunkZ);
|
||||
ChunkPtr * res;
|
||||
{
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
res = m_Cache[hash];
|
||||
// If succesful and chunk loaded, return the retrieved value:
|
||||
if ((res != nullptr) && (*res)->isValid())
|
||||
{
|
||||
return *res;
|
||||
}
|
||||
}
|
||||
|
||||
// If the chunk is in cache but not valid, it means it has been already queued for rendering, do nothing now:
|
||||
if (res != nullptr)
|
||||
{
|
||||
return ChunkPtr(nullptr);
|
||||
}
|
||||
|
||||
// There's no such item in the cache, create it now:
|
||||
res = new ChunkPtr(new Chunk);
|
||||
if (res == nullptr)
|
||||
{
|
||||
return ChunkPtr(nullptr);
|
||||
}
|
||||
{
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
m_Cache.insert(hash, res, sizeof(Chunk));
|
||||
}
|
||||
|
||||
// Queue the chunk for rendering:
|
||||
queueChunkRender(a_ChunkX, a_ChunkZ, *res);
|
||||
|
||||
// Return failure, the chunk is not yet rendered:
|
||||
return ChunkPtr(nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ChunkCache::setChunkSource(std::shared_ptr<ChunkSource> a_ChunkSource)
|
||||
{
|
||||
// Replace the chunk source:
|
||||
m_ChunkSource = a_ChunkSource;
|
||||
|
||||
// Clear the cache:
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
m_Cache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ChunkCache::reload()
|
||||
{
|
||||
assert(m_ChunkSource.get() != nullptr);
|
||||
|
||||
// Reload the chunk source:
|
||||
m_ChunkSource->reload();
|
||||
|
||||
// Clear the cache:
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
m_Cache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ChunkCache::gotChunk(int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
emit chunkAvailable(a_ChunkX, a_ChunkZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
quint32 ChunkCache::getChunkHash(int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
// Simply join the two coords into a single int
|
||||
// The coords will never be larger than 16-bits, so we can do this safely
|
||||
return (((static_cast<quint32>(a_ChunkX) & 0xffff) << 16) | (static_cast<quint32>(a_ChunkZ) & 0xffff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ChunkCache::queueChunkRender(int a_ChunkX, int a_ChunkZ, ChunkPtr & a_Chunk)
|
||||
{
|
||||
// Create a new loader task:
|
||||
ChunkLoader * loader = new ChunkLoader(a_ChunkX, a_ChunkZ, a_Chunk, m_ChunkSource);
|
||||
connect(loader, SIGNAL(loaded(int, int)), this, SLOT(gotChunk(int, int)));
|
||||
|
||||
QThreadPool::globalInstance()->start(loader);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#include "Globals.h"
|
||||
#include "ChunkLoader.h"
|
||||
#include "ChunkSource.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ChunkLoader::ChunkLoader(int a_ChunkX, int a_ChunkZ, ChunkPtr a_Chunk, ChunkSourcePtr a_ChunkSource) :
|
||||
m_ChunkX(a_ChunkX),
|
||||
m_ChunkZ(a_ChunkZ),
|
||||
m_Chunk(a_Chunk),
|
||||
m_ChunkSource(a_ChunkSource)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ChunkLoader::run()
|
||||
{
|
||||
m_ChunkSource->getChunkBiomes(m_ChunkX, m_ChunkZ, m_Chunk);
|
||||
emit loaded(m_ChunkX, m_ChunkZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QRunnable>
|
||||
#include <memory>
|
||||
|
||||
|
||||
|
||||
|
||||
// fwd:
|
||||
class Chunk;
|
||||
typedef std::shared_ptr<Chunk> ChunkPtr;
|
||||
|
||||
class ChunkSource;
|
||||
typedef std::shared_ptr<ChunkSource> ChunkSourcePtr;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ChunkLoader :
|
||||
public QObject,
|
||||
public QRunnable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChunkLoader(int a_ChunkX, int a_ChunkZ, ChunkPtr a_Chunk, ChunkSourcePtr a_ChunkSource);
|
||||
virtual ~ChunkLoader() {}
|
||||
|
||||
signals:
|
||||
void loaded(int a_ChunkX, int a_ChunkZ);
|
||||
|
||||
protected:
|
||||
virtual void run() override;
|
||||
|
||||
private:
|
||||
int m_ChunkX, m_ChunkZ;
|
||||
ChunkPtr m_Chunk;
|
||||
ChunkSourcePtr m_ChunkSource;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,136 +4,7 @@
|
||||
#include "src/Generating/BioGen.h"
|
||||
#include "src/StringCompression.h"
|
||||
#include "src/WorldStorage/FastNBT.h"
|
||||
#include "inifile/iniFile.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Map for converting biome values to colors. Initialized from biomeColors[]. */
|
||||
static uchar biomeToColor[256 * 4];
|
||||
|
||||
/** Map for converting biome values to colors. Used to initialize biomeToColor[].*/
|
||||
static struct
|
||||
{
|
||||
EMCSBiome m_Biome;
|
||||
uchar m_Color[3];
|
||||
} biomeColors[] =
|
||||
{
|
||||
{ biOcean, { 0x00, 0x00, 0x70 }, },
|
||||
{ biPlains, { 0x8d, 0xb3, 0x60 }, },
|
||||
{ biDesert, { 0xfa, 0x94, 0x18 }, },
|
||||
{ biExtremeHills, { 0x60, 0x60, 0x60 }, },
|
||||
{ biForest, { 0x05, 0x66, 0x21 }, },
|
||||
{ biTaiga, { 0x0b, 0x66, 0x59 }, },
|
||||
{ biSwampland, { 0x2f, 0xff, 0xda }, },
|
||||
{ biRiver, { 0x30, 0x30, 0xaf }, },
|
||||
{ biHell, { 0x7f, 0x00, 0x00 }, },
|
||||
{ biSky, { 0x00, 0x7f, 0xff }, },
|
||||
{ biFrozenOcean, { 0xa0, 0xa0, 0xdf }, },
|
||||
{ biFrozenRiver, { 0xa0, 0xa0, 0xff }, },
|
||||
{ biIcePlains, { 0xff, 0xff, 0xff }, },
|
||||
{ biIceMountains, { 0xa0, 0xa0, 0xa0 }, },
|
||||
{ biMushroomIsland, { 0xff, 0x00, 0xff }, },
|
||||
{ biMushroomShore, { 0xa0, 0x00, 0xff }, },
|
||||
{ biBeach, { 0xfa, 0xde, 0x55 }, },
|
||||
{ biDesertHills, { 0xd2, 0x5f, 0x12 }, },
|
||||
{ biForestHills, { 0x22, 0x55, 0x1c }, },
|
||||
{ biTaigaHills, { 0x16, 0x39, 0x33 }, },
|
||||
{ biExtremeHillsEdge, { 0x7f, 0x8f, 0x7f }, },
|
||||
{ biJungle, { 0x53, 0x7b, 0x09 }, },
|
||||
{ biJungleHills, { 0x2c, 0x42, 0x05 }, },
|
||||
|
||||
{ biJungleEdge, { 0x62, 0x8b, 0x17 }, },
|
||||
{ biDeepOcean, { 0x00, 0x00, 0x30 }, },
|
||||
{ biStoneBeach, { 0xa2, 0xa2, 0x84 }, },
|
||||
{ biColdBeach, { 0xfa, 0xf0, 0xc0 }, },
|
||||
{ biBirchForest, { 0x30, 0x74, 0x44 }, },
|
||||
{ biBirchForestHills, { 0x1f, 0x5f, 0x32 }, },
|
||||
{ biRoofedForest, { 0x40, 0x51, 0x1a }, },
|
||||
{ biColdTaiga, { 0x31, 0x55, 0x4a }, },
|
||||
{ biColdTaigaHills, { 0x59, 0x7d, 0x72 }, },
|
||||
{ biMegaTaiga, { 0x59, 0x66, 0x51 }, },
|
||||
{ biMegaTaigaHills, { 0x59, 0x66, 0x59 }, },
|
||||
{ biExtremeHillsPlus, { 0x50, 0x70, 0x50 }, },
|
||||
{ biSavanna, { 0xbd, 0xb2, 0x5f }, },
|
||||
{ biSavannaPlateau, { 0xa7, 0x9d, 0x64 }, },
|
||||
{ biMesa, { 0xd9, 0x45, 0x15 }, },
|
||||
{ biMesaPlateauF, { 0xb0, 0x97, 0x65 }, },
|
||||
{ biMesaPlateau, { 0xca, 0x8c, 0x65 }, },
|
||||
|
||||
// M variants:
|
||||
{ biSunflowerPlains, { 0xb5, 0xdb, 0x88 }, },
|
||||
{ biDesertM, { 0xff, 0xbc, 0x40 }, },
|
||||
{ biExtremeHillsM, { 0x88, 0x88, 0x88 }, },
|
||||
{ biFlowerForest, { 0x2d, 0x8e, 0x49 }, },
|
||||
{ biTaigaM, { 0x33, 0x8e, 0x81 }, },
|
||||
{ biSwamplandM, { 0x07, 0xf9, 0xb2 }, },
|
||||
{ biIcePlainsSpikes, { 0xb4, 0xdc, 0xdc }, },
|
||||
{ biJungleM, { 0x7b, 0xa3, 0x31 }, },
|
||||
{ biJungleEdgeM, { 0x62, 0x8b, 0x17 }, },
|
||||
{ biBirchForestM, { 0x58, 0x9c, 0x6c }, },
|
||||
{ biBirchForestHillsM, { 0x47, 0x87, 0x5a }, },
|
||||
{ biRoofedForestM, { 0x68, 0x79, 0x42 }, },
|
||||
{ biColdTaigaM, { 0x24, 0x3f, 0x36 }, },
|
||||
{ biMegaSpruceTaiga, { 0x45, 0x4f, 0x3e }, },
|
||||
{ biMegaSpruceTaigaHills, { 0x45, 0x4f, 0x4e }, },
|
||||
{ biExtremeHillsPlusM, { 0x78, 0x98, 0x78 }, },
|
||||
{ biSavannaM, { 0xe5, 0xda, 0x87 }, },
|
||||
{ biSavannaPlateauM, { 0xa7, 0x9d, 0x74 }, },
|
||||
{ biMesaBryce, { 0xff, 0x6d, 0x3d }, },
|
||||
{ biMesaPlateauFM, { 0xd8, 0xbf, 0x8d }, },
|
||||
{ biMesaPlateauM, { 0xf2, 0xb4, 0x8d }, },
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static class BiomeColorsInitializer
|
||||
{
|
||||
public:
|
||||
BiomeColorsInitializer(void)
|
||||
{
|
||||
// Reset all colors to gray:
|
||||
for (size_t i = 0; i < ARRAYCOUNT(biomeToColor); i++)
|
||||
{
|
||||
biomeToColor[i] = 0x7f;
|
||||
}
|
||||
|
||||
// Set known biomes to their colors:
|
||||
for (size_t i = 0; i < ARRAYCOUNT(biomeColors); i++)
|
||||
{
|
||||
uchar * color = &biomeToColor[4 * biomeColors[i].m_Biome];
|
||||
color[0] = biomeColors[i].m_Color[2];
|
||||
color[1] = biomeColors[i].m_Color[1];
|
||||
color[2] = biomeColors[i].m_Color[0];
|
||||
color[3] = 0xff;
|
||||
}
|
||||
}
|
||||
} biomeColorInitializer;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Converts biomes in an array into the chunk image data. */
|
||||
static void biomesToImage(cChunkDef::BiomeMap & a_Biomes, Chunk::Image & a_Image)
|
||||
{
|
||||
// Make sure the two arrays are of the same size, compile-time.
|
||||
// Note that a_Image is actually 4 items per pixel, so the array is 4 times bigger:
|
||||
static const char Check1[4 * ARRAYCOUNT(a_Biomes) - ARRAYCOUNT(a_Image) + 1] = {};
|
||||
static const char Check2[ARRAYCOUNT(a_Image) - 4 * ARRAYCOUNT(a_Biomes) + 1] = {};
|
||||
|
||||
// Convert the biomes into color:
|
||||
for (size_t i = 0; i < ARRAYCOUNT(a_Biomes); i++)
|
||||
{
|
||||
a_Image[4 * i + 0] = biomeToColor[4 * a_Biomes[i] + 0];
|
||||
a_Image[4 * i + 1] = biomeToColor[4 * a_Biomes[i] + 1];
|
||||
a_Image[4 * i + 2] = biomeToColor[4 * a_Biomes[i] + 2];
|
||||
a_Image[4 * i + 3] = biomeToColor[4 * a_Biomes[i] + 3];
|
||||
}
|
||||
}
|
||||
#include "src/IniFile.h"
|
||||
|
||||
|
||||
|
||||
@@ -153,16 +24,14 @@ BioGenSource::BioGenSource(cIniFilePtr a_IniFile) :
|
||||
|
||||
|
||||
|
||||
void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk)
|
||||
void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk)
|
||||
{
|
||||
cChunkDef::BiomeMap biomes;
|
||||
{
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, biomes);
|
||||
}
|
||||
Chunk::Image img;
|
||||
biomesToImage(biomes, img);
|
||||
a_DestChunk->setImage(img);
|
||||
int tag;
|
||||
cBiomeGenPtr biomeGen = getBiomeGen(tag);
|
||||
biomeGen->GenBiomes(a_ChunkX, a_ChunkZ, biomes);
|
||||
releaseBiomeGen(std::move(biomeGen), tag);
|
||||
a_DestChunk.setBiomes(biomes);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,10 +40,53 @@ void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChu
|
||||
|
||||
void BioGenSource::reload()
|
||||
{
|
||||
int seed = m_IniFile->GetValueSetI("Generator", "Seed", 0);
|
||||
bool unused = false;
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
m_BiomeGen.reset(cBiomeGen::CreateBiomeGen(*m_IniFile, seed, unused));
|
||||
m_CurrentTag += 1;
|
||||
m_BiomeGens.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cBiomeGenPtr BioGenSource::getBiomeGen(int & a_Tag)
|
||||
{
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
a_Tag = m_CurrentTag;
|
||||
if (m_BiomeGens.empty())
|
||||
{
|
||||
// Create a new biogen:
|
||||
lock.unlock();
|
||||
int seed = m_IniFile->GetValueSetI("Seed", "Seed", 0);
|
||||
bool unused;
|
||||
cBiomeGenPtr res = cBiomeGen::CreateBiomeGen(*m_IniFile, seed, unused);
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return an existing biogen:
|
||||
cBiomeGenPtr res = m_BiomeGens.back();
|
||||
m_BiomeGens.pop_back();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BioGenSource::releaseBiomeGen(cBiomeGenPtr && a_BiomeGen, int a_Tag)
|
||||
{
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
|
||||
// If the tag differs, the source has been reloaded and this biogen is old, dispose:
|
||||
if (a_Tag != m_CurrentTag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// The tag is the same, put the biogen back to list:
|
||||
m_BiomeGens.push_back(std::move(a_BiomeGen));
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +203,7 @@ AnvilSource::AnvilSource(QString a_WorldRegionFolder) :
|
||||
|
||||
|
||||
|
||||
void AnvilSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk)
|
||||
void AnvilSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk)
|
||||
{
|
||||
// Load the compressed data:
|
||||
AString compressedChunkData = getCompressedChunkData(a_ChunkX, a_ChunkZ);
|
||||
@@ -331,10 +243,7 @@ void AnvilSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChun
|
||||
{
|
||||
biomeMap[i] = (EMCSBiome)GetBEInt(beBiomes + 4 * i);
|
||||
}
|
||||
// Render the biomes:
|
||||
Chunk::Image img;
|
||||
biomesToImage(biomeMap, img);
|
||||
a_DestChunk->setImage(img);
|
||||
a_DestChunk.setBiomes(biomeMap);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -350,10 +259,7 @@ void AnvilSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChun
|
||||
{
|
||||
biomeMap[i] = EMCSBiome(vanillaBiomes[i]);
|
||||
}
|
||||
// Render the biomes:
|
||||
Chunk::Image img;
|
||||
biomesToImage(biomeMap, img);
|
||||
a_DestChunk->setImage(img);
|
||||
a_DestChunk.setBiomes(biomeMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -397,7 +303,7 @@ AnvilSource::AnvilFilePtr AnvilSource::getAnvilFile(int a_ChunkX, int a_ChunkZ)
|
||||
|
||||
// Search the cache for the file:
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
for (auto itr = m_Files.cbegin(), end = m_Files.cend(); itr != end; ++itr)
|
||||
for (auto itr = m_Files.begin(), end = m_Files.end(); itr != end; ++itr)
|
||||
{
|
||||
if (((*itr)->m_RegionX == RegionX) && ((*itr)->m_RegionZ == RegionZ))
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// fwd:
|
||||
class cBiomeGen;
|
||||
typedef std::shared_ptr<cBiomeGen> cBiomeGenPtr;
|
||||
typedef SharedPtr<cBiomeGen> cBiomeGenPtr;
|
||||
class cIniFile;
|
||||
typedef std::shared_ptr<cIniFile> cIniFilePtr;
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
|
||||
/** Fills the a_DestChunk with the biomes for the specified coords.
|
||||
It is expected to be thread-safe and re-entrant. Usually QThread::idealThreadCount() threads are used. */
|
||||
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) = 0;
|
||||
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) = 0;
|
||||
|
||||
/** Forces a fresh reload of the source. Useful mainly for the generator, whose underlying definition file may have been changed. */
|
||||
virtual void reload() = 0;
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
BioGenSource(cIniFilePtr a_IniFile);
|
||||
|
||||
// ChunkSource overrides:
|
||||
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
|
||||
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) override;
|
||||
virtual void reload(void) override;
|
||||
|
||||
protected:
|
||||
@@ -53,10 +53,30 @@ protected:
|
||||
cIniFilePtr m_IniFile;
|
||||
|
||||
/** The generator used for generating biomes. */
|
||||
std::unique_ptr<cBiomeGen> m_BiomeGen;
|
||||
std::vector<cBiomeGenPtr> m_BiomeGens;
|
||||
|
||||
/** Guards m_BiomeGen against multithreaded access. */
|
||||
/** Guards m_BiomeGens against multithreaded access. */
|
||||
QMutex m_Mtx;
|
||||
|
||||
/** Keeps track of the current settings of the biomegens.
|
||||
Incremented by one each time reload() is called. Provides the means of releasing old biomegens that were
|
||||
in use while reload() was being processed and thus couldn't be changed back then. releaseBiomeGen() does
|
||||
the job of filtering the biogens before reusing them. */
|
||||
int m_CurrentTag;
|
||||
|
||||
|
||||
/** Retrieves one cBiomeGenPtr from m_BiomeGens.
|
||||
If there's no biogen available there, creates a new one based on the ini file.
|
||||
When done with it, the caller should call releaseBiomeGen() to put the biogen back to m_BiomeGens.
|
||||
a_Tag receives the value of m_CurrentTag from when the lock was held; it should be passed to
|
||||
releaseBiomeGen() together with the biogen. */
|
||||
cBiomeGenPtr getBiomeGen(int & a_Tag);
|
||||
|
||||
/** Marks the specified biogen as available for reuse (puts it back into m_BiomeGens).
|
||||
a_Tag is the value of m_CurrentTag from the time when the biogen was retrieved; if it is different from
|
||||
current m_CurrentTagValue, the biogen will be disposed of (because reload() has been called in the
|
||||
meantime). */
|
||||
void releaseBiomeGen(cBiomeGenPtr && a_BiomeGen, int a_Tag);
|
||||
};
|
||||
|
||||
|
||||
@@ -70,7 +90,7 @@ public:
|
||||
AnvilSource(QString a_WorldRegionFolder);
|
||||
|
||||
// ChunkSource overrides:
|
||||
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
|
||||
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, Chunk & a_DestChunk) override;
|
||||
virtual void reload() override;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include "src/Generating/BioGen.h"
|
||||
#include "inifile/iniFile.h"
|
||||
#include "src/IniFile.h"
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ static const QString s_GeneratorNames[] =
|
||||
QString("Checkerboard"),
|
||||
QString("Constant"),
|
||||
QString("DistortedVoronoi"),
|
||||
QString("Grown"),
|
||||
QString("GrownProt"),
|
||||
QString("MultiStepMap"),
|
||||
QString("TwoLevel"),
|
||||
QString("Voronoi"),
|
||||
@@ -31,6 +33,7 @@ GeneratorSetup::GeneratorSetup(const AString & a_IniFileName, QWidget * a_Parent
|
||||
m_eSeed = new QLineEdit();
|
||||
m_eSeed->setValidator(new QIntValidator());
|
||||
m_eSeed->setText("0");
|
||||
m_eSeed->setProperty("INI.SectionName", QVariant("Seed"));
|
||||
m_eSeed->setProperty("INI.ItemName", QVariant("Seed"));
|
||||
m_cbGenerator = new QComboBox();
|
||||
m_cbGenerator->setMinimumWidth(120);
|
||||
@@ -53,17 +56,12 @@ GeneratorSetup::GeneratorSetup(const AString & a_IniFileName, QWidget * a_Parent
|
||||
setLayout(m_MainLayout);
|
||||
|
||||
// Load the INI file, if specified, otherwise set defaults:
|
||||
if (!a_IniFileName.empty() && m_IniFile->ReadFile(a_IniFileName))
|
||||
{
|
||||
m_cbGenerator->setCurrentText(QString::fromStdString(m_IniFile->GetValue("Generator", "BiomeGen")));
|
||||
m_eSeed->setText(QString::number(m_IniFile->GetValueI("Generator", "Seed")));
|
||||
}
|
||||
else
|
||||
if (a_IniFileName.empty() || !m_IniFile->ReadFile(a_IniFileName))
|
||||
{
|
||||
m_IniFile->SetValue("Generator", "Generator", "Composable");
|
||||
m_IniFile->SetValue("Generator", "BiomeGen", m_cbGenerator->currentText().toStdString());
|
||||
bool dummy;
|
||||
delete cBiomeGen::CreateBiomeGen(*m_IniFile, 0, dummy);
|
||||
cBiomeGen::CreateBiomeGen(*m_IniFile, 0, dummy);
|
||||
}
|
||||
updateFromIni();
|
||||
|
||||
@@ -95,7 +93,7 @@ void GeneratorSetup::generatorChanged(const QString & a_NewName)
|
||||
|
||||
// Create a dummy biome gen from the INI file, this will create the defaults in the INI file:
|
||||
bool dummy;
|
||||
delete cBiomeGen::CreateBiomeGen(*m_IniFile, m_Seed, dummy);
|
||||
cBiomeGen::CreateBiomeGen(*m_IniFile, m_Seed, dummy);
|
||||
|
||||
// Read all values from the INI file and put them into the form layout:
|
||||
updateFromIni();
|
||||
@@ -110,8 +108,9 @@ void GeneratorSetup::generatorChanged(const QString & a_NewName)
|
||||
|
||||
void GeneratorSetup::editChanged(const QString & a_NewValue)
|
||||
{
|
||||
QString itemName = sender()->property("INI.ItemName").toString();
|
||||
m_IniFile->SetValue("Generator", itemName.toStdString(), a_NewValue.toStdString());
|
||||
QString sectionName = sender()->property("INI.SectionName").toString();
|
||||
QString itemName = sender()->property("INI.ItemName").toString();
|
||||
m_IniFile->SetValue(sectionName.toStdString(), itemName.toStdString(), a_NewValue.toStdString());
|
||||
emit generatorUpdated();
|
||||
}
|
||||
|
||||
@@ -121,6 +120,7 @@ void GeneratorSetup::editChanged(const QString & a_NewValue)
|
||||
|
||||
void GeneratorSetup::updateFromIni()
|
||||
{
|
||||
m_eSeed->setText(QString::number(m_IniFile->GetValueI("Seed", "Seed", 0)));
|
||||
int keyID = m_IniFile->FindKey("Generator");
|
||||
if (keyID <= -1)
|
||||
{
|
||||
@@ -141,6 +141,7 @@ void GeneratorSetup::updateFromIni()
|
||||
|
||||
QLineEdit * edit = new QLineEdit();
|
||||
edit->setText(QString::fromStdString(itemValue));
|
||||
edit->setProperty("INI.SectionName", QVariant("Generator"));
|
||||
edit->setProperty("INI.ItemName", QVariant(QString::fromStdString(itemName)));
|
||||
|
||||
// Remove the generator name prefix from the item name, for clarity purposes:
|
||||
|
||||
@@ -158,8 +158,17 @@ template class SizeChecker<UInt16, 2>;
|
||||
TypeName(const TypeName &); \
|
||||
void operator =(const TypeName &)
|
||||
|
||||
// A macro that is used to mark unused local variables, to avoid pedantic warnings in gcc / clang / MSVC
|
||||
// Note that in MSVC it requires the full type of X to be known
|
||||
#define UNUSED_VAR(X) (void)(X)
|
||||
|
||||
// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
|
||||
#define UNUSED(X) (void)(X)
|
||||
// Written so that the full type of param needn't be known
|
||||
#ifdef _MSC_VER
|
||||
#define UNUSED(X)
|
||||
#else
|
||||
#define UNUSED UNUSED_VAR
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,12 +7,23 @@
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
#include <QDirIterator>
|
||||
#include "inifile/iniFile.h"
|
||||
#include <QStatusBar>
|
||||
#include "ChunkSource.h"
|
||||
#include "src/IniFile.h"
|
||||
#include "src/Generating/BioGen.h"
|
||||
#include "src/StringCompression.h"
|
||||
#include "src/WorldStorage/FastNBT.h"
|
||||
#include "GeneratorSetup.h"
|
||||
#include "RegionLoader.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const double MainWindow::m_ViewZooms[] =
|
||||
{
|
||||
0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16, 24,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,11 +32,27 @@
|
||||
MainWindow::MainWindow(QWidget * parent) :
|
||||
QMainWindow(parent),
|
||||
m_GeneratorSetup(nullptr),
|
||||
m_LineSeparator(nullptr)
|
||||
m_LineSeparator(nullptr),
|
||||
m_CurrentZoomLevel(2)
|
||||
{
|
||||
initMinecraftPath();
|
||||
|
||||
m_BiomeView = new BiomeView();
|
||||
connect(m_BiomeView, SIGNAL(increaseZoom()), this, SLOT(increaseZoom()));
|
||||
connect(m_BiomeView, SIGNAL(decreaseZoom()), this, SLOT(decreaseZoom()));
|
||||
connect(m_BiomeView, SIGNAL(wheelUp()), this, SLOT(increaseZoom()));
|
||||
connect(m_BiomeView, SIGNAL(wheelDown()), this, SLOT(decreaseZoom()));
|
||||
m_BiomeView->setZoomLevel(m_ViewZooms[m_CurrentZoomLevel]);
|
||||
|
||||
m_StatusBar = new QStatusBar();
|
||||
this->setStatusBar(m_StatusBar);
|
||||
m_StatusBlockX = new QLabel(tr("X"));
|
||||
m_StatusBlockZ = new QLabel(tr("Z"));
|
||||
m_StatusBiome = new QLabel(tr("B"));
|
||||
m_StatusBar->addPermanentWidget(m_StatusBlockX);
|
||||
m_StatusBar->addPermanentWidget(m_StatusBlockZ);
|
||||
m_StatusBar->addPermanentWidget(m_StatusBiome);
|
||||
|
||||
m_MainLayout = new QHBoxLayout();
|
||||
m_MainLayout->addWidget(m_BiomeView, 1);
|
||||
m_MainLayout->setMenuBar(menuBar());
|
||||
@@ -36,6 +63,8 @@ MainWindow::MainWindow(QWidget * parent) :
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
|
||||
connect(m_BiomeView, SIGNAL(hoverChanged(int, int, int)), this, SLOT(hoverChanged(int, int, int)));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +73,7 @@ MainWindow::MainWindow(QWidget * parent) :
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
|
||||
RegionLoader::shutdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +158,80 @@ void MainWindow::openVanillaWorld()
|
||||
|
||||
|
||||
|
||||
void MainWindow::centerView()
|
||||
{
|
||||
m_BiomeView->setPosition(0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::setViewZoom()
|
||||
{
|
||||
// The zoom level is stored in the sender action's data, retrieve it:
|
||||
QAction * action = qobject_cast<QAction *>(sender());
|
||||
if (action == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_CurrentZoomLevel = action->data().toInt();
|
||||
double newZoom = m_ViewZooms[m_CurrentZoomLevel];
|
||||
m_BiomeView->setZoomLevel(newZoom);
|
||||
action->setChecked(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::increaseZoom()
|
||||
{
|
||||
// If already at max zoom, bail out:
|
||||
if (m_CurrentZoomLevel >= ARRAYCOUNT(m_ViewZooms) - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Increase the zoom level:
|
||||
m_CurrentZoomLevel += 1;
|
||||
m_actViewZoom[m_CurrentZoomLevel]->setChecked(true);
|
||||
m_BiomeView->setZoomLevel(m_ViewZooms[m_CurrentZoomLevel]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::decreaseZoom()
|
||||
{
|
||||
// If already at min zoom, bail out:
|
||||
if (m_CurrentZoomLevel == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Decrease the zoom level:
|
||||
m_CurrentZoomLevel -= 1;
|
||||
m_actViewZoom[m_CurrentZoomLevel]->setChecked(true);
|
||||
m_BiomeView->setZoomLevel(m_ViewZooms[m_CurrentZoomLevel]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::hoverChanged(int a_BlockX, int a_BlockZ, int a_Biome)
|
||||
{
|
||||
m_StatusBlockX->setText(tr("X: %1").arg(a_BlockX));
|
||||
m_StatusBlockZ->setText(tr("Z: %1").arg(a_BlockZ));
|
||||
m_StatusBiome->setText (tr("B: %1 (%2)").arg(BiomeToString(a_Biome).c_str()).arg(a_Biome));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::initMinecraftPath()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
@@ -147,6 +250,7 @@ void MainWindow::initMinecraftPath()
|
||||
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
// Map menu:
|
||||
createWorldActions();
|
||||
|
||||
m_actNewGen = new QAction(tr("&New generator"), this);
|
||||
@@ -173,6 +277,22 @@ void MainWindow::createActions()
|
||||
m_actExit->setShortcut(tr("Alt+X"));
|
||||
m_actExit->setStatusTip(tr("Exit %1").arg(QApplication::instance()->applicationName()));
|
||||
connect(m_actExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
|
||||
// View menu:
|
||||
m_actViewCenter = new QAction(tr("&Reset to center"), this);
|
||||
m_actViewCenter->setStatusTip(tr("Scrolls the view back to the map center"));
|
||||
connect(m_actViewCenter, SIGNAL(triggered()), this, SLOT(centerView()));
|
||||
|
||||
QActionGroup * zoomGroup = new QActionGroup(this);
|
||||
for (int i = 0; i < ARRAYCOUNT(m_ViewZooms); i++)
|
||||
{
|
||||
m_actViewZoom[i] = new QAction(tr("&Zoom %1%").arg(std::floor(m_ViewZooms[i] * 100)), this);
|
||||
m_actViewZoom[i]->setCheckable(true);
|
||||
m_actViewZoom[i]->setData(QVariant(i));
|
||||
zoomGroup->addAction(m_actViewZoom[i]);
|
||||
connect(m_actViewZoom[i], SIGNAL(triggered()), this, SLOT(setViewZoom()));
|
||||
}
|
||||
m_actViewZoom[m_CurrentZoomLevel]->setChecked(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -220,11 +340,12 @@ void MainWindow::createWorldActions()
|
||||
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
// Map menu:
|
||||
QMenu * file = menuBar()->addMenu(tr("&Map"));
|
||||
file->addAction(m_actNewGen);
|
||||
file->addAction(m_actOpenGen);
|
||||
file->addSeparator();
|
||||
QMenu * worlds = file->addMenu(tr("Open existing"));
|
||||
QMenu * worlds = file->addMenu(tr("Open &existing"));
|
||||
worlds->addActions(m_WorldActions);
|
||||
if (m_WorldActions.empty())
|
||||
{
|
||||
@@ -235,6 +356,15 @@ void MainWindow::createMenus()
|
||||
file->addAction(m_actReload);
|
||||
file->addSeparator();
|
||||
file->addAction(m_actExit);
|
||||
|
||||
// View menu:
|
||||
QMenu * view = menuBar()->addMenu(tr("&View"));
|
||||
view->addAction(m_actViewCenter);
|
||||
view->addSeparator();
|
||||
for (size_t i = 0; i < ARRAYCOUNT(m_actViewZoom); i++)
|
||||
{
|
||||
view->addAction(m_actViewZoom[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QList>
|
||||
#include <QMainWindow>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include "BiomeView.h"
|
||||
|
||||
|
||||
@@ -39,13 +40,33 @@ private slots:
|
||||
/** Opens a vanilla world that is specified by the calling action. */
|
||||
void openVanillaWorld();
|
||||
|
||||
/** Moves the view to the map's center. */
|
||||
void centerView();
|
||||
|
||||
/** Sets the zoom level specified in the triggering action. */
|
||||
void setViewZoom();
|
||||
|
||||
/** Sets a zoom level one step larger than current, if allowed. */
|
||||
void increaseZoom();
|
||||
|
||||
/** Sets a zoom level one step smaller than current, if allowed. */
|
||||
void decreaseZoom();
|
||||
|
||||
/** Updates the statusbar for the specified info about the current block under the cursor. */
|
||||
void hoverChanged(int a_BlockX, int a_BlockZ, int a_Biome);
|
||||
|
||||
protected:
|
||||
/** The zoom levels */
|
||||
static const double m_ViewZooms[10];
|
||||
|
||||
// Actions:
|
||||
QAction * m_actNewGen;
|
||||
QAction * m_actOpenGen;
|
||||
QAction * m_actOpenWorld;
|
||||
QAction * m_actReload;
|
||||
QAction * m_actExit;
|
||||
QAction * m_actViewCenter;
|
||||
QAction * m_actViewZoom[ARRAYCOUNT(m_ViewZooms)];
|
||||
|
||||
/** List of actions that open the specific vanilla world. */
|
||||
QList<QAction *> m_WorldActions;
|
||||
@@ -62,9 +83,19 @@ protected:
|
||||
/** The layout for the window. */
|
||||
QHBoxLayout * m_MainLayout;
|
||||
|
||||
/** The status bar that displays the current hover information. */
|
||||
QStatusBar * m_StatusBar;
|
||||
|
||||
QLabel * m_StatusBlockX;
|
||||
QLabel * m_StatusBlockZ;
|
||||
QLabel * m_StatusBiome;
|
||||
|
||||
/** The separator line between biome view and generator setup. */
|
||||
QWidget * m_LineSeparator;
|
||||
|
||||
/** Index into m_ViewZooms[] for the current zoom level. */
|
||||
size_t m_CurrentZoomLevel;
|
||||
|
||||
|
||||
/** Initializes the m_MinecraftPath based on the proper MC path */
|
||||
void initMinecraftPath();
|
||||
|
||||
@@ -12,76 +12,86 @@ TARGET = QtBiomeVisualiser
|
||||
TEMPLATE = app
|
||||
|
||||
|
||||
SOURCES +=\
|
||||
MainWindow.cpp \
|
||||
BiomeView.cpp \
|
||||
../../src/Generating/BioGen.cpp \
|
||||
../../src/VoronoiMap.cpp \
|
||||
../../src/Noise.cpp \
|
||||
../../src/StringUtils.cpp \
|
||||
../../src/LoggerListeners.cpp \
|
||||
../../src/Logger.cpp \
|
||||
../../lib/inifile/iniFile.cpp \
|
||||
../../src/OSSupport/File.cpp \
|
||||
../../src/OSSupport/CriticalSection.cpp \
|
||||
../../src/OSSupport/IsThread.cpp \
|
||||
../../src/BiomeDef.cpp \
|
||||
ChunkCache.cpp \
|
||||
ChunkSource.cpp \
|
||||
ChunkLoader.cpp \
|
||||
../../src/StringCompression.cpp \
|
||||
../../src/WorldStorage/FastNBT.cpp \
|
||||
../../lib/zlib/adler32.c \
|
||||
../../lib/zlib/compress.c \
|
||||
../../lib/zlib/crc32.c \
|
||||
../../lib/zlib/deflate.c \
|
||||
../../lib/zlib/gzclose.c \
|
||||
../../lib/zlib/gzlib.c \
|
||||
../../lib/zlib/gzread.c \
|
||||
../../lib/zlib/gzwrite.c \
|
||||
../../lib/zlib/infback.c \
|
||||
../../lib/zlib/inffast.c \
|
||||
../../lib/zlib/inflate.c \
|
||||
../../lib/zlib/inftrees.c \
|
||||
../../lib/zlib/trees.c \
|
||||
../../lib/zlib/uncompr.c \
|
||||
../../lib/zlib/zutil.c \
|
||||
GeneratorSetup.cpp \
|
||||
QtBiomeVisualiser.cpp \
|
||||
QtChunk.cpp
|
||||
SOURCES += \
|
||||
MainWindow.cpp \
|
||||
BiomeView.cpp \
|
||||
../../src/Generating/BioGen.cpp \
|
||||
../../src/VoronoiMap.cpp \
|
||||
../../src/Noise.cpp \
|
||||
../../src/StringUtils.cpp \
|
||||
../../src/LoggerListeners.cpp \
|
||||
../../src/Logger.cpp \
|
||||
../../src/IniFile.cpp \
|
||||
../../src/OSSupport/File.cpp \
|
||||
../../src/OSSupport/CriticalSection.cpp \
|
||||
../../src/OSSupport/IsThread.cpp \
|
||||
../../src/BiomeDef.cpp \
|
||||
../../src/StringCompression.cpp \
|
||||
../../src/WorldStorage/FastNBT.cpp \
|
||||
../../lib/zlib/adler32.c \
|
||||
../../lib/zlib/compress.c \
|
||||
../../lib/zlib/crc32.c \
|
||||
../../lib/zlib/deflate.c \
|
||||
../../lib/zlib/gzclose.c \
|
||||
../../lib/zlib/gzlib.c \
|
||||
../../lib/zlib/gzread.c \
|
||||
../../lib/zlib/gzwrite.c \
|
||||
../../lib/zlib/infback.c \
|
||||
../../lib/zlib/inffast.c \
|
||||
../../lib/zlib/inflate.c \
|
||||
../../lib/zlib/inftrees.c \
|
||||
../../lib/zlib/trees.c \
|
||||
../../lib/zlib/uncompr.c \
|
||||
../../lib/zlib/zutil.c \
|
||||
GeneratorSetup.cpp \
|
||||
QtBiomeVisualiser.cpp \
|
||||
QtChunk.cpp \
|
||||
RegionCache.cpp \
|
||||
Region.cpp \
|
||||
ChunkSource.cpp \
|
||||
RegionLoader.cpp
|
||||
|
||||
|
||||
|
||||
HEADERS += \
|
||||
MainWindow.h \
|
||||
QtChunk.h \
|
||||
Globals.h \
|
||||
BiomeView.h \
|
||||
../../src/Generating/BioGen.h \
|
||||
../../src/Generating/IntGen.h \
|
||||
../../src/Generating/ProtIntGen.h \
|
||||
../../src/VoronoiMap.h \
|
||||
../../src/Noise.h \
|
||||
../../src/StringUtils.h \
|
||||
../../src/LoggerListeners.h \
|
||||
../../src/Logger.h \
|
||||
../../src/IniFile.h \
|
||||
../../src/OSSupport/File.h \
|
||||
../../src/OSSupport/CriticalSection.h \
|
||||
../../src/OSSupport/IsThread.h \
|
||||
../../src/BiomeDef.h \
|
||||
../../src/StringCompression.h \
|
||||
../../src/WorldStorage/FastNBT.h \
|
||||
../../lib/zlib/crc32.h \
|
||||
../../lib/zlib/deflate.h \
|
||||
../../lib/zlib/gzguts.h \
|
||||
../../lib/zlib/inffast.h \
|
||||
../../lib/zlib/inffixed.h \
|
||||
../../lib/zlib/inflate.h \
|
||||
../../lib/zlib/inftrees.h \
|
||||
../../lib/zlib/trees.h \
|
||||
../../lib/zlib/zconf.h \
|
||||
../../lib/zlib/zlib.h \
|
||||
../../lib/zlib/zutil.h \
|
||||
GeneratorSetup.h \
|
||||
QtChunk.h \
|
||||
RegionCache.h \
|
||||
Region.h \
|
||||
ChunkSource.h \
|
||||
RegionLoader.h
|
||||
|
||||
|
||||
HEADERS += MainWindow.h \
|
||||
Globals.h \
|
||||
BiomeView.h \
|
||||
../../src/Generating/BioGen.h \
|
||||
../../src/VoronoiMap.h \
|
||||
../../src/Noise.h \
|
||||
../../src/StringUtils.h \
|
||||
../../src/LoggerListeners.h \
|
||||
../../src/Logger.h \
|
||||
../../lib/inifile/iniFile.h \
|
||||
../../src/OSSupport/File.h \
|
||||
../../src/OSSupport/CriticalSection.h \
|
||||
../../src/OSSupport/IsThread.h \
|
||||
../../src/BiomeDef.h \
|
||||
ChunkCache.h \
|
||||
ChunkSource.h \
|
||||
ChunkLoader.h \
|
||||
../../src/StringCompression.h \
|
||||
../../src/WorldStorage/FastNBT.h \
|
||||
../../lib/zlib/crc32.h \
|
||||
../../lib/zlib/deflate.h \
|
||||
../../lib/zlib/gzguts.h \
|
||||
../../lib/zlib/inffast.h \
|
||||
../../lib/zlib/inffixed.h \
|
||||
../../lib/zlib/inflate.h \
|
||||
../../lib/zlib/inftrees.h \
|
||||
../../lib/zlib/trees.h \
|
||||
../../lib/zlib/zconf.h \
|
||||
../../lib/zlib/zlib.h \
|
||||
../../lib/zlib/zutil.h \
|
||||
GeneratorSetup.h \
|
||||
QtChunk.h
|
||||
|
||||
INCLUDEPATH += $$_PRO_FILE_PWD_ \
|
||||
$$_PRO_FILE_PWD_/../../lib \
|
||||
|
||||
@@ -14,22 +14,28 @@ Chunk::Chunk() :
|
||||
|
||||
|
||||
|
||||
const uchar * Chunk::getImage(void) const
|
||||
void Chunk::setBiomes(const cChunkDef::BiomeMap & a_Biomes)
|
||||
{
|
||||
ASSERT(m_IsValid);
|
||||
return m_Image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Chunk::setImage(const Image & a_Image)
|
||||
{
|
||||
memcpy(m_Image, a_Image, sizeof(a_Image));
|
||||
for (size_t idx = 0; idx < ARRAYCOUNT(a_Biomes); ++idx)
|
||||
{
|
||||
m_Biomes[idx] = static_cast<short>(a_Biomes[idx]);
|
||||
}
|
||||
m_IsValid = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EMCSBiome Chunk::getBiome(int a_RelX, int a_RelZ)
|
||||
{
|
||||
if (!m_IsValid)
|
||||
{
|
||||
return biInvalidBiome;
|
||||
}
|
||||
return static_cast<EMCSBiome>(m_Biomes[a_RelX + 16 * a_RelZ]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,18 +18,23 @@ public:
|
||||
/** Returns true iff the chunk data is valid - loaded or generated. */
|
||||
bool isValid(void) const { return m_IsValid; }
|
||||
|
||||
/** Returns the image of the chunk's biomes. Assumes that the chunk is valid. */
|
||||
const uchar * getImage(void) const;
|
||||
/** Sets the biomes to m_Biomes and renders them into m_Image. */
|
||||
void setBiomes(const cChunkDef::BiomeMap & a_Biomes);
|
||||
|
||||
/** Sets the image data for this chunk. */
|
||||
void setImage(const Image & a_Image);
|
||||
/** Returns the biome at the specified relative coords, or biInvalidBiome if not valid.
|
||||
Coords must be valid inside this chunk. */
|
||||
EMCSBiome getBiome(int a_RelX, int a_RelZ);
|
||||
|
||||
/** Returns the raw biome data for this chunk. */
|
||||
const short * getBiomes(void) const { return m_Biomes; }
|
||||
|
||||
protected:
|
||||
/** Flag that specifies if the chunk data is valid - loaded or generated. */
|
||||
bool m_IsValid;
|
||||
|
||||
/** Cached rendered image of this chunk's biomes. Updated in render(). */
|
||||
Image m_Image;
|
||||
/** Biomes comprising the chunk, in the X + 16 * Z ordering.
|
||||
Typed as short to save on memory, converted automatically when needed. */
|
||||
short m_Biomes[16 * 16];
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Chunk> ChunkPtr;
|
||||
|
||||
72
Tools/QtBiomeVisualiser/Region.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Region.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Region::Region()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Chunk & Region::getRelChunk(int a_RelChunkX, int a_RelChunkZ)
|
||||
{
|
||||
ASSERT(a_RelChunkX >= 0);
|
||||
ASSERT(a_RelChunkZ >= 0);
|
||||
ASSERT(a_RelChunkX < 32);
|
||||
ASSERT(a_RelChunkZ < 32);
|
||||
|
||||
return m_Chunks[a_RelChunkX + a_RelChunkZ * 32];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int Region::getRelBiome(int a_RelBlockX, int a_RelBlockZ)
|
||||
{
|
||||
ASSERT(a_RelBlockX >= 0);
|
||||
ASSERT(a_RelBlockZ >= 0);
|
||||
ASSERT(a_RelBlockX < 512);
|
||||
ASSERT(a_RelBlockZ < 512);
|
||||
|
||||
int chunkX = a_RelBlockX / 16;
|
||||
int chunkZ = a_RelBlockZ / 16;
|
||||
Chunk & chunk = m_Chunks[chunkX + 32 * chunkZ];
|
||||
if (chunk.isValid())
|
||||
{
|
||||
return chunk.getBiome(a_RelBlockX - 16 * chunkX, a_RelBlockZ - 16 * chunkZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
return biInvalidBiome;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Region::blockToRegion(int a_BlockX, int a_BlockZ, int & a_RegionX, int & a_RegionZ)
|
||||
{
|
||||
a_RegionX = static_cast<int>(std::floor(static_cast<float>(a_BlockX) / 512));
|
||||
a_RegionZ = static_cast<int>(std::floor(static_cast<float>(a_BlockZ) / 512));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Region::chunkToRegion(int a_ChunkX, int a_ChunkZ, int & a_RegionX, int & a_RegionZ)
|
||||
{
|
||||
a_RegionX = static_cast<int>(std::floor(static_cast<float>(a_ChunkX) / 32));
|
||||
a_RegionZ = static_cast<int>(std::floor(static_cast<float>(a_ChunkZ) / 32));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
46
Tools/QtBiomeVisualiser/Region.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "QtChunk.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Region
|
||||
{
|
||||
public:
|
||||
Region();
|
||||
|
||||
/** Retrieves the chunk with the specified relative coords. */
|
||||
Chunk & getRelChunk(int a_RelChunkX, int a_RelChunkZ);
|
||||
|
||||
/** Returns true iff the chunk data for all chunks has been loaded.
|
||||
This doesn't mean that all the chunks are valid, only that the entire region has been processed and should
|
||||
be displayed. */
|
||||
bool isValid(void) const { return m_IsValid; }
|
||||
|
||||
/** Returns the biome in the block coords relative to this region.
|
||||
Returns biInvalidBiome if the underlying chunk is not valid. */
|
||||
int getRelBiome(int a_RelBlockX, int a_RelBlockZ);
|
||||
|
||||
/** Converts block coordinates into region coordinates. */
|
||||
static void blockToRegion(int a_BlockX, int a_BlockZ, int & a_RegionX, int & a_RegionZ);
|
||||
|
||||
/** Converts chunk coordinates into region coordinates. */
|
||||
static void chunkToRegion(int a_ChunkX, int a_ChunkZ, int & a_RegionX, int & a_RegionZ);
|
||||
|
||||
protected:
|
||||
friend class RegionLoader;
|
||||
|
||||
|
||||
Chunk m_Chunks[32 * 32];
|
||||
|
||||
/** True iff the data for all the chunks has been loaded.
|
||||
This doesn't mean that all the chunks are valid, only that the entire region has been processed and should
|
||||
be displayed. */
|
||||
bool m_IsValid;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
138
Tools/QtBiomeVisualiser/RegionCache.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
#include "Globals.h"
|
||||
#include "RegionCache.h"
|
||||
#include <QMutexLocker>
|
||||
#include <QThreadPool>
|
||||
#include "ChunkSource.h"
|
||||
#include "RegionLoader.h"
|
||||
#include "Region.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RegionCache::RegionCache(QObject * parent) :
|
||||
super(parent)
|
||||
{
|
||||
m_Cache.setMaxCost(1024 * 1024 * 1024); // 1 GiB of memory for the cache
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RegionPtr RegionCache::fetch(int a_RegionX, int a_RegionZ)
|
||||
{
|
||||
// Retrieve from the cache:
|
||||
quint32 hash = getRegionHash(a_RegionX, a_RegionZ);
|
||||
RegionPtr * res;
|
||||
{
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
res = m_Cache[hash];
|
||||
// If succesful and region loaded, return the retrieved value:
|
||||
if ((res != nullptr) && (*res)->isValid())
|
||||
{
|
||||
return *res;
|
||||
}
|
||||
}
|
||||
|
||||
// If the region is in cache but not valid, it means it has been already queued for rendering, do nothing now:
|
||||
if (res != nullptr)
|
||||
{
|
||||
return RegionPtr(nullptr);
|
||||
}
|
||||
|
||||
// There's no such item in the cache, create it now:
|
||||
try
|
||||
{
|
||||
res = new RegionPtr(new Region);
|
||||
}
|
||||
catch (const std::bad_alloc &)
|
||||
{
|
||||
/* Allocation failed (32-bit process hit the 2 GiB barrier?)
|
||||
This may happen even with the cache set to 1 GiB, because it contains shared ptrs and so they may be
|
||||
held by another place in the code even when they are removed from cache.
|
||||
*/
|
||||
return RegionPtr(nullptr);
|
||||
}
|
||||
if (res == nullptr)
|
||||
{
|
||||
return RegionPtr(nullptr);
|
||||
}
|
||||
{
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
m_Cache.insert(hash, res, sizeof(Region));
|
||||
}
|
||||
|
||||
// Queue the region for rendering:
|
||||
queueRegionRender(a_RegionX, a_RegionZ, *res);
|
||||
|
||||
// Return failure, the region is not yet rendered:
|
||||
return RegionPtr(nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RegionCache::setChunkSource(std::shared_ptr<ChunkSource> a_ChunkSource)
|
||||
{
|
||||
// Replace the chunk source:
|
||||
m_ChunkSource = a_ChunkSource;
|
||||
|
||||
// Clear the cache:
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
m_Cache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RegionCache::reload()
|
||||
{
|
||||
assert(m_ChunkSource.get() != nullptr);
|
||||
|
||||
// Reload the chunk source:
|
||||
m_ChunkSource->reload();
|
||||
|
||||
// Clear the cache:
|
||||
QMutexLocker lock(&m_Mtx);
|
||||
m_Cache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RegionCache::gotRegion(int a_RegionX, int a_RegionZ)
|
||||
{
|
||||
emit regionAvailable(a_RegionX, a_RegionZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
quint32 RegionCache::getRegionHash(int a_RegionX, int a_RegionZ)
|
||||
{
|
||||
// Simply join the two coords into a single int
|
||||
// The coords will never be larger than 16-bits, so we can do this safely
|
||||
return (((static_cast<quint32>(a_RegionX) & 0xffff) << 16) | (static_cast<quint32>(a_RegionZ) & 0xffff));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RegionCache::queueRegionRender(int a_RegionX, int a_RegionZ, RegionPtr & a_Region)
|
||||
{
|
||||
// Create a new loader task:
|
||||
RegionLoader * loader = new RegionLoader(a_RegionX, a_RegionZ, a_Region, m_ChunkSource);
|
||||
connect(loader, SIGNAL(loaded(int, int)), this, SLOT(gotRegion(int, int)));
|
||||
|
||||
QThreadPool::globalInstance()->start(loader);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
|
||||
|
||||
|
||||
class Chunk;
|
||||
typedef std::shared_ptr<Chunk> ChunkPtr;
|
||||
// fwd:
|
||||
class Region;
|
||||
typedef std::shared_ptr<Region> RegionPtr;
|
||||
|
||||
class ChunkSource;
|
||||
|
||||
@@ -18,19 +19,19 @@ class ChunkSource;
|
||||
|
||||
|
||||
|
||||
/** Caches chunk data for reuse */
|
||||
class ChunkCache :
|
||||
/** Caches regions' chunk data for reuse */
|
||||
class RegionCache :
|
||||
public QObject
|
||||
{
|
||||
typedef QObject super;
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChunkCache(QObject * parent = NULL);
|
||||
explicit RegionCache(QObject * parent = NULL);
|
||||
|
||||
/** Retrieves the specified chunk from the cache.
|
||||
Only returns valid chunks; if the chunk is invalid, queues it for rendering and returns an empty ptr. */
|
||||
ChunkPtr fetch(int a_ChunkX, int a_ChunkZ);
|
||||
/** Retrieves the specified region from the cache.
|
||||
Only returns valid regions; if the region is invalid, queues it for rendering and returns an empty ptr. */
|
||||
RegionPtr fetch(int a_RegionX, int a_RegionZ);
|
||||
|
||||
/** Replaces the chunk source used by the biome view to get the chunk biome data.
|
||||
The cache is then invalidated. */
|
||||
@@ -43,16 +44,16 @@ public:
|
||||
void reload();
|
||||
|
||||
signals:
|
||||
void chunkAvailable(int a_ChunkX, int a_ChunkZ);
|
||||
void regionAvailable(int a_RegionX, int a_RegionZ);
|
||||
|
||||
protected slots:
|
||||
void gotChunk(int a_ChunkX, int a_ChunkZ);
|
||||
void gotRegion(int a_RegionX, int a_RegionZ);
|
||||
|
||||
protected:
|
||||
/** The cache of the chunks */
|
||||
QCache<quint32, ChunkPtr> m_Cache;
|
||||
QCache<quint32, RegionPtr> m_Cache;
|
||||
|
||||
/** Locks te cache against multithreaded access */
|
||||
/** Locks the cache against multithreaded access */
|
||||
QMutex m_Mtx;
|
||||
|
||||
/** The source used to get the biome data. */
|
||||
@@ -60,10 +61,10 @@ protected:
|
||||
|
||||
|
||||
/** Returns the hash used by the chunk in the cache */
|
||||
quint32 getChunkHash(int a_ChunkX, int a_ChunkZ);
|
||||
quint32 getRegionHash(int a_RegionX, int a_RegionZ);
|
||||
|
||||
/** Queues the specified chunk for rendering by m_ChunkSource. */
|
||||
void queueChunkRender(int a_ChunkX, int a_ChunkZ, ChunkPtr & a_Chunk);
|
||||
/** Queues the specified region for rendering by m_RegionSource. */
|
||||
void queueRegionRender(int a_RegionX, int a_RegionZ, RegionPtr & a_Region);
|
||||
};
|
||||
|
||||
|
||||
49
Tools/QtBiomeVisualiser/RegionLoader.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "Globals.h"
|
||||
#include "RegionLoader.h"
|
||||
#include "ChunkSource.h"
|
||||
#include "Region.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
volatile bool RegionLoader::m_IsShuttingDown = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RegionLoader::RegionLoader(int a_RegionX, int a_RegionZ, RegionPtr a_Region, ChunkSourcePtr a_ChunkSource) :
|
||||
m_RegionX(a_RegionX),
|
||||
m_RegionZ(a_RegionZ),
|
||||
m_Region(a_Region),
|
||||
m_ChunkSource(a_ChunkSource)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void RegionLoader::run()
|
||||
{
|
||||
// Load all the chunks in this region:
|
||||
for (int z = 0; z < 32; z++)
|
||||
{
|
||||
for (int x = 0; x < 32; x++)
|
||||
{
|
||||
m_ChunkSource->getChunkBiomes(m_RegionX * 32 + x, m_RegionZ * 32 + z, m_Region->getRelChunk(x, z));
|
||||
if (m_IsShuttingDown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Region->m_IsValid = true;
|
||||
|
||||
emit loaded(m_RegionX, m_RegionZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
56
Tools/QtBiomeVisualiser/RegionLoader.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QRunnable>
|
||||
#include <memory>
|
||||
|
||||
|
||||
|
||||
|
||||
// fwd:
|
||||
class Region;
|
||||
typedef std::shared_ptr<Region> RegionPtr;
|
||||
|
||||
class ChunkSource;
|
||||
typedef std::shared_ptr<ChunkSource> ChunkSourcePtr;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class RegionLoader :
|
||||
public QObject,
|
||||
public QRunnable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RegionLoader(int a_RegionX, int a_RegionZ, RegionPtr a_Region, ChunkSourcePtr a_ChunkSource);
|
||||
virtual ~RegionLoader() {}
|
||||
|
||||
/** Signals to all loaders that the app is shutting down and the loading should be aborted. */
|
||||
static void shutdown() { m_IsShuttingDown = true; }
|
||||
|
||||
signals:
|
||||
void loaded(int a_RegionX, int a_RegionZ);
|
||||
|
||||
protected:
|
||||
virtual void run() override;
|
||||
|
||||
private:
|
||||
/** Coords of the region to be loaded. */
|
||||
int m_RegionX, m_RegionZ;
|
||||
|
||||
/** The region to be loaded. */
|
||||
RegionPtr m_Region;
|
||||
|
||||
/** The chunk source to be used for individual chunks within the region. */
|
||||
ChunkSourcePtr m_ChunkSource;
|
||||
|
||||
/** Flag that is set upon app exit to terminate the queued loaders faster. */
|
||||
static volatile bool m_IsShuttingDown;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
11
app.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
name: MCServer
|
||||
image: ubuntu-14-04-x64
|
||||
config:
|
||||
#cloud-config
|
||||
packages:
|
||||
- curl
|
||||
- screen
|
||||
runcmd:
|
||||
- mkdir /minecraft
|
||||
- cd /minecraft && curl -s https://raw.githubusercontent.com/mc-server/MCServer/master/easyinstall.sh | sh
|
||||
- cd /minecraft/MCServer && screen -S mcserver -d -m ./MCServer
|
||||
17
easyinstall.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
PLATFORM=$(uname -m)
|
||||
|
||||
echo "Identifying platform: $PLATFORM"
|
||||
case $PLATFORM in
|
||||
"i686") DOWNLOADURL="http://builds.cuberite.org/job/MCServer%20Linux%20x86/lastSuccessfulBuild/artifact/MCServer.tar" ;;
|
||||
"x86_64") DOWNLOADURL="http://builds.cuberite.org/job/MCServer%20Linux%20x64/lastSuccessfulBuild/artifact/MCServer.tar" ;;
|
||||
# Assume that all arm devices are a raspi for now.
|
||||
"arm*") DOWNLOADURL="http://builds.cuberite.org/job/MCServer%20Linux%20armhf/lastSuccessfulBuild/artifact/MCServer.tar"
|
||||
esac
|
||||
|
||||
echo "Downloading precompiled binaries."
|
||||
curl -s $DOWNLOADURL | tar -xzf -
|
||||
echo "Done."
|
||||
|
||||
echo "MCServer is now installed, run using 'cd MCServer; ./MCServer'."
|
||||
@@ -1,11 +0,0 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
project (iniFile)
|
||||
|
||||
include_directories ("${PROJECT_SOURCE_DIR}/../../src/")
|
||||
|
||||
file(GLOB SOURCE
|
||||
"*.h"
|
||||
"*.cpp"
|
||||
)
|
||||
|
||||
add_library(iniFile ${SOURCE})
|
||||
@@ -45,7 +45,7 @@ class cListAllocationPool : public cAllocationPool<T>
|
||||
for (size_t i = 0; i < NumElementsInReserve; i++)
|
||||
{
|
||||
void * space = malloc(sizeof(T));
|
||||
if (space == NULL)
|
||||
if (space == nullptr)
|
||||
{
|
||||
m_Callbacks->OnStartUsingReserve();
|
||||
break;
|
||||
@@ -68,7 +68,7 @@ class cListAllocationPool : public cAllocationPool<T>
|
||||
if (m_FreeList.size() <= NumElementsInReserve)
|
||||
{
|
||||
void * space = malloc(sizeof(T));
|
||||
if (space != NULL)
|
||||
if (space != nullptr)
|
||||
{
|
||||
return new(space) T;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class cListAllocationPool : public cAllocationPool<T>
|
||||
}
|
||||
virtual void Free(T * a_ptr) override
|
||||
{
|
||||
if (a_ptr == NULL)
|
||||
if (a_ptr == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ $cfile "../Vector3.h"
|
||||
$cfile "../ChunkDef.h"
|
||||
$cfile "../BiomeDef.h"
|
||||
|
||||
$cfile "../../lib/inifile/iniFile.h"
|
||||
$cfile "../IniFile.h"
|
||||
|
||||
$cfile "../OSSupport/File.h"
|
||||
|
||||
@@ -27,20 +27,33 @@ $cfile "WebPlugin.h"
|
||||
$cfile "LuaWindow.h"
|
||||
|
||||
$cfile "../BlockID.h"
|
||||
$cfile "../Mobs/MonsterTypes.h"
|
||||
$cfile "../BlockInfo.h"
|
||||
$cfile "../StringUtils.h"
|
||||
$cfile "../Defines.h"
|
||||
$cfile "../ChatColor.h"
|
||||
$cfile "../ClientHandle.h"
|
||||
$cfile "../Entities/ArrowEntity.h"
|
||||
$cfile "../Entities/Entity.h"
|
||||
$cfile "../Entities/EntityEffect.h"
|
||||
$cfile "../Entities/ExpBottleEntity.h"
|
||||
$cfile "../Entities/FireChargeEntity.h"
|
||||
$cfile "../Entities/FireworkEntity.h"
|
||||
$cfile "../Entities/Floater.h"
|
||||
$cfile "../Entities/GhastFireballEntity.h"
|
||||
$cfile "../Entities/HangingEntity.h"
|
||||
$cfile "../Entities/ItemFrame.h"
|
||||
$cfile "../Entities/Pawn.h"
|
||||
$cfile "../Entities/Player.h"
|
||||
$cfile "../Entities/Painting.h"
|
||||
$cfile "../Entities/Pickup.h"
|
||||
$cfile "../Entities/ProjectileEntity.h"
|
||||
$cfile "../Entities/SplashPotionEntity.h"
|
||||
$cfile "../Entities/ThrownEggEntity.h"
|
||||
$cfile "../Entities/ThrownEnderPearlEntity.h"
|
||||
$cfile "../Entities/ThrownSnowballEntity.h"
|
||||
$cfile "../Entities/TNTEntity.h"
|
||||
$cfile "../Entities/EntityEffect.h"
|
||||
$cfile "../Entities/WitherSkullEntity.h"
|
||||
$cfile "../Server.h"
|
||||
$cfile "../World.h"
|
||||
$cfile "../Inventory.h"
|
||||
|
||||
@@ -5,134 +5,133 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
|
||||
include_directories (".")
|
||||
|
||||
SET (SRCS
|
||||
Bindings.cpp
|
||||
DeprecatedBindings.cpp
|
||||
LuaChunkStay.cpp
|
||||
LuaState.cpp
|
||||
LuaWindow.cpp
|
||||
ManualBindings.cpp
|
||||
ManualBindings_RankManager.cpp
|
||||
Plugin.cpp
|
||||
PluginLua.cpp
|
||||
PluginManager.cpp
|
||||
WebPlugin.cpp
|
||||
Bindings.cpp
|
||||
DeprecatedBindings.cpp
|
||||
LuaChunkStay.cpp
|
||||
LuaState.cpp
|
||||
LuaWindow.cpp
|
||||
ManualBindings.cpp
|
||||
ManualBindings_RankManager.cpp
|
||||
Plugin.cpp
|
||||
PluginLua.cpp
|
||||
PluginManager.cpp
|
||||
WebPlugin.cpp
|
||||
)
|
||||
|
||||
SET (HDRS
|
||||
Bindings.h
|
||||
DeprecatedBindings.h
|
||||
LuaChunkStay.h
|
||||
LuaFunctions.h
|
||||
LuaState.h
|
||||
LuaWindow.h
|
||||
ManualBindings.h
|
||||
Plugin.h
|
||||
PluginLua.h
|
||||
PluginManager.h
|
||||
WebPlugin.h
|
||||
tolua++.h
|
||||
Bindings.h
|
||||
DeprecatedBindings.h
|
||||
LuaChunkStay.h
|
||||
LuaFunctions.h
|
||||
LuaState.h
|
||||
LuaWindow.h
|
||||
ManualBindings.h
|
||||
Plugin.h
|
||||
PluginLua.h
|
||||
PluginManager.h
|
||||
WebPlugin.h
|
||||
tolua++.h
|
||||
)
|
||||
|
||||
# List all the files that are generated as part of the Bindings build process
|
||||
set (BINDING_OUTPUTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
|
||||
)
|
||||
|
||||
set(BINDING_DEPENDENCIES
|
||||
tolua
|
||||
../Bindings/virtual_method_hooks.lua
|
||||
../Bindings/AllToLua.pkg
|
||||
../Bindings/gen_LuaState_Call.lua
|
||||
../Bindings/LuaFunctions.h
|
||||
../Bindings/LuaWindow.h
|
||||
../Bindings/Plugin.h
|
||||
../Bindings/PluginLua.h
|
||||
../Bindings/PluginManager.h
|
||||
../Bindings/WebPlugin.h
|
||||
../BiomeDef.h
|
||||
../BlockArea.h
|
||||
tolua
|
||||
../Bindings/virtual_method_hooks.lua
|
||||
../Bindings/AllToLua.pkg
|
||||
../Bindings/LuaFunctions.h
|
||||
../Bindings/LuaWindow.h
|
||||
../Bindings/Plugin.h
|
||||
../Bindings/PluginLua.h
|
||||
../Bindings/PluginManager.h
|
||||
../Bindings/WebPlugin.h
|
||||
../BiomeDef.h
|
||||
../BlockArea.h
|
||||
../BlockEntities/BeaconEntity.h
|
||||
../BlockEntities/BlockEntity.h
|
||||
../BlockEntities/BlockEntityWithItems.h
|
||||
../BlockEntities/ChestEntity.h
|
||||
../BlockEntities/DispenserEntity.h
|
||||
../BlockEntities/DropSpenserEntity.h
|
||||
../BlockEntities/DropperEntity.h
|
||||
../BlockEntities/FurnaceEntity.h
|
||||
../BlockEntities/HopperEntity.h
|
||||
../BlockEntities/JukeboxEntity.h
|
||||
../BlockEntities/NoteEntity.h
|
||||
../BlockEntities/SignEntity.h
|
||||
../BlockEntities/MobHeadEntity.h
|
||||
../BlockEntities/FlowerPotEntity.h
|
||||
../BlockID.h
|
||||
../BoundingBox.h
|
||||
../ChatColor.h
|
||||
../ChunkDef.h
|
||||
../ClientHandle.h
|
||||
../CraftingRecipes.h
|
||||
../Cuboid.h
|
||||
../Defines.h
|
||||
../Enchantments.h
|
||||
../Entities/EntityEffect.h
|
||||
../Entities/Entity.h
|
||||
../Entities/Floater.h
|
||||
../Entities/Pawn.h
|
||||
../Entities/Painting.h
|
||||
../Entities/Pickup.h
|
||||
../Entities/Player.h
|
||||
../Entities/ProjectileEntity.h
|
||||
../Entities/ArrowEntity.h
|
||||
../Entities/ThrownEggEntity.h
|
||||
../Entities/ThrownEnderPearlEntity.h
|
||||
../Entities/ExpBottleEntity.h
|
||||
../Entities/ThrownSnowballEntity.h
|
||||
../Entities/FireChargeEntity.h
|
||||
../Entities/FireworkEntity.h
|
||||
../Entities/GhastFireballEntity.h
|
||||
../Entities/TNTEntity.h
|
||||
../Entities/ExpOrb.h
|
||||
../Entities/HangingEntity.h
|
||||
../Entities/ItemFrame.h
|
||||
../Generating/ChunkDesc.h
|
||||
../Inventory.h
|
||||
../Item.h
|
||||
../ItemGrid.h
|
||||
../Mobs/Monster.h
|
||||
../OSSupport/File.h
|
||||
../Root.h
|
||||
../Server.h
|
||||
../StringUtils.h
|
||||
../Tracer.h
|
||||
../UI/Window.h
|
||||
../Vector3.h
|
||||
../WebAdmin.h
|
||||
../World.h
|
||||
../BlockEntities/BlockEntity.h
|
||||
../BlockEntities/BlockEntityWithItems.h
|
||||
../BlockEntities/ChestEntity.h
|
||||
../BlockEntities/DispenserEntity.h
|
||||
../BlockEntities/DropSpenserEntity.h
|
||||
../BlockEntities/DropperEntity.h
|
||||
../BlockEntities/FurnaceEntity.h
|
||||
../BlockEntities/HopperEntity.h
|
||||
../BlockEntities/JukeboxEntity.h
|
||||
../BlockEntities/NoteEntity.h
|
||||
../BlockEntities/SignEntity.h
|
||||
../BlockEntities/MobHeadEntity.h
|
||||
../BlockEntities/FlowerPotEntity.h
|
||||
../BlockID.h
|
||||
../BoundingBox.h
|
||||
../ChatColor.h
|
||||
../ChunkDef.h
|
||||
../ClientHandle.h
|
||||
../CraftingRecipes.h
|
||||
../Cuboid.h
|
||||
../Defines.h
|
||||
../Enchantments.h
|
||||
../Entities/ArrowEntity.h
|
||||
../Entities/Entity.h
|
||||
../Entities/EntityEffect.h
|
||||
../Entities/ExpBottleEntity.h
|
||||
../Entities/FireChargeEntity.h
|
||||
../Entities/FireworkEntity.h
|
||||
../Entities/Floater.h
|
||||
../Entities/GhastFireballEntity.h
|
||||
../Entities/HangingEntity.h
|
||||
../Entities/ItemFrame.h
|
||||
../Entities/Pawn.h
|
||||
../Entities/Player.h
|
||||
../Entities/Painting.h
|
||||
../Entities/Pickup.h
|
||||
../Entities/ProjectileEntity.h
|
||||
../Entities/SplashPotionEntity.h
|
||||
../Entities/ThrownEggEntity.h
|
||||
../Entities/ThrownEnderPearlEntity.h
|
||||
../Entities/ThrownSnowballEntity.h
|
||||
../Entities/TNTEntity.h
|
||||
../Entities/WitherSkullEntity.h
|
||||
../Generating/ChunkDesc.h
|
||||
../Inventory.h
|
||||
../Item.h
|
||||
../ItemGrid.h
|
||||
../Mobs/Monster.h
|
||||
../OSSupport/File.h
|
||||
../Root.h
|
||||
../Server.h
|
||||
../StringUtils.h
|
||||
../Tracer.h
|
||||
../UI/Window.h
|
||||
../Vector3.h
|
||||
../WebAdmin.h
|
||||
../World.h
|
||||
)
|
||||
|
||||
if (NOT MSVC)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
# add any new generated bindings here
|
||||
OUTPUT ${BINDING_OUTPUTS}
|
||||
ADD_CUSTOM_COMMAND(
|
||||
# add any new generated bindings here
|
||||
OUTPUT ${BINDING_OUTPUTS}
|
||||
|
||||
# Regenerate bindings:
|
||||
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
# Regenerate bindings:
|
||||
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
||||
# add any new generation dependencies here
|
||||
DEPENDS ${BINDING_DEPENDENCIES}
|
||||
)
|
||||
# add any new generation dependencies here
|
||||
DEPENDS ${BINDING_DEPENDENCIES}
|
||||
)
|
||||
endif ()
|
||||
|
||||
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/LuaState_Call.inc PROPERTIES GENERATED TRUE)
|
||||
|
||||
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
|
||||
|
||||
if(NOT MSVC)
|
||||
add_library(Bindings ${SRCS} ${HDRS})
|
||||
add_library(Bindings ${SRCS} ${HDRS})
|
||||
|
||||
target_link_libraries(Bindings lua sqlite tolualib polarssl)
|
||||
target_link_libraries(Bindings lua sqlite tolualib polarssl)
|
||||
endif()
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
|
||||
#include "../BlockInfo.h"
|
||||
#include "../World.h"
|
||||
#include "../Entities/Player.h"
|
||||
#include "LuaState.h"
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +32,7 @@ static int tolua_get_AllToLua_g_BlockLightValue(lua_State* tolua_S)
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
tolua_error(tolua_S, "array indexing out of range.", nullptr);
|
||||
}
|
||||
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetLightValue((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
@@ -55,7 +58,7 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
tolua_error(tolua_S, "array indexing out of range.", nullptr);
|
||||
}
|
||||
tolua_pushnumber(tolua_S, (lua_Number)cBlockInfo::GetSpreadLightFalloff((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
@@ -81,7 +84,7 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
tolua_error(tolua_S, "array indexing out of range.", nullptr);
|
||||
}
|
||||
tolua_pushboolean(tolua_S, cBlockInfo::IsTransparent((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
@@ -107,7 +110,7 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
tolua_error(tolua_S, "array indexing out of range.", nullptr);
|
||||
}
|
||||
tolua_pushboolean(tolua_S, cBlockInfo::IsOneHitDig((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
@@ -133,7 +136,7 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
tolua_error(tolua_S, "array indexing out of range.", nullptr);
|
||||
}
|
||||
tolua_pushboolean(tolua_S, cBlockInfo::IsPistonBreakable((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
@@ -159,7 +162,7 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
tolua_error(tolua_S, "array indexing out of range.", nullptr);
|
||||
}
|
||||
tolua_pushboolean(tolua_S, cBlockInfo::IsSnowable((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
@@ -185,7 +188,7 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
tolua_error(tolua_S, "array indexing out of range.", nullptr);
|
||||
}
|
||||
tolua_pushboolean(tolua_S, (bool)cBlockInfo::IsSolid((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
@@ -211,7 +214,7 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
{
|
||||
tolua_error(tolua_S, "array indexing out of range.", NULL);
|
||||
tolua_error(tolua_S, "array indexing out of range.", nullptr);
|
||||
}
|
||||
tolua_pushboolean(tolua_S, (bool)cBlockInfo::FullyOccupiesVoxel((BLOCKTYPE)BlockType));
|
||||
return 1;
|
||||
@@ -222,18 +225,80 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
|
||||
|
||||
|
||||
|
||||
/** function: cWorld:SetSignLines */
|
||||
static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
|
||||
{
|
||||
cLuaState LuaState(tolua_S);
|
||||
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype (LuaState, 1, "cWorld", 0, &tolua_err) ||
|
||||
!tolua_isnumber (LuaState, 2, 0, &tolua_err) ||
|
||||
!tolua_isnumber (LuaState, 3, 0, &tolua_err) ||
|
||||
!tolua_isnumber (LuaState, 4, 0, &tolua_err) ||
|
||||
!tolua_iscppstring(LuaState, 5, 0, &tolua_err) ||
|
||||
!tolua_iscppstring(LuaState, 6, 0, &tolua_err) ||
|
||||
!tolua_iscppstring(LuaState, 7, 0, &tolua_err) ||
|
||||
!tolua_iscppstring(LuaState, 8, 0, &tolua_err) ||
|
||||
!tolua_isusertype (LuaState, 9, "cPlayer", 1, &tolua_err) ||
|
||||
!tolua_isnoobj (LuaState, 10, &tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cWorld * self = (cWorld *) tolua_tousertype (LuaState, 1, nullptr);
|
||||
int BlockX = (int) tolua_tonumber (LuaState, 2, 0);
|
||||
int BlockY = (int) tolua_tonumber (LuaState, 3, 0);
|
||||
int BlockZ = (int) tolua_tonumber (LuaState, 4, 0);
|
||||
const AString Line1 = tolua_tocppstring(LuaState, 5, 0);
|
||||
const AString Line2 = tolua_tocppstring(LuaState, 6, 0);
|
||||
const AString Line3 = tolua_tocppstring(LuaState, 7, 0);
|
||||
const AString Line4 = tolua_tocppstring(LuaState, 8, 0);
|
||||
cPlayer * Player = (cPlayer *)tolua_tousertype (LuaState, 9, nullptr);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(LuaState, "invalid 'self' in function 'UpdateSign'", nullptr);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
bool res = self->SetSignLines(BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player);
|
||||
tolua_pushboolean(LuaState, res ? 1 : 0);
|
||||
}
|
||||
}
|
||||
LOGWARNING("Warning in function call 'UpdateSign': UpdateSign() is deprecated. Please use SetSignLines()");
|
||||
LuaState.LogStackTrace(0);
|
||||
return 1;
|
||||
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(LuaState, "#ferror in function 'UpdateSign'.", &tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DeprecatedBindings::Bind(lua_State * tolua_S)
|
||||
{
|
||||
tolua_beginmodule(tolua_S, NULL);
|
||||
tolua_beginmodule(tolua_S, nullptr);
|
||||
|
||||
tolua_array(tolua_S, "g_BlockLightValue", tolua_get_AllToLua_g_BlockLightValue, NULL);
|
||||
tolua_array(tolua_S, "g_BlockSpreadLightFalloff", tolua_get_AllToLua_g_BlockSpreadLightFalloff, NULL);
|
||||
tolua_array(tolua_S, "g_BlockTransparent", tolua_get_AllToLua_g_BlockTransparent, NULL);
|
||||
tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, NULL);
|
||||
tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, NULL);
|
||||
tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, NULL);
|
||||
tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, NULL);
|
||||
tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, NULL);
|
||||
tolua_array(tolua_S, "g_BlockLightValue", tolua_get_AllToLua_g_BlockLightValue, nullptr);
|
||||
tolua_array(tolua_S, "g_BlockSpreadLightFalloff", tolua_get_AllToLua_g_BlockSpreadLightFalloff, nullptr);
|
||||
tolua_array(tolua_S, "g_BlockTransparent", tolua_get_AllToLua_g_BlockTransparent, nullptr);
|
||||
tolua_array(tolua_S, "g_BlockOneHitDig", tolua_get_AllToLua_g_BlockOneHitDig, nullptr);
|
||||
tolua_array(tolua_S, "g_BlockPistonBreakable", tolua_get_AllToLua_g_BlockPistonBreakable, nullptr);
|
||||
tolua_array(tolua_S, "g_BlockIsSnowable", tolua_get_AllToLua_g_BlockIsSnowable, nullptr);
|
||||
tolua_array(tolua_S, "g_BlockIsSolid", tolua_get_AllToLua_g_BlockIsSolid, nullptr);
|
||||
tolua_array(tolua_S, "g_BlockFullyOccupiesVoxel", tolua_get_AllToLua_g_BlockFullyOccupiesVoxel, nullptr);
|
||||
|
||||
tolua_beginmodule(tolua_S, "cWorld");
|
||||
tolua_function(tolua_S, "UpdateSign", tolua_cWorld_SetSignLines);
|
||||
tolua_endmodule(tolua_S);
|
||||
|
||||
tolua_endmodule(tolua_S);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
cLuaChunkStay::cLuaChunkStay(cPluginLua & a_Plugin) :
|
||||
m_Plugin(a_Plugin),
|
||||
m_LuaState(NULL)
|
||||
m_LuaState(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -130,8 +130,11 @@ void cLuaChunkStay::Enable(cChunkMap & a_ChunkMap, int a_OnChunkAvailableStackPo
|
||||
|
||||
void cLuaChunkStay::OnChunkAvailable(int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
cPluginLua::cOperation Op(m_Plugin);
|
||||
Op().Call((int)m_OnChunkAvailable, a_ChunkX, a_ChunkZ);
|
||||
if (m_OnChunkAvailable.IsValid())
|
||||
{
|
||||
cPluginLua::cOperation Op(m_Plugin);
|
||||
Op().Call((int)m_OnChunkAvailable, a_ChunkX, a_ChunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +143,7 @@ void cLuaChunkStay::OnChunkAvailable(int a_ChunkX, int a_ChunkZ)
|
||||
|
||||
bool cLuaChunkStay::OnAllChunksAvailable(void)
|
||||
{
|
||||
if (m_OnAllChunksAvailable.IsValid())
|
||||
{
|
||||
// Call the callback:
|
||||
cPluginLua::cOperation Op(m_Plugin);
|
||||
|
||||
@@ -16,6 +16,8 @@ extern "C"
|
||||
#include "Bindings.h"
|
||||
#include "ManualBindings.h"
|
||||
#include "DeprecatedBindings.h"
|
||||
#include "../Entities/Entity.h"
|
||||
#include "../BlockEntities/BlockEntity.h"
|
||||
|
||||
// fwd: SQLite/lsqlite3.c
|
||||
extern "C"
|
||||
@@ -44,7 +46,7 @@ const cLuaState::cRet cLuaState::Return = {};
|
||||
// cLuaState:
|
||||
|
||||
cLuaState::cLuaState(const AString & a_SubsystemName) :
|
||||
m_LuaState(NULL),
|
||||
m_LuaState(nullptr),
|
||||
m_IsOwned(false),
|
||||
m_SubsystemName(a_SubsystemName),
|
||||
m_NumCurrentFunctionArgs(-1)
|
||||
@@ -88,7 +90,7 @@ cLuaState::~cLuaState()
|
||||
|
||||
void cLuaState::Create(void)
|
||||
{
|
||||
if (m_LuaState != NULL)
|
||||
if (m_LuaState != nullptr)
|
||||
{
|
||||
LOGWARNING("%s: Trying to create an already-existing LuaState, ignoring.", __FUNCTION__);
|
||||
return;
|
||||
@@ -117,7 +119,7 @@ void cLuaState::RegisterAPILibs(void)
|
||||
|
||||
void cLuaState::Close(void)
|
||||
{
|
||||
if (m_LuaState == NULL)
|
||||
if (m_LuaState == nullptr)
|
||||
{
|
||||
LOGWARNING("%s: Trying to close an invalid LuaState, ignoring.", __FUNCTION__);
|
||||
return;
|
||||
@@ -132,7 +134,7 @@ void cLuaState::Close(void)
|
||||
return;
|
||||
}
|
||||
lua_close(m_LuaState);
|
||||
m_LuaState = NULL;
|
||||
m_LuaState = nullptr;
|
||||
m_IsOwned = false;
|
||||
}
|
||||
|
||||
@@ -142,7 +144,7 @@ void cLuaState::Close(void)
|
||||
|
||||
void cLuaState::Attach(lua_State * a_State)
|
||||
{
|
||||
if (m_LuaState != NULL)
|
||||
if (m_LuaState != nullptr)
|
||||
{
|
||||
LOGINFO("%s: Already contains a LuaState (0x%p), will be closed / detached.", __FUNCTION__, m_LuaState);
|
||||
if (m_IsOwned)
|
||||
@@ -164,7 +166,7 @@ void cLuaState::Attach(lua_State * a_State)
|
||||
|
||||
void cLuaState::Detach(void)
|
||||
{
|
||||
if (m_LuaState == NULL)
|
||||
if (m_LuaState == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -177,7 +179,7 @@ void cLuaState::Detach(void)
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
m_LuaState = NULL;
|
||||
m_LuaState = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -520,7 +522,7 @@ void cLuaState::Push(cBlockEntity * a_BlockEntity)
|
||||
{
|
||||
ASSERT(IsValid());
|
||||
|
||||
tolua_pushusertype(m_LuaState, a_BlockEntity, "cBlockEntity");
|
||||
tolua_pushusertype(m_LuaState, a_BlockEntity, (a_BlockEntity == nullptr) ? "cBlockEntity" : a_BlockEntity->GetClass());
|
||||
m_NumCurrentFunctionArgs += 1;
|
||||
}
|
||||
|
||||
@@ -556,7 +558,61 @@ void cLuaState::Push(cEntity * a_Entity)
|
||||
{
|
||||
ASSERT(IsValid());
|
||||
|
||||
tolua_pushusertype(m_LuaState, a_Entity, "cEntity");
|
||||
if (a_Entity == nullptr)
|
||||
{
|
||||
lua_pushnil(m_LuaState);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (a_Entity->GetEntityType())
|
||||
{
|
||||
case cEntity::etMonster:
|
||||
{
|
||||
// Don't push specific mob types, as those are not exported in the API:
|
||||
tolua_pushusertype(m_LuaState, a_Entity, "cMonster");
|
||||
break;
|
||||
}
|
||||
case cEntity::etPlayer:
|
||||
{
|
||||
tolua_pushusertype(m_LuaState, a_Entity, "cPlayer");
|
||||
break;
|
||||
}
|
||||
case cEntity::etPickup:
|
||||
{
|
||||
tolua_pushusertype(m_LuaState, a_Entity, "cPickup");
|
||||
break;
|
||||
}
|
||||
case cEntity::etTNT:
|
||||
{
|
||||
tolua_pushusertype(m_LuaState, a_Entity, "cTNTEntity");
|
||||
break;
|
||||
}
|
||||
case cEntity::etProjectile:
|
||||
{
|
||||
tolua_pushusertype(m_LuaState, a_Entity, a_Entity->GetClass());
|
||||
break;
|
||||
}
|
||||
case cEntity::etFloater:
|
||||
{
|
||||
tolua_pushusertype(m_LuaState, a_Entity, "cFloater");
|
||||
break;
|
||||
}
|
||||
|
||||
case cEntity::etEntity:
|
||||
case cEntity::etEnderCrystal:
|
||||
case cEntity::etFallingBlock:
|
||||
case cEntity::etMinecart:
|
||||
case cEntity::etBoat:
|
||||
case cEntity::etExpOrb:
|
||||
case cEntity::etItemFrame:
|
||||
case cEntity::etPainting:
|
||||
{
|
||||
// Push the generic entity class type:
|
||||
tolua_pushusertype(m_LuaState, a_Entity, "cEntity");
|
||||
}
|
||||
} // switch (EntityType)
|
||||
}
|
||||
|
||||
m_NumCurrentFunctionArgs += 1;
|
||||
}
|
||||
|
||||
@@ -813,7 +869,7 @@ void cLuaState::GetStackValue(int a_StackPos, AString & a_Value)
|
||||
{
|
||||
size_t len = 0;
|
||||
const char * data = lua_tolstring(m_LuaState, a_StackPos, &len);
|
||||
if (data != NULL)
|
||||
if (data != nullptr)
|
||||
{
|
||||
a_Value.assign(data, len);
|
||||
}
|
||||
@@ -861,6 +917,11 @@ void cLuaState::GetStackValue(int a_StackPos, eWeather & a_ReturnedVal)
|
||||
|
||||
void cLuaState::GetStackValue(int a_StackPos, pBoundingBox & a_ReturnedVal)
|
||||
{
|
||||
if (lua_isnil(m_LuaState, a_StackPos))
|
||||
{
|
||||
a_ReturnedVal = nullptr;
|
||||
return;
|
||||
}
|
||||
tolua_Error err;
|
||||
if (tolua_isusertype(m_LuaState, a_StackPos, "cBoundingBox", false, &err))
|
||||
{
|
||||
@@ -874,6 +935,11 @@ void cLuaState::GetStackValue(int a_StackPos, pBoundingBox & a_ReturnedVal)
|
||||
|
||||
void cLuaState::GetStackValue(int a_StackPos, pWorld & a_ReturnedVal)
|
||||
{
|
||||
if (lua_isnil(m_LuaState, a_StackPos))
|
||||
{
|
||||
a_ReturnedVal = nullptr;
|
||||
return;
|
||||
}
|
||||
tolua_Error err;
|
||||
if (tolua_isusertype(m_LuaState, a_StackPos, "cWorld", false, &err))
|
||||
{
|
||||
@@ -936,7 +1002,7 @@ bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable,
|
||||
lua_Debug entry;
|
||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
|
||||
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
||||
return false;
|
||||
} // for i - Param
|
||||
@@ -969,7 +1035,7 @@ bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, in
|
||||
lua_Debug entry;
|
||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
|
||||
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
||||
return false;
|
||||
} // for i - Param
|
||||
@@ -1002,7 +1068,7 @@ bool cLuaState::CheckParamTable(int a_StartParam, int a_EndParam)
|
||||
lua_Debug entry;
|
||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
|
||||
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
||||
return false;
|
||||
} // for i - Param
|
||||
@@ -1035,7 +1101,7 @@ bool cLuaState::CheckParamNumber(int a_StartParam, int a_EndParam)
|
||||
lua_Debug entry;
|
||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
|
||||
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
||||
return false;
|
||||
} // for i - Param
|
||||
@@ -1068,7 +1134,7 @@ bool cLuaState::CheckParamString(int a_StartParam, int a_EndParam)
|
||||
lua_Debug entry;
|
||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
|
||||
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != nullptr) ? entry.name : "?");
|
||||
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
||||
return false;
|
||||
} // for i - Param
|
||||
@@ -1101,7 +1167,7 @@ bool cLuaState::CheckParamFunction(int a_StartParam, int a_EndParam)
|
||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||
luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s",
|
||||
(entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str()
|
||||
(entry.name != nullptr) ? entry.name : "?", i, GetTypeText(i).c_str()
|
||||
);
|
||||
return false;
|
||||
} // for i - Param
|
||||
@@ -1134,7 +1200,7 @@ bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam)
|
||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||
luaL_error(m_LuaState, "Error in function '%s' parameter #%d. Function expected, got %s",
|
||||
(entry.name != NULL) ? entry.name : "?", i, GetTypeText(i).c_str()
|
||||
(entry.name != nullptr) ? entry.name : "?", i, GetTypeText(i).c_str()
|
||||
);
|
||||
return false;
|
||||
} // for i - Param
|
||||
@@ -1158,7 +1224,7 @@ bool cLuaState::CheckParamEnd(int a_Param)
|
||||
lua_Debug entry;
|
||||
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||
AString ErrMsg = Printf("#ferror in function '%s': Too many arguments.", (entry.name != NULL) ? entry.name : "?");
|
||||
AString ErrMsg = Printf("#ferror in function '%s': Too many arguments.", (entry.name != nullptr) ? entry.name : "?");
|
||||
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
||||
return false;
|
||||
}
|
||||
@@ -1337,7 +1403,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
|
||||
case LUA_TUSERDATA:
|
||||
{
|
||||
// Get the class name:
|
||||
const char * type = NULL;
|
||||
const char * type = nullptr;
|
||||
if (lua_getmetatable(a_SrcLuaState, i) == 0)
|
||||
{
|
||||
LOGWARNING("%s: Unknown class in pos %d, cannot copy.", __FUNCTION__, i);
|
||||
@@ -1349,7 +1415,7 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
|
||||
lua_pop(a_SrcLuaState, 1); // Stack -1
|
||||
|
||||
// Copy the value:
|
||||
void * ud = tolua_touserdata(a_SrcLuaState, i, NULL);
|
||||
void * ud = tolua_touserdata(a_SrcLuaState, i, nullptr);
|
||||
tolua_pushusertype(m_LuaState, ud, type);
|
||||
break;
|
||||
}
|
||||
@@ -1375,7 +1441,7 @@ void cLuaState::ToString(int a_StackPos, AString & a_String)
|
||||
{
|
||||
size_t len;
|
||||
const char * s = lua_tolstring(m_LuaState, a_StackPos, &len);
|
||||
if (s != NULL)
|
||||
if (s != nullptr)
|
||||
{
|
||||
a_String.assign(s, len);
|
||||
}
|
||||
@@ -1396,10 +1462,8 @@ void cLuaState::LogStack(const char * a_Header)
|
||||
|
||||
void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
|
||||
{
|
||||
UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns
|
||||
|
||||
// Format string consisting only of %s is used to appease the compiler
|
||||
LOGD("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
|
||||
LOG("%s", (a_Header != nullptr) ? a_Header : "Lua C API Stack contents:");
|
||||
for (int i = lua_gettop(a_LuaState); i > 0; i--)
|
||||
{
|
||||
AString Value;
|
||||
@@ -1436,7 +1500,7 @@ int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
|
||||
// cLuaState::cRef:
|
||||
|
||||
cLuaState::cRef::cRef(void) :
|
||||
m_LuaState(NULL),
|
||||
m_LuaState(nullptr),
|
||||
m_Ref(LUA_REFNIL)
|
||||
{
|
||||
}
|
||||
@@ -1446,7 +1510,7 @@ cLuaState::cRef::cRef(void) :
|
||||
|
||||
|
||||
cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) :
|
||||
m_LuaState(NULL),
|
||||
m_LuaState(nullptr),
|
||||
m_Ref(LUA_REFNIL)
|
||||
{
|
||||
RefStack(a_LuaState, a_StackPos);
|
||||
@@ -1458,7 +1522,7 @@ cLuaState::cRef::cRef(cLuaState & a_LuaState, int a_StackPos) :
|
||||
|
||||
cLuaState::cRef::~cRef()
|
||||
{
|
||||
if (m_LuaState != NULL)
|
||||
if (m_LuaState != nullptr)
|
||||
{
|
||||
UnRef();
|
||||
}
|
||||
@@ -1471,7 +1535,7 @@ cLuaState::cRef::~cRef()
|
||||
void cLuaState::cRef::RefStack(cLuaState & a_LuaState, int a_StackPos)
|
||||
{
|
||||
ASSERT(a_LuaState.IsValid());
|
||||
if (m_LuaState != NULL)
|
||||
if (m_LuaState != nullptr)
|
||||
{
|
||||
UnRef();
|
||||
}
|
||||
@@ -1492,7 +1556,7 @@ void cLuaState::cRef::UnRef(void)
|
||||
{
|
||||
luaL_unref(*m_LuaState, LUA_REGISTRYINDEX, m_Ref);
|
||||
}
|
||||
m_LuaState = NULL;
|
||||
m_LuaState = nullptr;
|
||||
m_Ref = LUA_REFNIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
void Detach(void);
|
||||
|
||||
/** Returns true if the m_LuaState is valid */
|
||||
bool IsValid(void) const { return (m_LuaState != NULL); }
|
||||
bool IsValid(void) const { return (m_LuaState != nullptr); }
|
||||
|
||||
/** Adds the specified path to package.<a_PathVariable> */
|
||||
void AddPackagePath(const AString & a_PathVariable, const AString & a_Path);
|
||||
@@ -240,10 +240,28 @@ public:
|
||||
/** Retrieve value at a_StackPos, if it is a valid cWorld class. If not, a_Value is unchanged */
|
||||
void GetStackValue(int a_StackPos, pWorld & a_Value);
|
||||
|
||||
/** Call the specified Lua function.
|
||||
Returns true if call succeeded, false if there was an error.
|
||||
A special param of cRet & signifies the end of param list and the start of return values.
|
||||
Example call: Call(Fn, Param1, Param2, Param3, cLuaState::Return, Ret1, Ret2) */
|
||||
template <typename FnT, typename... Args>
|
||||
bool Call(const FnT & a_Function, Args &&... args)
|
||||
{
|
||||
if (!PushFunction(a_Function))
|
||||
{
|
||||
// Pushing the function failed
|
||||
return false;
|
||||
}
|
||||
return PushCallPop(args...);
|
||||
}
|
||||
|
||||
// Include the cLuaState::Call() overload implementation that is generated by the gen_LuaState_Call.lua script:
|
||||
#include "LuaState_Call.inc"
|
||||
|
||||
/** Retrieves a list of values from the Lua stack, starting at the specified index. */
|
||||
template <typename T, typename... Args>
|
||||
inline void GetStackValues(int a_StartStackPos, T & a_Ret, Args &&... args)
|
||||
{
|
||||
GetStackValue(a_StartStackPos, a_Ret);
|
||||
GetStackValues(a_StartStackPos + 1, args...);
|
||||
}
|
||||
|
||||
/** Returns true if the specified parameters on the stack are of the specified usertable type; also logs warning if not. Used for static functions */
|
||||
bool CheckParamUserTable(int a_StartParam, const char * a_UserTable, int a_EndParam = -1);
|
||||
@@ -304,12 +322,13 @@ public:
|
||||
void ToString(int a_StackPos, AString & a_String);
|
||||
|
||||
/** Logs all the elements' types on the API stack, with an optional header for the listing. */
|
||||
void LogStack(const char * a_Header);
|
||||
void LogStack(const char * a_Header = nullptr);
|
||||
|
||||
/** Logs all the elements' types on the API stack, with an optional header for the listing. */
|
||||
static void LogStack(lua_State * a_LuaState, const char * a_Header = NULL);
|
||||
static void LogStack(lua_State * a_LuaState, const char * a_Header = nullptr);
|
||||
|
||||
protected:
|
||||
|
||||
lua_State * m_LuaState;
|
||||
|
||||
/** If true, the state is owned by this object and will be auto-Closed. False => attached state */
|
||||
@@ -327,6 +346,63 @@ protected:
|
||||
int m_NumCurrentFunctionArgs;
|
||||
|
||||
|
||||
/** Variadic template terminator: Counting zero args returns zero. */
|
||||
int CountArgs(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Variadic template: Counting args means add one to the count of the rest. */
|
||||
template <typename T, typename... Args>
|
||||
int CountArgs(T, Args... args)
|
||||
{
|
||||
return 1 + CountArgs(args...);
|
||||
}
|
||||
|
||||
/** Variadic template terminator: If there's nothing more to push / pop, just call the function.
|
||||
Note that there are no return values either, because those are prefixed by a cRet value, so the arg list is never empty. */
|
||||
bool PushCallPop(void)
|
||||
{
|
||||
return CallFunction(0);
|
||||
}
|
||||
|
||||
/** Variadic template recursor: More params to push. Push them and recurse. */
|
||||
template <typename T, typename... Args>
|
||||
inline bool PushCallPop(T a_Param, Args &&... args)
|
||||
{
|
||||
Push(a_Param);
|
||||
return PushCallPop(args...);
|
||||
}
|
||||
|
||||
/** Variadic template terminator: If there's nothing more to push, but return values to collect, call the function and collect the returns. */
|
||||
template <typename... Args>
|
||||
bool PushCallPop(cLuaState::cRet, Args &&... args)
|
||||
{
|
||||
// Calculate the number of return values (number of args left):
|
||||
int NumReturns = CountArgs(args...);
|
||||
|
||||
// Call the function:
|
||||
if (!CallFunction(NumReturns))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Collect the return values:
|
||||
GetStackValues(-NumReturns, args...);
|
||||
lua_pop(m_LuaState, NumReturns);
|
||||
|
||||
// All successful:
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Variadic template terminator: If there are no more values to get, bail out.
|
||||
This function is not available in the public API, because it's an error to request no values directly; only internal functions can do that.
|
||||
If you get a compile error saying this function is not accessible, check your calling code, you aren't reading any stack values. */
|
||||
void GetStackValues(int a_StartingStackPos)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/** Pushes the function of the specified name onto the stack.
|
||||
Returns true if successful. Logs a warning on failure (incl. m_SubsystemName)
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
cLuaWindow::cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title) :
|
||||
super(a_WindowType, a_Title),
|
||||
m_Contents(a_SlotsX, a_SlotsY),
|
||||
m_Plugin(NULL),
|
||||
m_Plugin(nullptr),
|
||||
m_LuaRef(LUA_REFNIL),
|
||||
m_OnClosingFnRef(LUA_REFNIL),
|
||||
m_OnSlotChangedFnRef(LUA_REFNIL)
|
||||
@@ -70,7 +70,7 @@ cLuaWindow::~cLuaWindow()
|
||||
void cLuaWindow::SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef)
|
||||
{
|
||||
// Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
|
||||
ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
|
||||
ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
|
||||
ASSERT(m_LuaRef == LUA_REFNIL);
|
||||
m_Plugin = a_Plugin;
|
||||
m_LuaRef = a_LuaRef;
|
||||
@@ -82,7 +82,7 @@ void cLuaWindow::SetLuaRef(cPluginLua * a_Plugin, int a_LuaRef)
|
||||
|
||||
bool cLuaWindow::IsLuaReferenced(void) const
|
||||
{
|
||||
return ((m_Plugin != NULL) && (m_LuaRef != LUA_REFNIL));
|
||||
return ((m_Plugin != nullptr) && (m_LuaRef != LUA_REFNIL));
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ bool cLuaWindow::IsLuaReferenced(void) const
|
||||
void cLuaWindow::SetOnClosing(cPluginLua * a_Plugin, int a_FnRef)
|
||||
{
|
||||
// Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
|
||||
ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
|
||||
ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
|
||||
|
||||
// If there already was a function, unreference it first
|
||||
if (m_OnClosingFnRef != LUA_REFNIL)
|
||||
@@ -112,7 +112,7 @@ void cLuaWindow::SetOnClosing(cPluginLua * a_Plugin, int a_FnRef)
|
||||
void cLuaWindow::SetOnSlotChanged(cPluginLua * a_Plugin, int a_FnRef)
|
||||
{
|
||||
// Either m_Plugin is not set or equal to the passed plugin; only one plugin can use one cLuaWindow object
|
||||
ASSERT((m_Plugin == NULL) || (m_Plugin == a_Plugin));
|
||||
ASSERT((m_Plugin == nullptr) || (m_Plugin == a_Plugin));
|
||||
|
||||
// If there already was a function, unreference it first
|
||||
if (m_OnSlotChangedFnRef != LUA_REFNIL)
|
||||
@@ -134,7 +134,7 @@ bool cLuaWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
|
||||
// First notify the plugin through the registered callback:
|
||||
if (m_OnClosingFnRef != LUA_REFNIL)
|
||||
{
|
||||
ASSERT(m_Plugin != NULL);
|
||||
ASSERT(m_Plugin != nullptr);
|
||||
if (m_Plugin->CallbackWindowClosing(m_OnClosingFnRef, *this, a_Player, a_CanRefuse))
|
||||
{
|
||||
// The callback disagrees (the higher levels check the CanRefuse flag compliance)
|
||||
@@ -153,7 +153,7 @@ void cLuaWindow::Destroy(void)
|
||||
{
|
||||
super::Destroy();
|
||||
|
||||
if ((m_LuaRef != LUA_REFNIL) && (m_Plugin != NULL))
|
||||
if ((m_LuaRef != LUA_REFNIL) && (m_Plugin != nullptr))
|
||||
{
|
||||
// The object is referenced by Lua, un-reference it
|
||||
m_Plugin->Unreference(m_LuaRef);
|
||||
|
||||
@@ -145,13 +145,13 @@ static AString GetLogMessage(lua_State * tolua_S)
|
||||
tolua_Error err;
|
||||
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
|
||||
{
|
||||
return ((cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL))->ExtractText();
|
||||
return ((cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr))->ExtractText();
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t len = 0;
|
||||
const char * str = lua_tolstring(tolua_S, 1, &len);
|
||||
if (str != NULL)
|
||||
if (str != nullptr)
|
||||
{
|
||||
return AString(str, len);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ static int tolua_LOG(lua_State * tolua_S)
|
||||
tolua_Error err;
|
||||
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
|
||||
{
|
||||
LogLevel = cCompositeChat::MessageTypeToLogLevel(((cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL))->GetMessageType());
|
||||
LogLevel = cCompositeChat::MessageTypeToLogLevel(((cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr))->GetMessageType());
|
||||
}
|
||||
|
||||
// Log the message:
|
||||
@@ -264,7 +264,7 @@ static cPluginLua * GetLuaPlugin(lua_State * L)
|
||||
{
|
||||
LOGWARNING("%s: cannot get plugin instance, what have you done to my Lua state?", __FUNCTION__);
|
||||
lua_pop(L, 1);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
cPluginLua * Plugin = (cPluginLua *)lua_topointer(L, -1);
|
||||
lua_pop(L, 1);
|
||||
@@ -312,10 +312,10 @@ static int tolua_DoWith(lua_State* tolua_S)
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 2 or 3 arguments, got %i", NumArgs);
|
||||
}
|
||||
|
||||
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
|
||||
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
|
||||
const char * ItemName = tolua_tocppstring(tolua_S, 2, "");
|
||||
if ((ItemName == NULL) || (ItemName[0] == 0))
|
||||
if ((ItemName == nullptr) || (ItemName[0] == 0))
|
||||
{
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a non-empty string for parameter #1", NumArgs);
|
||||
}
|
||||
@@ -406,7 +406,7 @@ static int tolua_DoWithID(lua_State* tolua_S)
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 2 or 3 arguments, got %i", NumArgs);
|
||||
}
|
||||
|
||||
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
|
||||
int ItemID = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if (!lua_isfunction(tolua_S, 3))
|
||||
@@ -496,7 +496,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 4 or 5 arguments, got %i", NumArgs);
|
||||
}
|
||||
|
||||
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
|
||||
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (!lua_isnumber(tolua_S, 2) || !lua_isnumber(tolua_S, 3) || !lua_isnumber(tolua_S, 4))
|
||||
{
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3");
|
||||
@@ -591,7 +591,7 @@ static int tolua_ForEachInChunk(lua_State * tolua_S)
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 3 or 4 arguments, got %i", NumArgs);
|
||||
}
|
||||
|
||||
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, NULL);
|
||||
Ty1 * self = (Ty1 *) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (!lua_isnumber(tolua_S, 2) || !lua_isnumber(tolua_S, 3))
|
||||
{
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a number for parameters #1 and #2");
|
||||
@@ -694,11 +694,15 @@ static int tolua_ForEachInBox(lua_State * tolua_S)
|
||||
}
|
||||
|
||||
// Get the params:
|
||||
Ty1 * Self = NULL;
|
||||
cBoundingBox * Box = NULL;
|
||||
Ty1 * Self = nullptr;
|
||||
cBoundingBox * Box = nullptr;
|
||||
L.GetStackValues(1, Self, Box);
|
||||
ASSERT(Self != NULL); // We have verified the type at the top, so we should get valid objects here
|
||||
ASSERT(Box != NULL);
|
||||
if ((Self == nullptr) || (Box == nullptr))
|
||||
{
|
||||
LOGWARNING("Invalid world (%p) or boundingbox (%p)", Self, Box);
|
||||
L.LogStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create a reference for the function:
|
||||
cLuaState::cRef FnRef(L, 3);
|
||||
@@ -756,8 +760,8 @@ static int tolua_ForEach(lua_State * tolua_S)
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Requires 1 or 2 arguments, got %i", NumArgs);
|
||||
}
|
||||
|
||||
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
Ty1 * self = (Ty1 *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
|
||||
}
|
||||
@@ -853,14 +857,14 @@ static int tolua_cWorld_GetBlockInfo(lua_State * tolua_S)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
|
||||
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
|
||||
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
|
||||
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (self == NULL)
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'GetBlockInfo'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'GetBlockInfo'", nullptr);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
@@ -908,14 +912,14 @@ static int tolua_cWorld_GetBlockTypeMeta(lua_State * tolua_S)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
|
||||
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
|
||||
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
|
||||
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (self == NULL)
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'GetBlockTypeMeta'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'GetBlockTypeMeta'", nullptr);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
@@ -960,14 +964,14 @@ static int tolua_cWorld_GetSignLines(lua_State * tolua_S)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
|
||||
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
|
||||
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
|
||||
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (self == NULL)
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'GetSignLines'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'GetSignLines'", nullptr);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
@@ -1018,7 +1022,7 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
|
||||
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
|
||||
int BlockY = (int) tolua_tonumber (tolua_S, 3, 0);
|
||||
int BlockZ = (int) tolua_tonumber (tolua_S, 4, 0);
|
||||
@@ -1026,15 +1030,15 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
|
||||
const AString Line2 = tolua_tocppstring(tolua_S, 6, 0);
|
||||
const AString Line3 = tolua_tocppstring(tolua_S, 7, 0);
|
||||
const AString Line4 = tolua_tocppstring(tolua_S, 8, 0);
|
||||
cPlayer * Player = (cPlayer *)tolua_tousertype (tolua_S, 9, NULL);
|
||||
cPlayer * Player = (cPlayer *)tolua_tousertype (tolua_S, 9, nullptr);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (self == NULL)
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'SetSignLines' / 'UpdateSign'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'SetSignLines'", nullptr);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
bool res = self->UpdateSign(BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player);
|
||||
bool res = self->SetSignLines(BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player);
|
||||
tolua_pushboolean(tolua_S, res ? 1 : 0);
|
||||
}
|
||||
}
|
||||
@@ -1042,7 +1046,7 @@ static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
|
||||
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S, "#ferror in function 'SetSignLines' / 'UpdateSign'.", &tolua_err);
|
||||
tolua_error(tolua_S, "#ferror in function 'SetSignLines'.", &tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -1067,13 +1071,13 @@ static int tolua_cWorld_TryGetHeight(lua_State * tolua_S)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, NULL);
|
||||
cWorld * self = (cWorld *) tolua_tousertype (tolua_S, 1, nullptr);
|
||||
int BlockX = (int) tolua_tonumber (tolua_S, 2, 0);
|
||||
int BlockZ = (int) tolua_tonumber (tolua_S, 3, 0);
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (self == NULL)
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "Invalid 'self' in function 'TryGetHeight'", NULL);
|
||||
tolua_error(tolua_S, "Invalid 'self' in function 'TryGetHeight'", nullptr);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
@@ -1132,15 +1136,15 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
|
||||
|
||||
// Retrieve the cPlugin from the LuaState:
|
||||
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
// An error message has been already printed in GetLuaPlugin()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Retrieve the args:
|
||||
cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cWorld * self = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
|
||||
}
|
||||
@@ -1156,7 +1160,7 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Could not get function reference of parameter #1");
|
||||
}
|
||||
|
||||
self->QueueTask(new cLuaWorldTask(*Plugin, FnRef));
|
||||
self->QueueTask(make_unique<cLuaWorldTask>(*Plugin, FnRef));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1196,7 +1200,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
|
||||
|
||||
// Retrieve the cPlugin from the LuaState:
|
||||
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
// An error message has been already printed in GetLuaPlugin()
|
||||
return 0;
|
||||
@@ -1212,8 +1216,8 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (World == NULL)
|
||||
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (World == nullptr)
|
||||
{
|
||||
return lua_do_error(tolua_S, "Error in function call '#funcname#': Not called on an object instance");
|
||||
}
|
||||
@@ -1237,7 +1241,7 @@ static int tolua_cWorld_ScheduleTask(lua_State * tolua_S)
|
||||
|
||||
static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
|
||||
{
|
||||
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
|
||||
const cPluginManager::PluginMap & AllPlugins = self->GetAllPlugins();
|
||||
|
||||
@@ -1248,7 +1252,7 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
|
||||
{
|
||||
const cPlugin* Plugin = iter->second;
|
||||
tolua_pushstring(tolua_S, iter->first.c_str());
|
||||
if (Plugin != NULL)
|
||||
if (Plugin != nullptr)
|
||||
{
|
||||
tolua_pushusertype(tolua_S, (void *)Plugin, "const cPlugin");
|
||||
}
|
||||
@@ -1270,7 +1274,7 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S)
|
||||
static int tolua_cPluginManager_GetCurrentPlugin(lua_State * S)
|
||||
{
|
||||
cPluginLua * Plugin = GetLuaPlugin(S);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
// An error message has already been printed in GetLuaPlugin()
|
||||
return 0;
|
||||
@@ -1301,7 +1305,7 @@ static int tolua_cPluginManager_AddHook_FnRef(cPluginManager * a_PluginManager,
|
||||
|
||||
// Retrieve the cPlugin from the LuaState:
|
||||
cPluginLua * Plugin = GetLuaPlugin(S);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
// An error message has been already printed in GetLuaPlugin()
|
||||
return 0;
|
||||
@@ -1340,8 +1344,8 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
|
||||
// The arg types have already been checked
|
||||
|
||||
// Retrieve and check the cPlugin parameter
|
||||
cPluginLua * Plugin = (cPluginLua *)tolua_tousertype(S, a_ParamIdx, NULL);
|
||||
if (Plugin == NULL)
|
||||
cPluginLua * Plugin = (cPluginLua *)tolua_tousertype(S, a_ParamIdx, nullptr);
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
LOGWARNING("cPluginManager.AddHook(): Invalid Plugin parameter, expected a valid cPlugin object. Hook not added");
|
||||
S.LogStackTrace();
|
||||
@@ -1366,7 +1370,7 @@ static int tolua_cPluginManager_AddHook_DefFn(cPluginManager * a_PluginManager,
|
||||
|
||||
// Get the standard name for the callback function:
|
||||
const char * FnName = cPluginLua::GetHookFnName(HookType);
|
||||
if (FnName == NULL)
|
||||
if (FnName == nullptr)
|
||||
{
|
||||
LOGWARNING("cPluginManager.AddHook(): Unknown hook type (%d). Hook not added.", HookType);
|
||||
S.LogStackTrace();
|
||||
@@ -1413,8 +1417,8 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S)
|
||||
if (tolua_isusertype(S, 1, "cPluginManager", 0, &err))
|
||||
{
|
||||
// Style 2 or 3, retrieve the PlgMgr instance
|
||||
PlgMgr = (cPluginManager *)tolua_tousertype(S, 1, NULL);
|
||||
if (PlgMgr == NULL)
|
||||
PlgMgr = (cPluginManager *)tolua_tousertype(S, 1, nullptr);
|
||||
if (PlgMgr == nullptr)
|
||||
{
|
||||
LOGWARNING("Malformed plugin, use cPluginManager.AddHook(HOOK_TYPE, CallbackFunction). Fixing the call for you.");
|
||||
S.LogStackTrace();
|
||||
@@ -1461,8 +1465,8 @@ static int tolua_cPluginManager_ForEachCommand(lua_State * tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
LOGWARN("Error in function call 'ForEachCommand': Not called on an object instance");
|
||||
return 0;
|
||||
@@ -1538,8 +1542,8 @@ static int tolua_cPluginManager_ForEachConsoleCommand(lua_State * tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cPluginManager * self = (cPluginManager *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
LOGWARN("Error in function call 'ForEachConsoleCommand': Not called on an object instance");
|
||||
return 0;
|
||||
@@ -1613,7 +1617,7 @@ static int tolua_cPluginManager_BindCommand(lua_State * L)
|
||||
cPluginManager.BindCommand(Command, Permission, Function, HelpString) -- without the "self" param
|
||||
*/
|
||||
cPluginLua * Plugin = GetLuaPlugin(L);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1683,7 +1687,7 @@ static int tolua_cPluginManager_BindConsoleCommand(lua_State * L)
|
||||
|
||||
// Get the plugin identification out of LuaState:
|
||||
cPluginLua * Plugin = GetLuaPlugin(L);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1771,7 +1775,7 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S)
|
||||
|
||||
// If requesting calling the current plugin, refuse:
|
||||
cPluginLua * ThisPlugin = GetLuaPlugin(L);
|
||||
if (ThisPlugin == NULL)
|
||||
if (ThisPlugin == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1839,14 +1843,14 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
|
||||
}
|
||||
|
||||
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read the params:
|
||||
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (World == NULL)
|
||||
cWorld * World = (cWorld *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (World == nullptr)
|
||||
{
|
||||
LOGWARNING("World:ChunkStay(): invalid world parameter");
|
||||
L.LogStackTrace();
|
||||
@@ -1858,7 +1862,7 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
|
||||
if (!ChunkStay->AddChunks(2))
|
||||
{
|
||||
delete ChunkStay;
|
||||
ChunkStay = NULL;
|
||||
ChunkStay = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1885,8 +1889,8 @@ static int tolua_cPlayer_GetPermissions(lua_State * tolua_S)
|
||||
}
|
||||
|
||||
// Get the params:
|
||||
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
|
||||
return 0;
|
||||
@@ -1907,15 +1911,15 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S)
|
||||
|
||||
// Retrieve the plugin instance from the Lua state
|
||||
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the parameters:
|
||||
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
cWindow * wnd = (cWindow *)tolua_tousertype(tolua_S, 2, NULL);
|
||||
if ((self == NULL) || (wnd == NULL))
|
||||
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
cWindow * wnd = (cWindow *)tolua_tousertype(tolua_S, 2, nullptr);
|
||||
if ((self == nullptr) || (wnd == nullptr))
|
||||
{
|
||||
LOGWARNING("%s: invalid self (%p) or wnd (%p)", __FUNCTION__, self, wnd);
|
||||
return 0;
|
||||
@@ -1957,26 +1961,20 @@ static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S)
|
||||
// Check the params:
|
||||
cLuaState L(tolua_S);
|
||||
if (
|
||||
!L.CheckParamUserType(1, "cPlayer") ||
|
||||
!L.CheckParamString (2, 3) ||
|
||||
!L.CheckParamEnd (4)
|
||||
!L.CheckParamUserTable(1, "cPlayer") ||
|
||||
!L.CheckParamString (2, 3) ||
|
||||
!L.CheckParamEnd (4)
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the params:
|
||||
cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
{
|
||||
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
|
||||
return 0;
|
||||
}
|
||||
AString Permission, Template;
|
||||
L.GetStackValues(2, Permission, Template);
|
||||
|
||||
// Push the result of the match:
|
||||
L.Push(self->PermissionMatches(StringSplit(Permission, "."), StringSplit(Template, ".")));
|
||||
L.Push(cPlayer::PermissionMatches(StringSplit(Permission, "."), StringSplit(Template, ".")));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1994,15 +1992,15 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
|
||||
|
||||
// Retrieve the plugin instance from the Lua state
|
||||
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
|
||||
if (Plugin == NULL)
|
||||
if (Plugin == nullptr)
|
||||
{
|
||||
// Warning message has already been printed by GetLuaPlugin(), bail out silently
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the parameters - self and the function reference:
|
||||
OBJTYPE * self = (OBJTYPE *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
OBJTYPE * self = (OBJTYPE *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
|
||||
return 0;
|
||||
@@ -2025,7 +2023,7 @@ static int tolua_SetObjectCallback(lua_State * tolua_S)
|
||||
|
||||
static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
|
||||
{
|
||||
cPluginLua * self = (cPluginLua *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
cPluginLua * self = (cPluginLua *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
|
||||
tolua_Error tolua_err;
|
||||
tolua_err.array = 0;
|
||||
@@ -2069,7 +2067,7 @@ static int tolua_cPluginLua_AddWebTab(lua_State * tolua_S)
|
||||
|
||||
static int tolua_cPluginLua_AddTab(lua_State* tolua_S)
|
||||
{
|
||||
cPluginLua * self = (cPluginLua *) tolua_tousertype(tolua_S, 1, NULL);
|
||||
cPluginLua * self = (cPluginLua *) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")",
|
||||
self->GetName().c_str(), self->GetDirectory().c_str()
|
||||
);
|
||||
@@ -2089,7 +2087,7 @@ static int tolua_cPlugin_Call(lua_State * tolua_S)
|
||||
L.LogStackTrace();
|
||||
|
||||
// Retrieve the params: plugin and the function name to call
|
||||
cPluginLua * TargetPlugin = (cPluginLua *) tolua_tousertype(tolua_S, 1, NULL);
|
||||
cPluginLua * TargetPlugin = (cPluginLua *) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
AString FunctionName = tolua_tostring(tolua_S, 2, "");
|
||||
|
||||
// Call the function:
|
||||
@@ -2144,7 +2142,7 @@ static int tolua_push_StringStringMap(lua_State* tolua_S, std::map< std::string,
|
||||
|
||||
static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
|
||||
{
|
||||
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL);
|
||||
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
return tolua_push_StringStringMap(tolua_S, self->Params);
|
||||
}
|
||||
|
||||
@@ -2154,7 +2152,7 @@ static int tolua_get_HTTPRequest_Params(lua_State* tolua_S)
|
||||
|
||||
static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
|
||||
{
|
||||
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL);
|
||||
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
return tolua_push_StringStringMap(tolua_S, self->PostParams);
|
||||
}
|
||||
|
||||
@@ -2164,7 +2162,7 @@ static int tolua_get_HTTPRequest_PostParams(lua_State* tolua_S)
|
||||
|
||||
static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
|
||||
{
|
||||
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, NULL);
|
||||
HTTPRequest* self = (HTTPRequest*) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
std::map< std::string, HTTPFormData >& FormData = self->FormData;
|
||||
|
||||
lua_newtable(tolua_S);
|
||||
@@ -2187,7 +2185,7 @@ static int tolua_get_HTTPRequest_FormData(lua_State* tolua_S)
|
||||
|
||||
static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S)
|
||||
{
|
||||
cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
cWebAdmin * self = (cWebAdmin *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
|
||||
const cWebAdmin::PluginList & AllPlugins = self->GetPlugins();
|
||||
|
||||
@@ -2268,7 +2266,7 @@ static int tolua_AllToLua_cWebAdmin_GetURLEncodedString(lua_State * tolua_S)
|
||||
|
||||
static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
|
||||
{
|
||||
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, NULL);
|
||||
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, nullptr);
|
||||
|
||||
const cWebPlugin::TabNameList & TabNames = self->GetTabNames();
|
||||
|
||||
@@ -2304,8 +2302,8 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, NULL);
|
||||
if (Client == NULL)
|
||||
cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, nullptr);
|
||||
if (Client == nullptr)
|
||||
{
|
||||
LOGWARNING("ClientHandle is nil in cClientHandle:SendPluginMessage()");
|
||||
S.LogStackTrace();
|
||||
@@ -2550,11 +2548,11 @@ static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
|
||||
}
|
||||
|
||||
{
|
||||
const cItemGrid * self = (const cItemGrid *)tolua_tousertype(L, 1, NULL);
|
||||
const cItemGrid * self = (const cItemGrid *)tolua_tousertype(L, 1, nullptr);
|
||||
int SlotNum = (int)tolua_tonumber(L, 2, 0);
|
||||
if (self == NULL)
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(L, "invalid 'self' in function 'cItemGrid:GetSlotCoords'", NULL);
|
||||
tolua_error(L, "invalid 'self' in function 'cItemGrid:GetSlotCoords'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
int X, Y;
|
||||
@@ -2691,7 +2689,7 @@ static int tolua_cLineBlockTracer_Trace(lua_State * tolua_S)
|
||||
}
|
||||
|
||||
// Trace:
|
||||
cWorld * World = (cWorld *)tolua_tousertype(L, idx, NULL);
|
||||
cWorld * World = (cWorld *)tolua_tousertype(L, idx, nullptr);
|
||||
cLuaBlockTracerCallbacks Callbacks(L, idx + 1);
|
||||
double StartX = tolua_tonumber(L, idx + 2, 0);
|
||||
double StartY = tolua_tonumber(L, idx + 3, 0);
|
||||
@@ -2721,8 +2719,8 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
|
||||
}
|
||||
|
||||
// Check the input param:
|
||||
cItem * Input = (cItem *)tolua_tousertype(L, 2, NULL);
|
||||
if (Input == NULL)
|
||||
cItem * Input = (cItem *)tolua_tousertype(L, 2, nullptr);
|
||||
if (Input == nullptr)
|
||||
{
|
||||
LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing.");
|
||||
return 0;
|
||||
@@ -2731,7 +2729,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
|
||||
// Get the recipe for the input
|
||||
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
|
||||
const cFurnaceRecipe::cRecipe * Recipe = FR->GetRecipeFrom(*Input);
|
||||
if (Recipe == NULL)
|
||||
if (Recipe == nullptr)
|
||||
{
|
||||
// There is no such furnace recipe for this input, return no value
|
||||
return 0;
|
||||
@@ -2762,10 +2760,10 @@ static int tolua_cHopperEntity_GetOutputBlockPos(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cHopperEntity * self = (cHopperEntity *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cHopperEntity::GetOutputBlockPos()'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cHopperEntity::GetOutputBlockPos()'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2802,10 +2800,10 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@@ -2836,10 +2834,10 @@ static int tolua_cBlockArea_GetOrigin(lua_State * tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetOrigin'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2868,10 +2866,10 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetRelBlockTypeMeta'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
int BlockX = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
@@ -2902,10 +2900,10 @@ static int tolua_cBlockArea_GetSize(lua_State * tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2933,10 +2931,10 @@ static int tolua_cBlockArea_GetCoordRange(lua_State * tolua_S)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea:GetSize'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2964,10 +2962,10 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2994,10 +2992,10 @@ static int tolua_cBlockArea_LoadFromSchematicString(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::LoadFromSchematicFile'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3025,10 +3023,10 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
AString Filename = tolua_tostring(tolua_S, 2, 0);
|
||||
@@ -3053,10 +3051,10 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cBlockArea * self = (cBlockArea *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cBlockArea::SaveToSchematicFile'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3087,10 +3085,10 @@ static int tolua_cCompositeChat_AddRunCommandPart(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddRunCommandPart'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddRunCommandPart'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3124,10 +3122,10 @@ static int tolua_cCompositeChat_AddSuggestCommandPart(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddSuggestCommandPart'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddSuggestCommandPart'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3161,10 +3159,10 @@ static int tolua_cCompositeChat_AddTextPart(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddTextPart'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddTextPart'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3197,10 +3195,10 @@ static int tolua_cCompositeChat_AddUrlPart(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddUrlPart'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:AddUrlPart'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3234,10 +3232,10 @@ static int tolua_cCompositeChat_ParseText(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:ParseText'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3269,10 +3267,10 @@ static int tolua_cCompositeChat_SetMessageType(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:SetMessageType'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:SetMessageType'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3301,10 +3299,10 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, NULL);
|
||||
if (self == NULL)
|
||||
cCompositeChat * self = (cCompositeChat *)tolua_tousertype(tolua_S, 1, nullptr);
|
||||
if (self == nullptr)
|
||||
{
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:UnderlineUrls'", NULL);
|
||||
tolua_error(tolua_S, "invalid 'self' in function 'cCompositeChat:UnderlineUrls'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3322,7 +3320,7 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
|
||||
|
||||
void ManualBindings::Bind(lua_State * tolua_S)
|
||||
{
|
||||
tolua_beginmodule(tolua_S, NULL);
|
||||
tolua_beginmodule(tolua_S, nullptr);
|
||||
tolua_function(tolua_S, "Clamp", tolua_Clamp);
|
||||
tolua_function(tolua_S, "StringSplit", tolua_StringSplit);
|
||||
tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim);
|
||||
@@ -3370,6 +3368,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
||||
|
||||
tolua_beginmodule(tolua_S, "cRoot");
|
||||
tolua_function(tolua_S, "FindAndDoWithPlayer", tolua_DoWith <cRoot, cPlayer, &cRoot::FindAndDoWithPlayer>);
|
||||
tolua_function(tolua_S, "DoWithPlayerByUUID", tolua_DoWith <cRoot, cPlayer, &cRoot::DoWithPlayerByUUID>);
|
||||
tolua_function(tolua_S, "ForEachPlayer", tolua_ForEach<cRoot, cPlayer, &cRoot::ForEachPlayer>);
|
||||
tolua_function(tolua_S, "ForEachWorld", tolua_ForEach<cRoot, cWorld, &cRoot::ForEachWorld>);
|
||||
tolua_function(tolua_S, "GetFurnaceRecipe", tolua_cRoot_GetFurnaceRecipe);
|
||||
@@ -3391,6 +3390,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
||||
tolua_function(tolua_S, "DoWithFlowerPotAt", tolua_DoWithXYZ<cWorld, cFlowerPotEntity, &cWorld::DoWithFlowerPotAt>);
|
||||
tolua_function(tolua_S, "DoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::DoWithPlayer>);
|
||||
tolua_function(tolua_S, "FindAndDoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::FindAndDoWithPlayer>);
|
||||
tolua_function(tolua_S, "DoWithPlayerByUUID", tolua_DoWith< cWorld, cPlayer, &cWorld::DoWithPlayerByUUID>);
|
||||
tolua_function(tolua_S, "ForEachBlockEntityInChunk", tolua_ForEachInChunk<cWorld, cBlockEntity, &cWorld::ForEachBlockEntityInChunk>);
|
||||
tolua_function(tolua_S, "ForEachChestInChunk", tolua_ForEachInChunk<cWorld, cChestEntity, &cWorld::ForEachChestInChunk>);
|
||||
tolua_function(tolua_S, "ForEachEntity", tolua_ForEach< cWorld, cEntity, &cWorld::ForEachEntity>);
|
||||
@@ -3405,7 +3405,6 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
||||
tolua_function(tolua_S, "ScheduleTask", tolua_cWorld_ScheduleTask);
|
||||
tolua_function(tolua_S, "SetSignLines", tolua_cWorld_SetSignLines);
|
||||
tolua_function(tolua_S, "TryGetHeight", tolua_cWorld_TryGetHeight);
|
||||
tolua_function(tolua_S, "UpdateSign", tolua_cWorld_SetSignLines);
|
||||
tolua_endmodule(tolua_S);
|
||||
|
||||
tolua_beginmodule(tolua_S, "cMapManager");
|
||||
@@ -3449,7 +3448,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
||||
tolua_function(tolua_S, "AddWebTab", tolua_cPluginLua_AddWebTab);
|
||||
tolua_endmodule(tolua_S);
|
||||
|
||||
tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", NULL);
|
||||
tolua_cclass(tolua_S, "HTTPRequest", "HTTPRequest", "", nullptr);
|
||||
tolua_beginmodule(tolua_S, "HTTPRequest");
|
||||
// tolua_variable(tolua_S, "Method", tolua_get_HTTPRequest_Method, tolua_set_HTTPRequest_Method);
|
||||
// tolua_variable(tolua_S, "Path", tolua_get_HTTPRequest_Path, tolua_set_HTTPRequest_Path);
|
||||
|
||||
@@ -34,7 +34,7 @@ static int tolua_cRankManager_AddGroup(lua_State * L)
|
||||
S.GetStackValue(2, GroupName);
|
||||
|
||||
// Add the group:
|
||||
cRoot::Get()->GetRankManager().AddGroup(GroupName);
|
||||
cRoot::Get()->GetRankManager()->AddGroup(GroupName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ static int tolua_cRankManager_AddGroupToRank(lua_State * L)
|
||||
S.GetStackValues(2, GroupName, RankName);
|
||||
|
||||
// Add the group to the rank:
|
||||
S.Push(cRoot::Get()->GetRankManager().AddGroupToRank(GroupName, RankName));
|
||||
S.Push(cRoot::Get()->GetRankManager()->AddGroupToRank(GroupName, RankName));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ static int tolua_cRankManager_AddPermissionToGroup(lua_State * L)
|
||||
S.GetStackValues(2, Permission, GroupName);
|
||||
|
||||
// Add the group to the rank:
|
||||
S.Push(cRoot::Get()->GetRankManager().AddPermissionToGroup(Permission, GroupName));
|
||||
S.Push(cRoot::Get()->GetRankManager()->AddPermissionToGroup(Permission, GroupName));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ static int tolua_cRankManager_AddRank(lua_State * L)
|
||||
S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
|
||||
|
||||
// Add the rank:
|
||||
cRoot::Get()->GetRankManager().AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
|
||||
cRoot::Get()->GetRankManager()->AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -129,6 +129,27 @@ static int tolua_cRankManager_AddRank(lua_State * L)
|
||||
|
||||
|
||||
|
||||
/** Binds cRankManager::ClearPlayerRanks */
|
||||
static int tolua_cRankManager_ClearPlayerRanks(lua_State * L)
|
||||
{
|
||||
cLuaState S(L);
|
||||
if (
|
||||
!S.CheckParamUserTable(1, "cRankManager") ||
|
||||
!S.CheckParamEnd(2)
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Remove all players:
|
||||
cRoot::Get()->GetRankManager()->ClearPlayerRanks();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Binds cRankManager::GetAllGroups */
|
||||
static int tolua_cRankManager_GetAllGroups(lua_State * L)
|
||||
{
|
||||
@@ -145,7 +166,7 @@ static int tolua_cRankManager_GetAllGroups(lua_State * L)
|
||||
}
|
||||
|
||||
// Get the groups:
|
||||
AStringVector Groups = cRoot::Get()->GetRankManager().GetAllGroups();
|
||||
AStringVector Groups = cRoot::Get()->GetRankManager()->GetAllGroups();
|
||||
|
||||
// Push the results:
|
||||
S.Push(Groups);
|
||||
@@ -172,7 +193,7 @@ static int tolua_cRankManager_GetAllPermissions(lua_State * L)
|
||||
}
|
||||
|
||||
// Get the permissions:
|
||||
AStringVector Permissions = cRoot::Get()->GetRankManager().GetAllPermissions();
|
||||
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissions();
|
||||
|
||||
// Push the results:
|
||||
S.Push(Permissions);
|
||||
@@ -183,6 +204,33 @@ static int tolua_cRankManager_GetAllPermissions(lua_State * L)
|
||||
|
||||
|
||||
|
||||
/** Binds cRankManager::GetAllPlayerUUIDs */
|
||||
static int tolua_cRankManager_GetAllPlayerUUIDs(lua_State * L)
|
||||
{
|
||||
// Function signature:
|
||||
// cRankManager:GetAllPlayerUUIDs() -> arraytable of Player UUID's
|
||||
|
||||
cLuaState S(L);
|
||||
if (
|
||||
!S.CheckParamUserTable(1, "cRankManager") ||
|
||||
!S.CheckParamEnd(2)
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the player uuid's:
|
||||
AStringVector Players = cRoot::Get()->GetRankManager()->GetAllPlayerUUIDs();
|
||||
|
||||
// Push the results:
|
||||
S.Push(Players);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Binds cRankManager::GetAllRanks */
|
||||
static int tolua_cRankManager_GetAllRanks(lua_State * L)
|
||||
{
|
||||
@@ -199,7 +247,7 @@ static int tolua_cRankManager_GetAllRanks(lua_State * L)
|
||||
}
|
||||
|
||||
// Get the ranks:
|
||||
AStringVector Ranks = cRoot::Get()->GetRankManager().GetAllRanks();
|
||||
AStringVector Ranks = cRoot::Get()->GetRankManager()->GetAllRanks();
|
||||
|
||||
// Push the results:
|
||||
S.Push(Ranks);
|
||||
@@ -226,7 +274,7 @@ static int tolua_cRankManager_GetDefaultRank(lua_State * L)
|
||||
}
|
||||
|
||||
// Return the rank name:
|
||||
S.Push(cRoot::Get()->GetRankManager().GetDefaultRank());
|
||||
S.Push(cRoot::Get()->GetRankManager()->GetDefaultRank());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -255,7 +303,7 @@ static int tolua_cRankManager_GetGroupPermissions(lua_State * L)
|
||||
S.GetStackValue(2, GroupName);
|
||||
|
||||
// Get the permissions:
|
||||
AStringVector Permissions = cRoot::Get()->GetRankManager().GetGroupPermissions(GroupName);
|
||||
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetGroupPermissions(GroupName);
|
||||
|
||||
// Push the results:
|
||||
S.Push(Permissions);
|
||||
@@ -287,7 +335,7 @@ static int tolua_cRankManager_GetPlayerGroups(lua_State * L)
|
||||
S.GetStackValue(2, PlayerUUID);
|
||||
|
||||
// Get the groups:
|
||||
AStringVector Groups = cRoot::Get()->GetRankManager().GetPlayerGroups(PlayerUUID);
|
||||
AStringVector Groups = cRoot::Get()->GetRankManager()->GetPlayerGroups(PlayerUUID);
|
||||
|
||||
// Push the results:
|
||||
S.Push(Groups);
|
||||
@@ -320,7 +368,7 @@ static int tolua_cRankManager_GetPlayerMsgVisuals(lua_State * L)
|
||||
|
||||
// Get the permissions:
|
||||
AString MsgPrefix, MsgSuffix, MsgNameColorCode;
|
||||
if (!cRoot::Get()->GetRankManager().GetPlayerMsgVisuals(PlayerUUID, MsgPrefix, MsgSuffix, MsgNameColorCode))
|
||||
if (!cRoot::Get()->GetRankManager()->GetPlayerMsgVisuals(PlayerUUID, MsgPrefix, MsgSuffix, MsgNameColorCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -357,7 +405,7 @@ static int tolua_cRankManager_GetPlayerPermissions(lua_State * L)
|
||||
S.GetStackValue(2, PlayerUUID);
|
||||
|
||||
// Get the permissions:
|
||||
AStringVector Permissions = cRoot::Get()->GetRankManager().GetPlayerPermissions(PlayerUUID);
|
||||
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetPlayerPermissions(PlayerUUID);
|
||||
|
||||
// Push the results:
|
||||
S.Push(Permissions);
|
||||
@@ -389,7 +437,7 @@ static int tolua_cRankManager_GetPlayerRankName(lua_State * L)
|
||||
S.GetStackValue(2, PlayerUUID);
|
||||
|
||||
// Get the rank name:
|
||||
AString RankName = cRoot::Get()->GetRankManager().GetPlayerRankName(PlayerUUID);
|
||||
AString RankName = cRoot::Get()->GetRankManager()->GetPlayerRankName(PlayerUUID);
|
||||
|
||||
// Push the result:
|
||||
S.Push(RankName);
|
||||
@@ -400,6 +448,38 @@ static int tolua_cRankManager_GetPlayerRankName(lua_State * L)
|
||||
|
||||
|
||||
|
||||
/** Binds cRankManager::GetPlayerName */
|
||||
static int tolua_cRankManager_GetPlayerName(lua_State * L)
|
||||
{
|
||||
// Function signature:
|
||||
// cRankManager:GetPlayerName(PlayerUUID) -> string
|
||||
|
||||
cLuaState S(L);
|
||||
if (
|
||||
!S.CheckParamUserTable(1, "cRankManager") ||
|
||||
!S.CheckParamString(2) ||
|
||||
!S.CheckParamEnd(3)
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the params:
|
||||
AString PlayerUUID;
|
||||
S.GetStackValue(2, PlayerUUID);
|
||||
|
||||
// Get the player name:
|
||||
AString PlayerName = cRoot::Get()->GetRankManager()->GetPlayerName(PlayerUUID);
|
||||
|
||||
// Push the result:
|
||||
S.Push(PlayerName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Binds cRankManager::GetRankGroups */
|
||||
static int tolua_cRankManager_GetRankGroups(lua_State * L)
|
||||
{
|
||||
@@ -421,7 +501,7 @@ static int tolua_cRankManager_GetRankGroups(lua_State * L)
|
||||
S.GetStackValue(2, RankName);
|
||||
|
||||
// Get the groups:
|
||||
AStringVector Groups = cRoot::Get()->GetRankManager().GetRankGroups(RankName);
|
||||
AStringVector Groups = cRoot::Get()->GetRankManager()->GetRankGroups(RankName);
|
||||
|
||||
// Push the results:
|
||||
S.Push(Groups);
|
||||
@@ -453,7 +533,7 @@ static int tolua_cRankManager_GetRankPermissions(lua_State * L)
|
||||
S.GetStackValue(2, RankName);
|
||||
|
||||
// Get the permissions:
|
||||
AStringVector Permissions = cRoot::Get()->GetRankManager().GetRankPermissions(RankName);
|
||||
AStringVector Permissions = cRoot::Get()->GetRankManager()->GetRankPermissions(RankName);
|
||||
|
||||
// Push the results:
|
||||
S.Push(Permissions);
|
||||
@@ -486,7 +566,7 @@ static int tolua_cRankManager_GetRankVisuals(lua_State * L)
|
||||
|
||||
// Get the visuals:
|
||||
AString MsgPrefix, MsgSuffix, MsgNameColorCode;
|
||||
if (!cRoot::Get()->GetRankManager().GetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode))
|
||||
if (!cRoot::Get()->GetRankManager()->GetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode))
|
||||
{
|
||||
// No such rank, return nothing:
|
||||
return 0;
|
||||
@@ -524,7 +604,7 @@ static int tolua_cRankManager_GroupExists(lua_State * L)
|
||||
S.GetStackValue(2, GroupName);
|
||||
|
||||
// Get the response:
|
||||
bool res = cRoot::Get()->GetRankManager().GroupExists(GroupName);
|
||||
bool res = cRoot::Get()->GetRankManager()->GroupExists(GroupName);
|
||||
|
||||
// Push the result:
|
||||
S.Push(res);
|
||||
@@ -556,7 +636,7 @@ static int tolua_cRankManager_IsGroupInRank(lua_State * L)
|
||||
S.GetStackValues(2, GroupName, RankName);
|
||||
|
||||
// Get the response:
|
||||
bool res = cRoot::Get()->GetRankManager().IsGroupInRank(GroupName, RankName);
|
||||
bool res = cRoot::Get()->GetRankManager()->IsGroupInRank(GroupName, RankName);
|
||||
|
||||
// Push the result:
|
||||
S.Push(res);
|
||||
@@ -588,7 +668,7 @@ static int tolua_cRankManager_IsPermissionInGroup(lua_State * L)
|
||||
S.GetStackValues(2, Permission, GroupName);
|
||||
|
||||
// Get the response:
|
||||
bool res = cRoot::Get()->GetRankManager().IsPermissionInGroup(Permission, GroupName);
|
||||
bool res = cRoot::Get()->GetRankManager()->IsPermissionInGroup(Permission, GroupName);
|
||||
|
||||
// Push the result:
|
||||
S.Push(res);
|
||||
@@ -620,7 +700,7 @@ static int tolua_cRankManager_IsPlayerRankSet(lua_State * L)
|
||||
S.GetStackValue(2, PlayerUUID);
|
||||
|
||||
// Get the response:
|
||||
bool res = cRoot::Get()->GetRankManager().IsPlayerRankSet(PlayerUUID);
|
||||
bool res = cRoot::Get()->GetRankManager()->IsPlayerRankSet(PlayerUUID);
|
||||
|
||||
// Push the result:
|
||||
S.Push(res);
|
||||
@@ -652,7 +732,7 @@ static int tolua_cRankManager_RankExists(lua_State * L)
|
||||
S.GetStackValue(2, RankName);
|
||||
|
||||
// Get the response:
|
||||
bool res = cRoot::Get()->GetRankManager().RankExists(RankName);
|
||||
bool res = cRoot::Get()->GetRankManager()->RankExists(RankName);
|
||||
|
||||
// Push the result:
|
||||
S.Push(res);
|
||||
@@ -684,7 +764,7 @@ static int tolua_cRankManager_RemoveGroup(lua_State * L)
|
||||
S.GetStackValue(2, GroupName);
|
||||
|
||||
// Remove the group:
|
||||
cRoot::Get()->GetRankManager().RemoveGroup(GroupName);
|
||||
cRoot::Get()->GetRankManager()->RemoveGroup(GroupName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -713,7 +793,7 @@ static int tolua_cRankManager_RemoveGroupFromRank(lua_State * L)
|
||||
S.GetStackValues(2, GroupName, RankName);
|
||||
|
||||
// Remove the group:
|
||||
cRoot::Get()->GetRankManager().RemoveGroupFromRank(GroupName, RankName);
|
||||
cRoot::Get()->GetRankManager()->RemoveGroupFromRank(GroupName, RankName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -742,7 +822,7 @@ static int tolua_cRankManager_RemovePermissionFromGroup(lua_State * L)
|
||||
S.GetStackValues(2, Permission, GroupName);
|
||||
|
||||
// Remove the group:
|
||||
cRoot::Get()->GetRankManager().RemovePermissionFromGroup(Permission, GroupName);
|
||||
cRoot::Get()->GetRankManager()->RemovePermissionFromGroup(Permission, GroupName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -771,7 +851,7 @@ static int tolua_cRankManager_RemovePlayerRank(lua_State * L)
|
||||
S.GetStackValue(2, PlayerUUID);
|
||||
|
||||
// Remove the player's rank:
|
||||
cRoot::Get()->GetRankManager().RemovePlayerRank(PlayerUUID);
|
||||
cRoot::Get()->GetRankManager()->RemovePlayerRank(PlayerUUID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -801,7 +881,7 @@ static int tolua_cRankManager_RemoveRank(lua_State * L)
|
||||
S.GetStackValues(2, RankName, ReplacementRankName);
|
||||
|
||||
// Remove the rank:
|
||||
cRoot::Get()->GetRankManager().RemoveRank(RankName, ReplacementRankName);
|
||||
cRoot::Get()->GetRankManager()->RemoveRank(RankName, ReplacementRankName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -830,7 +910,7 @@ static int tolua_cRankManager_RenameGroup(lua_State * L)
|
||||
S.GetStackValues(2, OldName, NewName);
|
||||
|
||||
// Remove the group:
|
||||
bool res = cRoot::Get()->GetRankManager().RenameGroup(OldName, NewName);
|
||||
bool res = cRoot::Get()->GetRankManager()->RenameGroup(OldName, NewName);
|
||||
|
||||
// Push the result:
|
||||
S.Push(res);
|
||||
@@ -862,7 +942,7 @@ static int tolua_cRankManager_RenameRank(lua_State * L)
|
||||
S.GetStackValues(2, OldName, NewName);
|
||||
|
||||
// Remove the rank:
|
||||
bool res = cRoot::Get()->GetRankManager().RenameRank(OldName, NewName);
|
||||
bool res = cRoot::Get()->GetRankManager()->RenameRank(OldName, NewName);
|
||||
|
||||
// Push the result:
|
||||
S.Push(res);
|
||||
@@ -894,8 +974,8 @@ static int tolua_cRankManager_SetDefaultRank(lua_State * L)
|
||||
S.GetStackValue(2, RankName);
|
||||
|
||||
// Set the rank, return the result:
|
||||
S.Push(cRoot::Get()->GetRankManager().SetDefaultRank(RankName));
|
||||
return 0;
|
||||
S.Push(cRoot::Get()->GetRankManager()->SetDefaultRank(RankName));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -923,7 +1003,7 @@ static int tolua_cRankManager_SetPlayerRank(lua_State * L)
|
||||
S.GetStackValues(2, PlayerUUID, PlayerName, RankName);
|
||||
|
||||
// Set the rank:
|
||||
cRoot::Get()->GetRankManager().SetPlayerRank(PlayerUUID, PlayerName, RankName);
|
||||
cRoot::Get()->GetRankManager()->SetPlayerRank(PlayerUUID, PlayerName, RankName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -952,7 +1032,7 @@ static int tolua_cRankManager_SetRankVisuals(lua_State * L)
|
||||
S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
|
||||
|
||||
// Set the visuals:
|
||||
cRoot::Get()->GetRankManager().SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
|
||||
cRoot::Get()->GetRankManager()->SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -964,7 +1044,7 @@ void ManualBindings::BindRankManager(lua_State * tolua_S)
|
||||
{
|
||||
// Create the cRankManager class in the API:
|
||||
tolua_usertype(tolua_S, "cRankManager");
|
||||
tolua_cclass(tolua_S, "cRankManager", "cRankManager", "", NULL);
|
||||
tolua_cclass(tolua_S, "cRankManager", "cRankManager", "", nullptr);
|
||||
|
||||
// Fill in the functions (alpha-sorted):
|
||||
tolua_beginmodule(tolua_S, "cRankManager");
|
||||
@@ -972,8 +1052,10 @@ void ManualBindings::BindRankManager(lua_State * tolua_S)
|
||||
tolua_function(tolua_S, "AddGroupToRank", tolua_cRankManager_AddGroupToRank);
|
||||
tolua_function(tolua_S, "AddPermissionToGroup", tolua_cRankManager_AddPermissionToGroup);
|
||||
tolua_function(tolua_S, "AddRank", tolua_cRankManager_AddRank);
|
||||
tolua_function(tolua_S, "ClearPlayerRanks", tolua_cRankManager_ClearPlayerRanks);
|
||||
tolua_function(tolua_S, "GetAllGroups", tolua_cRankManager_GetAllGroups);
|
||||
tolua_function(tolua_S, "GetAllPermissions", tolua_cRankManager_GetAllPermissions);
|
||||
tolua_function(tolua_S, "GetAllPlayerUUIDs", tolua_cRankManager_GetAllPlayerUUIDs);
|
||||
tolua_function(tolua_S, "GetAllRanks", tolua_cRankManager_GetAllRanks);
|
||||
tolua_function(tolua_S, "GetDefaultRank", tolua_cRankManager_GetDefaultRank);
|
||||
tolua_function(tolua_S, "GetGroupPermissions", tolua_cRankManager_GetGroupPermissions);
|
||||
@@ -981,6 +1063,7 @@ void ManualBindings::BindRankManager(lua_State * tolua_S)
|
||||
tolua_function(tolua_S, "GetPlayerMsgVisuals", tolua_cRankManager_GetPlayerMsgVisuals);
|
||||
tolua_function(tolua_S, "GetPlayerPermissions", tolua_cRankManager_GetPlayerPermissions);
|
||||
tolua_function(tolua_S, "GetPlayerRankName", tolua_cRankManager_GetPlayerRankName);
|
||||
tolua_function(tolua_S, "GetPlayerName", tolua_cRankManager_GetPlayerName);
|
||||
tolua_function(tolua_S, "GetRankGroups", tolua_cRankManager_GetRankGroups);
|
||||
tolua_function(tolua_S, "GetRankPermissions", tolua_cRankManager_GetRankPermissions);
|
||||
tolua_function(tolua_S, "GetRankVisuals", tolua_cRankManager_GetRankVisuals);
|
||||
|
||||
@@ -45,26 +45,26 @@ public:
|
||||
virtual void Tick(float a_Dt) = 0;
|
||||
|
||||
/** Calls the specified hook with the params given. Returns the bool that the hook callback returns.*/
|
||||
virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0;
|
||||
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
|
||||
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) = 0;
|
||||
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
||||
virtual bool OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) = 0;
|
||||
virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) = 0;
|
||||
virtual bool OnChunkUnloaded (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
||||
virtual bool OnChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
||||
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) = 0;
|
||||
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
||||
virtual bool OnBlockSpread (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0;
|
||||
virtual bool OnBlockToPickups (cWorld & a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
|
||||
virtual bool OnChat (cPlayer & a_Player, AString & a_Message) = 0;
|
||||
virtual bool OnChunkAvailable (cWorld & a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
||||
virtual bool OnChunkGenerated (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) = 0;
|
||||
virtual bool OnChunkGenerating (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) = 0;
|
||||
virtual bool OnChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
||||
virtual bool OnChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
||||
virtual bool OnCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup) = 0;
|
||||
virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
||||
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
|
||||
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) = 0;
|
||||
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
|
||||
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
|
||||
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) = 0;
|
||||
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0;
|
||||
virtual bool OnHandshake (cClientHandle & a_Client, const AString & a_Username) = 0;
|
||||
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0;
|
||||
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0;
|
||||
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0;
|
||||
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
|
||||
virtual bool OnLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
|
||||
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0;
|
||||
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
||||
virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
||||
@@ -89,8 +89,8 @@ public:
|
||||
virtual bool OnPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0;
|
||||
virtual bool OnPluginMessage (cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message) = 0;
|
||||
virtual bool OnPluginsLoaded (void) = 0;
|
||||
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
||||
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
||||
virtual bool OnPostCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) = 0;
|
||||
virtual bool OnPreCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) = 0;
|
||||
virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) = 0;
|
||||
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0;
|
||||
virtual bool OnServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon) = 0;
|
||||
@@ -99,8 +99,8 @@ public:
|
||||
virtual bool OnSpawningEntity (cWorld & a_World, cEntity & a_Entity) = 0;
|
||||
virtual bool OnSpawningMonster (cWorld & a_World, cMonster & a_Monster) = 0;
|
||||
virtual bool OnTakeDamage (cEntity & a_Receiver, TakeDamageInfo & a_TakeDamageInfo) = 0;
|
||||
virtual bool OnUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player) = 0;
|
||||
virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player) = 0;
|
||||
virtual bool OnUpdatedSign (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player) = 0;
|
||||
virtual bool OnUpdatingSign (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player) = 0;
|
||||
virtual bool OnWeatherChanged (cWorld & a_World) = 0;
|
||||
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) = 0;
|
||||
virtual bool OnWorldStarted (cWorld & a_World) = 0;
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
Command permissions have already been checked.
|
||||
Returns true if command handled successfully
|
||||
*/
|
||||
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer * a_Player) = 0;
|
||||
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player) = 0;
|
||||
|
||||
/** Handles the console command split into a_Split.
|
||||
Returns true if command handled successfully. Output is to be sent to the a_Output callback.
|
||||
|
||||
@@ -202,14 +202,14 @@ void cPluginLua::Tick(float a_Dt)
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
|
||||
bool cPluginLua::OnBlockSpread(cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_BLOCK_SPREAD];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -222,14 +222,14 @@ bool cPluginLua::OnBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnBlockToPickups(cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups)
|
||||
bool cPluginLua::OnBlockToPickups(cWorld & a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_BLOCK_TO_PICKUPS];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, &a_Pickups, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, &a_Pickups, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -242,14 +242,14 @@ bool cPluginLua::OnBlockToPickups(cWorld * a_World, cEntity * a_Digger, int a_Bl
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnChat(cPlayer * a_Player, AString & a_Message)
|
||||
bool cPluginLua::OnChat(cPlayer & a_Player, AString & a_Message)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHAT];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_Player, a_Message, cLuaState::Return, res, a_Message);
|
||||
m_LuaState.Call((int)(**itr), &a_Player, a_Message, cLuaState::Return, res, a_Message);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -262,14 +262,14 @@ bool cPluginLua::OnChat(cPlayer * a_Player, AString & a_Message)
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnChunkAvailable(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
bool cPluginLua::OnChunkAvailable(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_AVAILABLE];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -282,14 +282,14 @@ bool cPluginLua::OnChunkAvailable(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
|
||||
bool cPluginLua::OnChunkGenerated(cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_GENERATED];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -302,14 +302,14 @@ bool cPluginLua::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ,
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
|
||||
bool cPluginLua::OnChunkGenerating(cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_GENERATING];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -322,14 +322,14 @@ bool cPluginLua::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ,
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnChunkUnloaded(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
bool cPluginLua::OnChunkUnloaded(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_UNLOADED];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -342,14 +342,14 @@ bool cPluginLua::OnChunkUnloaded(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnChunkUnloading(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
bool cPluginLua::OnChunkUnloading(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CHUNK_UNLOADING];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_ChunkX, a_ChunkZ, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -362,14 +362,14 @@ bool cPluginLua::OnChunkUnloading(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnCollectingPickup(cPlayer * a_Player, cPickup * a_Pickup)
|
||||
bool cPluginLua::OnCollectingPickup(cPlayer & a_Player, cPickup & a_Pickup)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_COLLECTING_PICKUP];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_Player, a_Pickup, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_Player, &a_Pickup, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -382,14 +382,14 @@ bool cPluginLua::OnCollectingPickup(cPlayer * a_Player, cPickup * a_Pickup)
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
|
||||
bool cPluginLua::OnCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_CRAFTING_NO_RECIPE];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), (cPlayer *)a_Player, a_Grid, a_Recipe, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -471,12 +471,12 @@ bool cPluginLua::OnExploded(cWorld & a_World, double a_ExplosionSize, bool a_Can
|
||||
{
|
||||
switch (a_Source)
|
||||
{
|
||||
case esOther: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
|
||||
case esPrimedTNT: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cTNTEntity *)a_SourceData, cLuaState::Return, res); break;
|
||||
case esMonster: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cMonster *)a_SourceData, cLuaState::Return, res); break;
|
||||
case esBed: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res); break;
|
||||
case esEnderCrystal: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res); break;
|
||||
case esGhastFireball: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
|
||||
case esOther: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
|
||||
case esPrimedTNT: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cTNTEntity *)a_SourceData, cLuaState::Return, res); break;
|
||||
case esMonster: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (cMonster *)a_SourceData, cLuaState::Return, res); break;
|
||||
case esBed: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res); break;
|
||||
case esEnderCrystal: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, (Vector3i *)a_SourceData, cLuaState::Return, res); break;
|
||||
case esGhastFireball: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
|
||||
case esWitherSkullBlack:
|
||||
case esWitherSkullBlue: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
|
||||
case esWitherBirth: m_LuaState.Call((int)(**itr), &a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData, cLuaState::Return, res); break;
|
||||
@@ -536,14 +536,14 @@ bool cPluginLua::OnExploding(cWorld & a_World, double & a_ExplosionSize, bool &
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnHandshake(cClientHandle * a_Client, const AString & a_Username)
|
||||
bool cPluginLua::OnHandshake(cClientHandle & a_Client, const AString & a_Username)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_HANDSHAKE];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_Client, a_Username, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_Client, a_Username, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -617,14 +617,14 @@ bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInf
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username)
|
||||
bool cPluginLua::OnLogin(cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_LOGIN];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_Client, a_ProtocolVersion, a_Username, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_Client, a_ProtocolVersion, a_Username, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -784,7 +784,7 @@ bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, cItems & a_Reward)
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHING];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), &a_Player, a_Reward, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_Player, &a_Reward, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -1115,14 +1115,14 @@ bool cPluginLua::OnPluginsLoaded(void)
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
|
||||
bool cPluginLua::OnPostCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_POST_CRAFTING];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_Player, a_Grid, a_Recipe, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -1135,14 +1135,14 @@ bool cPluginLua::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid *
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
|
||||
bool cPluginLua::OnPreCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PRE_CRAFTING];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_Player, a_Grid, a_Recipe, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_Player, &a_Grid, &a_Recipe, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -1316,7 +1316,7 @@ bool cPluginLua::OnTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
|
||||
|
||||
|
||||
bool cPluginLua::OnUpdatedSign(
|
||||
cWorld * a_World,
|
||||
cWorld & a_World,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ,
|
||||
const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4,
|
||||
cPlayer * a_Player
|
||||
@@ -1327,7 +1327,7 @@ bool cPluginLua::OnUpdatedSign(
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_UPDATED_SIGN];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -1341,7 +1341,7 @@ bool cPluginLua::OnUpdatedSign(
|
||||
|
||||
|
||||
bool cPluginLua::OnUpdatingSign(
|
||||
cWorld * a_World,
|
||||
cWorld & a_World,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ,
|
||||
AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4,
|
||||
cPlayer * a_Player
|
||||
@@ -1352,7 +1352,7 @@ bool cPluginLua::OnUpdatingSign(
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_UPDATING_SIGN];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res, a_Line1, a_Line2, a_Line3, a_Line4);
|
||||
m_LuaState.Call((int)(**itr), &a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player, cLuaState::Return, res, a_Line1, a_Line2, a_Line3, a_Line4);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
@@ -1435,7 +1435,7 @@ bool cPluginLua::OnWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDuratio
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer * a_Player)
|
||||
bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer & a_Player)
|
||||
{
|
||||
ASSERT(!a_Split.empty());
|
||||
CommandMap::iterator cmd = m_Commands.find(a_Split[0]);
|
||||
@@ -1447,7 +1447,7 @@ bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer * a_Player
|
||||
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
m_LuaState.Call(cmd->second, a_Split, a_Player, cLuaState::Return, res);
|
||||
m_LuaState.Call(cmd->second, a_Split, &a_Player, cLuaState::Return, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1487,7 +1487,7 @@ void cPluginLua::ClearCommands(void)
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
|
||||
// Unreference the bound functions so that Lua can GC them
|
||||
if (m_LuaState != NULL)
|
||||
if (m_LuaState != nullptr)
|
||||
{
|
||||
for (CommandMap::iterator itr = m_Commands.begin(), end = m_Commands.end(); itr != end; ++itr)
|
||||
{
|
||||
@@ -1506,7 +1506,7 @@ void cPluginLua::ClearConsoleCommands(void)
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
|
||||
// Unreference the bound functions so that Lua can GC them
|
||||
if (m_LuaState != NULL)
|
||||
if (m_LuaState != nullptr)
|
||||
{
|
||||
for (CommandMap::iterator itr = m_ConsoleCommands.begin(), end = m_ConsoleCommands.end(); itr != end; ++itr)
|
||||
{
|
||||
@@ -1523,7 +1523,7 @@ void cPluginLua::ClearConsoleCommands(void)
|
||||
bool cPluginLua::CanAddOldStyleHook(int a_HookType)
|
||||
{
|
||||
const char * FnName = GetHookFnName(a_HookType);
|
||||
if (FnName == NULL)
|
||||
if (FnName == nullptr)
|
||||
{
|
||||
// Unknown hook ID
|
||||
LOGWARNING("Plugin %s wants to add an unknown hook ID (%d). The plugin need not work properly.",
|
||||
@@ -1614,7 +1614,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
|
||||
} // switch (a_Hook)
|
||||
LOGWARNING("Requested name of an unknown hook type function: %d (max is %d)", a_HookType, cPluginManager::HOOK_MAX);
|
||||
ASSERT(!"Unknown hook requested!");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1627,12 +1627,12 @@ bool cPluginLua::AddHookRef(int a_HookType, int a_FnRefIdx)
|
||||
|
||||
// Check if the function reference is valid:
|
||||
cLuaState::cRef * Ref = new cLuaState::cRef(m_LuaState, a_FnRefIdx);
|
||||
if ((Ref == NULL) || !Ref->IsValid())
|
||||
if ((Ref == nullptr) || !Ref->IsValid())
|
||||
{
|
||||
LOGWARNING("Plugin %s tried to add a hook %d with bad handler function.", GetName().c_str(), a_HookType);
|
||||
m_LuaState.LogStackTrace();
|
||||
delete Ref;
|
||||
Ref = NULL;
|
||||
Ref = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1700,7 +1700,7 @@ AString cPluginLua::HandleWebRequest(const HTTPRequest * a_Request)
|
||||
}
|
||||
}
|
||||
|
||||
if (Tab != NULL)
|
||||
if (Tab != nullptr)
|
||||
{
|
||||
AString Contents = Printf("WARNING: WebPlugin tab '%s' did not return a string!", Tab->Title.c_str());
|
||||
if (!m_LuaState.Call(Tab->UserData, a_Request, cLuaState::Return, Contents))
|
||||
|
||||
@@ -69,26 +69,26 @@ public:
|
||||
|
||||
virtual void Tick(float a_Dt) override;
|
||||
|
||||
virtual bool OnBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) override;
|
||||
virtual bool OnBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) override;
|
||||
virtual bool OnChat (cPlayer * a_Player, AString & a_Message) override;
|
||||
virtual bool OnChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
|
||||
virtual bool OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) override;
|
||||
virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) override;
|
||||
virtual bool OnChunkUnloaded (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
|
||||
virtual bool OnChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
|
||||
virtual bool OnCollectingPickup (cPlayer * a_Player, cPickup * a_Pickup) override;
|
||||
virtual bool OnCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
||||
virtual bool OnBlockSpread (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) override;
|
||||
virtual bool OnBlockToPickups (cWorld & a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) override;
|
||||
virtual bool OnChat (cPlayer & a_Player, AString & a_Message) override;
|
||||
virtual bool OnChunkAvailable (cWorld & a_World, int a_ChunkX, int a_ChunkZ) override;
|
||||
virtual bool OnChunkGenerated (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) override;
|
||||
virtual bool OnChunkGenerating (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc) override;
|
||||
virtual bool OnChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ) override;
|
||||
virtual bool OnChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ) override;
|
||||
virtual bool OnCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup) override;
|
||||
virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe) override;
|
||||
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
|
||||
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override;
|
||||
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override;
|
||||
virtual bool OnExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
|
||||
virtual bool OnExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData) override;
|
||||
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override;
|
||||
virtual bool OnHandshake (cClientHandle & a_Client, const AString & a_Username) override;
|
||||
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override;
|
||||
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override;
|
||||
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override;
|
||||
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
|
||||
virtual bool OnLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username) override;
|
||||
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override;
|
||||
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
|
||||
virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
|
||||
@@ -113,8 +113,8 @@ public:
|
||||
virtual bool OnPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
|
||||
virtual bool OnPluginMessage (cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message) override;
|
||||
virtual bool OnPluginsLoaded (void) override;
|
||||
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
||||
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
||||
virtual bool OnPostCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) override;
|
||||
virtual bool OnPreCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) override;
|
||||
virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) override;
|
||||
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override;
|
||||
virtual bool OnServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon) override;
|
||||
@@ -123,14 +123,14 @@ public:
|
||||
virtual bool OnSpawningEntity (cWorld & a_World, cEntity & a_Entity) override;
|
||||
virtual bool OnSpawningMonster (cWorld & a_World, cMonster & a_Monster) override;
|
||||
virtual bool OnTakeDamage (cEntity & a_Receiver, TakeDamageInfo & a_TakeDamageInfo) override;
|
||||
virtual bool OnUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player) override;
|
||||
virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player) override;
|
||||
virtual bool OnUpdatedSign (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player) override;
|
||||
virtual bool OnUpdatingSign (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player) override;
|
||||
virtual bool OnWeatherChanged (cWorld & a_World) override;
|
||||
virtual bool OnWeatherChanging (cWorld & a_World, eWeather & a_NewWeather) override;
|
||||
virtual bool OnWorldStarted (cWorld & a_World) override;
|
||||
virtual bool OnWorldTick (cWorld & a_World, float a_Dt, int a_LastTickDurationMSec) override;
|
||||
|
||||
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer * a_Player) override;
|
||||
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player) override;
|
||||
|
||||
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output) override;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "../Server.h"
|
||||
#include "../CommandOutput.h"
|
||||
|
||||
#include "inifile/iniFile.h"
|
||||
#include "../IniFile.h"
|
||||
#include "../Entities/Player.h"
|
||||
|
||||
#define FIND_HOOK(a_HookName) HookMap::iterator Plugins = m_Hooks.find(a_HookName);
|
||||
@@ -66,7 +66,7 @@ void cPluginManager::FindPlugins(void)
|
||||
// First get a clean list of only the currently running plugins, we don't want to mess those up
|
||||
for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
|
||||
{
|
||||
if (itr->second == NULL)
|
||||
if (itr->second == nullptr)
|
||||
{
|
||||
PluginMap::iterator thiz = itr;
|
||||
++thiz;
|
||||
@@ -89,7 +89,7 @@ void cPluginManager::FindPlugins(void)
|
||||
// Add plugin name/directory to the list
|
||||
if (m_Plugins.find(*itr) == m_Plugins.end())
|
||||
{
|
||||
m_Plugins[*itr] = NULL;
|
||||
m_Plugins[*itr] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
|
||||
// Remove invalid plugins from the PluginMap.
|
||||
for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
|
||||
{
|
||||
if (itr->second == NULL)
|
||||
if (itr->second == nullptr)
|
||||
{
|
||||
PluginMap::iterator thiz = itr;
|
||||
++thiz;
|
||||
@@ -225,7 +225,7 @@ void cPluginManager::Tick(float a_Dt)
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
|
||||
bool cPluginManager::CallHookBlockSpread(cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
|
||||
{
|
||||
FIND_HOOK(HOOK_BLOCK_SPREAD);
|
||||
VERIFY_HOOK;
|
||||
@@ -245,7 +245,7 @@ bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_B
|
||||
|
||||
|
||||
bool cPluginManager::CallHookBlockToPickups(
|
||||
cWorld * a_World, cEntity * a_Digger,
|
||||
cWorld & a_World, cEntity * a_Digger,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
|
||||
cItems & a_Pickups
|
||||
)
|
||||
@@ -267,7 +267,7 @@ bool cPluginManager::CallHookBlockToPickups(
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
|
||||
bool cPluginManager::CallHookChat(cPlayer & a_Player, AString & a_Message)
|
||||
{
|
||||
// Check if the message contains a command, execute it:
|
||||
switch (HandleCommand(a_Player, a_Message, true))
|
||||
@@ -288,14 +288,14 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
|
||||
case crError:
|
||||
{
|
||||
// An error in the plugin has prevented the command from executing. Report the error to the player:
|
||||
a_Player->SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str()));
|
||||
a_Player.SendMessageFailure(Printf("Something went wrong while executing command \"%s\"", a_Message.c_str()));
|
||||
return true;
|
||||
}
|
||||
|
||||
case crNoPermission:
|
||||
{
|
||||
// The player is not allowed to execute this command
|
||||
a_Player->SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str()));
|
||||
a_Player.SendMessageFailure(Printf("Forbidden command; insufficient privileges: \"%s\"", a_Message.c_str()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -311,8 +311,8 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
|
||||
{
|
||||
AStringVector Split(StringSplit(a_Message, " "));
|
||||
ASSERT(!Split.empty()); // This should not happen - we know there's at least one char in the message so the split needs to be at least one item long
|
||||
a_Player->SendMessageInfo(Printf("Unknown command: \"%s\"", a_Message.c_str()));
|
||||
LOGINFO("Player %s issued an unknown command: \"%s\"", a_Player->GetName().c_str(), a_Message.c_str());
|
||||
a_Player.SendMessageInfo(Printf("Unknown command: \"%s\"", a_Message.c_str()));
|
||||
LOGINFO("Player %s issued an unknown command: \"%s\"", a_Player.GetName().c_str(), a_Message.c_str());
|
||||
return true; // Cancel sending
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
bool cPluginManager::CallHookChunkAvailable(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
FIND_HOOK(HOOK_CHUNK_AVAILABLE);
|
||||
VERIFY_HOOK;
|
||||
@@ -353,7 +353,7 @@ bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
|
||||
bool cPluginManager::CallHookChunkGenerated(cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
|
||||
{
|
||||
FIND_HOOK(HOOK_CHUNK_GENERATED);
|
||||
VERIFY_HOOK;
|
||||
@@ -372,7 +372,7 @@ bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
|
||||
bool cPluginManager::CallHookChunkGenerating(cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
|
||||
{
|
||||
FIND_HOOK(HOOK_CHUNK_GENERATING);
|
||||
VERIFY_HOOK;
|
||||
@@ -391,7 +391,7 @@ bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
bool cPluginManager::CallHookChunkUnloaded(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
FIND_HOOK(HOOK_CHUNK_UNLOADED);
|
||||
VERIFY_HOOK;
|
||||
@@ -410,7 +410,7 @@ bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
|
||||
bool cPluginManager::CallHookChunkUnloading(cWorld & a_World, int a_ChunkX, int a_ChunkZ)
|
||||
{
|
||||
FIND_HOOK(HOOK_CHUNK_UNLOADING);
|
||||
VERIFY_HOOK;
|
||||
@@ -429,14 +429,14 @@ bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pickup)
|
||||
bool cPluginManager::CallHookCollectingPickup(cPlayer & a_Player, cPickup & a_Pickup)
|
||||
{
|
||||
FIND_HOOK(HOOK_COLLECTING_PICKUP);
|
||||
VERIFY_HOOK;
|
||||
|
||||
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->OnCollectingPickup(a_Player, &a_Pickup))
|
||||
if ((*itr)->OnCollectingPickup(a_Player, a_Pickup))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -448,7 +448,7 @@ bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pi
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
|
||||
bool cPluginManager::CallHookCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe)
|
||||
{
|
||||
FIND_HOOK(HOOK_CRAFTING_NO_RECIPE);
|
||||
VERIFY_HOOK;
|
||||
@@ -562,7 +562,7 @@ bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSiz
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const AString & a_Username)
|
||||
bool cPluginManager::CallHookHandshake(cClientHandle & a_ClientHandle, const AString & a_Username)
|
||||
{
|
||||
FIND_HOOK(HOOK_HANDSHAKE);
|
||||
VERIFY_HOOK;
|
||||
@@ -638,7 +638,7 @@ bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, Tak
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username)
|
||||
bool cPluginManager::CallHookLogin(cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username)
|
||||
{
|
||||
FIND_HOOK(HOOK_LOGIN);
|
||||
VERIFY_HOOK;
|
||||
@@ -1111,7 +1111,7 @@ bool cPluginManager::CallHookPluginsLoaded(void)
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
|
||||
bool cPluginManager::CallHookPostCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
|
||||
{
|
||||
FIND_HOOK(HOOK_POST_CRAFTING);
|
||||
VERIFY_HOOK;
|
||||
@@ -1130,7 +1130,7 @@ bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraft
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
|
||||
bool cPluginManager::CallHookPreCrafting(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
|
||||
{
|
||||
FIND_HOOK(HOOK_PRE_CRAFTING);
|
||||
VERIFY_HOOK;
|
||||
@@ -1299,7 +1299,7 @@ bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player)
|
||||
bool cPluginManager::CallHookUpdatingSign(cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player)
|
||||
{
|
||||
FIND_HOOK(HOOK_UPDATING_SIGN);
|
||||
VERIFY_HOOK;
|
||||
@@ -1318,7 +1318,7 @@ bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
|
||||
bool cPluginManager::CallHookUpdatedSign(cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
|
||||
{
|
||||
FIND_HOOK(HOOK_UPDATED_SIGN);
|
||||
VERIFY_HOOK;
|
||||
@@ -1413,10 +1413,8 @@ bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastT
|
||||
|
||||
|
||||
|
||||
cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
|
||||
cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer & a_Player, const AString & a_Command, bool a_ShouldCheckPermissions)
|
||||
{
|
||||
ASSERT(a_Player != NULL);
|
||||
|
||||
AStringVector Split(StringSplit(a_Command, " "));
|
||||
if (Split.empty())
|
||||
{
|
||||
@@ -1431,23 +1429,23 @@ cPluginManager::CommandResult cPluginManager::HandleCommand(cPlayer * a_Player,
|
||||
}
|
||||
|
||||
// Ask plugins first if a command is okay to execute the command:
|
||||
if (CallHookExecuteCommand(a_Player, Split))
|
||||
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());
|
||||
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 crBlocked;
|
||||
}
|
||||
|
||||
if (
|
||||
a_ShouldCheckPermissions &&
|
||||
!cmd->second.m_Permission.empty() &&
|
||||
!a_Player->HasPermission(cmd->second.m_Permission)
|
||||
!a_Player.HasPermission(cmd->second.m_Permission)
|
||||
)
|
||||
{
|
||||
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player->GetName().c_str(), Split[0].c_str());
|
||||
LOGINFO("Player %s tried to execute forbidden command: \"%s\"", a_Player.GetName().c_str(), Split[0].c_str());
|
||||
return crNoPermission;
|
||||
}
|
||||
|
||||
ASSERT(cmd->second.m_Plugin != NULL);
|
||||
ASSERT(cmd->second.m_Plugin != nullptr);
|
||||
|
||||
if (!cmd->second.m_Plugin->HandleCommand(Split, a_Player))
|
||||
{
|
||||
@@ -1465,7 +1463,7 @@ cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin) const
|
||||
{
|
||||
for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr)
|
||||
{
|
||||
if (itr->second == NULL) continue;
|
||||
if (itr->second == nullptr) continue;
|
||||
if (itr->second->GetName().compare(a_Plugin) == 0)
|
||||
{
|
||||
return itr->second;
|
||||
@@ -1515,7 +1513,7 @@ bool cPluginManager::DisablePlugin(const AString & a_PluginName)
|
||||
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);
|
||||
itr->second = NULL; // Get rid of this thing right away
|
||||
itr->second = nullptr; // Get rid of this thing right away
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1560,12 +1558,12 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin)
|
||||
RemovePluginCommands(a_Plugin);
|
||||
RemovePluginConsoleCommands(a_Plugin);
|
||||
RemoveHooks(a_Plugin);
|
||||
if (a_Plugin != NULL)
|
||||
if (a_Plugin != nullptr)
|
||||
{
|
||||
a_Plugin->OnDisable();
|
||||
}
|
||||
delete a_Plugin;
|
||||
a_Plugin = NULL;
|
||||
a_Plugin = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1574,7 +1572,7 @@ void cPluginManager::RemovePlugin(cPlugin * a_Plugin)
|
||||
|
||||
void cPluginManager::RemovePluginCommands(cPlugin * a_Plugin)
|
||||
{
|
||||
if (a_Plugin != NULL)
|
||||
if (a_Plugin != nullptr)
|
||||
{
|
||||
a_Plugin->ClearCommands();
|
||||
}
|
||||
@@ -1652,7 +1650,7 @@ AString cPluginManager::GetCommandPermission(const AString & a_Command)
|
||||
|
||||
|
||||
|
||||
cPluginManager::CommandResult cPluginManager::ExecuteCommand(cPlayer * a_Player, const AString & a_Command)
|
||||
cPluginManager::CommandResult cPluginManager::ExecuteCommand(cPlayer & a_Player, const AString & a_Command)
|
||||
{
|
||||
return HandleCommand(a_Player, a_Command, true);
|
||||
}
|
||||
@@ -1661,7 +1659,7 @@ cPluginManager::CommandResult cPluginManager::ExecuteCommand(cPlayer * a_Player,
|
||||
|
||||
|
||||
|
||||
cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command)
|
||||
cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer & a_Player, const AString & a_Command)
|
||||
{
|
||||
return HandleCommand(a_Player, a_Command, false);
|
||||
}
|
||||
@@ -1672,7 +1670,7 @@ cPluginManager::CommandResult cPluginManager::ForceExecuteCommand(cPlayer * a_Pl
|
||||
|
||||
void cPluginManager::RemovePluginConsoleCommands(cPlugin * a_Plugin)
|
||||
{
|
||||
if (a_Plugin != NULL)
|
||||
if (a_Plugin != nullptr)
|
||||
{
|
||||
a_Plugin->ClearConsoleCommands();
|
||||
}
|
||||
@@ -1701,7 +1699,7 @@ bool cPluginManager::BindConsoleCommand(const AString & a_Command, cPlugin * a_P
|
||||
CommandMap::iterator cmd = m_ConsoleCommands.find(a_Command);
|
||||
if (cmd != m_ConsoleCommands.end())
|
||||
{
|
||||
if (cmd->second.m_Plugin == NULL)
|
||||
if (cmd->second.m_Plugin == nullptr)
|
||||
{
|
||||
LOGWARNING("Console command \"%s\" is already bound internally by MCServer, cannot bind in plugin \"%s\".", a_Command.c_str(), a_Plugin->GetName().c_str());
|
||||
}
|
||||
@@ -1761,14 +1759,14 @@ bool cPluginManager::ExecuteConsoleCommand(const AStringVector & a_Split, cComma
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cmd->second.m_Plugin == NULL)
|
||||
if (cmd->second.m_Plugin == nullptr)
|
||||
{
|
||||
// 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))
|
||||
if (CallHookExecuteCommand(nullptr, a_Split))
|
||||
{
|
||||
a_Output.Out("Command \"%s\" was stopped by the HOOK_EXECUTE_COMMAND hook", a_Split[0].c_str());
|
||||
return false;
|
||||
@@ -1790,7 +1788,7 @@ void cPluginManager::TabCompleteCommand(const AString & a_Text, AStringVector &
|
||||
// Command name doesn't match
|
||||
continue;
|
||||
}
|
||||
if ((a_Player != NULL) && !a_Player->HasPermission(itr->second.m_Permission))
|
||||
if ((a_Player != nullptr) && !a_Player->HasPermission(itr->second.m_Permission))
|
||||
{
|
||||
// Player doesn't have permission for the command
|
||||
continue;
|
||||
@@ -1816,7 +1814,7 @@ bool cPluginManager::DoWithPlugin(const AString & a_PluginName, cPluginCallback
|
||||
{
|
||||
// TODO: Implement locking for plugins
|
||||
PluginMap::iterator itr = m_Plugins.find(a_PluginName);
|
||||
if ((itr == m_Plugins.end()) || (itr->second == NULL))
|
||||
if ((itr == m_Plugins.end()) || (itr->second == nullptr))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1830,6 +1828,7 @@ bool cPluginManager::DoWithPlugin(const AString & a_PluginName, cPluginCallback
|
||||
bool cPluginManager::AddPlugin(cPlugin * a_Plugin)
|
||||
{
|
||||
m_Plugins[a_Plugin->GetDirectory()] = a_Plugin;
|
||||
|
||||
if (a_Plugin->Initialize())
|
||||
{
|
||||
// Initialization OK
|
||||
@@ -1849,7 +1848,7 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook)
|
||||
{
|
||||
if (!a_Plugin)
|
||||
{
|
||||
LOGWARN("Called cPluginManager::AddHook() with a_Plugin == NULL");
|
||||
LOGWARN("Called cPluginManager::AddHook() with a_Plugin == nullptr");
|
||||
return;
|
||||
}
|
||||
PluginList & Plugins = m_Hooks[a_Hook];
|
||||
|
||||
@@ -178,26 +178,26 @@ public:
|
||||
size_t GetNumPlugins() const; // tolua_export
|
||||
|
||||
// Calls for individual hooks. Each returns false if the action is to continue or true if the plugin wants to abort
|
||||
bool CallHookBlockSpread (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source);
|
||||
bool CallHookBlockToPickups (cWorld * a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups);
|
||||
bool CallHookChat (cPlayer * a_Player, AString & a_Message);
|
||||
bool CallHookChunkAvailable (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
|
||||
bool CallHookChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
|
||||
bool CallHookChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
|
||||
bool CallHookChunkUnloaded (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
|
||||
bool CallHookChunkUnloading (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
|
||||
bool CallHookCollectingPickup (cPlayer * a_Player, cPickup & a_Pickup);
|
||||
bool CallHookCraftingNoRecipe (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
||||
bool CallHookBlockSpread (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source);
|
||||
bool CallHookBlockToPickups (cWorld & a_World, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups);
|
||||
bool CallHookChat (cPlayer & a_Player, AString & a_Message);
|
||||
bool CallHookChunkAvailable (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
|
||||
bool CallHookChunkGenerated (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
|
||||
bool CallHookChunkGenerating (cWorld & a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc);
|
||||
bool CallHookChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
|
||||
bool CallHookChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
|
||||
bool CallHookCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup);
|
||||
bool CallHookCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe);
|
||||
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
|
||||
bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
|
||||
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == NULL, it is a console cmd
|
||||
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == nullptr, it is a console cmd
|
||||
bool CallHookExploded (cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
|
||||
bool CallHookExploding (cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData);
|
||||
bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username);
|
||||
bool CallHookHandshake (cClientHandle & a_ClientHandle, const AString & a_Username);
|
||||
bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum);
|
||||
bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
|
||||
bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI);
|
||||
bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username);
|
||||
bool CallHookLogin (cClientHandle & a_Client, int a_ProtocolVersion, const AString & a_Username);
|
||||
bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
|
||||
bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
@@ -222,8 +222,8 @@ public:
|
||||
bool CallHookPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ);
|
||||
bool CallHookPluginMessage (cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message);
|
||||
bool CallHookPluginsLoaded (void);
|
||||
bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
||||
bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
||||
bool CallHookPostCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
|
||||
bool CallHookPreCrafting (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
|
||||
bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos);
|
||||
bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity);
|
||||
bool CallHookServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon);
|
||||
@@ -232,8 +232,8 @@ public:
|
||||
bool CallHookSpawningEntity (cWorld & a_World, cEntity & a_Entity);
|
||||
bool CallHookSpawningMonster (cWorld & a_World, cMonster & a_Monster);
|
||||
bool CallHookTakeDamage (cEntity & a_Receiver, TakeDamageInfo & a_TDI);
|
||||
bool CallHookUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player);
|
||||
bool CallHookUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player);
|
||||
bool CallHookUpdatedSign (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player);
|
||||
bool CallHookUpdatingSign (cWorld & a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player);
|
||||
bool CallHookWeatherChanged (cWorld & a_World);
|
||||
bool CallHookWeatherChanging (cWorld & a_World, eWeather & a_NewWeather);
|
||||
bool CallHookWorldStarted (cWorld & a_World);
|
||||
@@ -264,10 +264,10 @@ public:
|
||||
AString GetCommandPermission(const AString & a_Command); // tolua_export
|
||||
|
||||
/** Executes the command, as if it was requested by a_Player. Checks permissions first. Returns crExecuted if executed. */
|
||||
CommandResult ExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
|
||||
CommandResult ExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
|
||||
|
||||
/** Executes the command, as if it was requested by a_Player. Permisssions are not checked. Returns crExecuted if executed. */
|
||||
CommandResult ForceExecuteCommand(cPlayer * a_Player, const AString & a_Command); // tolua_export
|
||||
CommandResult ForceExecuteCommand(cPlayer & a_Player, const AString & a_Command); // tolua_export
|
||||
|
||||
/** Removes all console command bindings that the specified plugin has made */
|
||||
void RemovePluginConsoleCommands(cPlugin * a_Plugin);
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
bool ExecuteConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output);
|
||||
|
||||
/** Appends all commands beginning with a_Text (case-insensitive) into a_Results.
|
||||
If a_Player is not NULL, only commands for which the player has permissions are added.
|
||||
If a_Player is not nullptr, only commands for which the player has permissions are added.
|
||||
*/
|
||||
void TabCompleteCommand(const AString & a_Text, AStringVector & a_Results, cPlayer * a_Player);
|
||||
|
||||
@@ -341,7 +341,7 @@ private:
|
||||
bool AddPlugin(cPlugin * a_Plugin);
|
||||
|
||||
/** Tries to match a_Command to the internal table of commands, if a match is found, the corresponding plugin is called. Returns crExecuted if the command is executed. */
|
||||
cPluginManager::CommandResult HandleCommand(cPlayer * a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
|
||||
CommandResult HandleCommand(cPlayer & a_Player, const AString & a_Command, bool a_ShouldCheckPermissions);
|
||||
} ; // tolua_export
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
cWebPlugin::cWebPlugin()
|
||||
{
|
||||
cWebAdmin * WebAdmin = cRoot::Get()->GetWebAdmin();
|
||||
if (WebAdmin != NULL)
|
||||
if (WebAdmin != nullptr)
|
||||
{
|
||||
WebAdmin->AddPlugin(this);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ cWebPlugin::cWebPlugin()
|
||||
cWebPlugin::~cWebPlugin()
|
||||
{
|
||||
cWebAdmin * WebAdmin = cRoot::Get()->GetWebAdmin();
|
||||
if (WebAdmin != NULL)
|
||||
if (WebAdmin != nullptr)
|
||||
{
|
||||
WebAdmin->RemovePlugin(this);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
|
||||
|
||||
if (Split.size() > 1)
|
||||
{
|
||||
sWebPluginTab * Tab = NULL;
|
||||
sWebPluginTab * Tab = nullptr;
|
||||
if (Split.size() > 2) // If we got the tab name, show that page
|
||||
{
|
||||
for (TabList::iterator itr = GetTabs().begin(); itr != GetTabs().end(); ++itr)
|
||||
@@ -85,7 +85,7 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
|
||||
}
|
||||
}
|
||||
|
||||
if (Tab != NULL)
|
||||
if (Tab != nullptr)
|
||||
{
|
||||
Names.first = Tab->Title;
|
||||
Names.second = Tab->SafeTitle;
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
|
||||
-- gen_LuaState_Call.lua
|
||||
|
||||
-- Generates the cLuaState::Call() function templates that are included from LuaState.h
|
||||
|
||||
--[[
|
||||
The cLuaState::Call() family of functions provides a template-based system for calling any Lua function
|
||||
either by name or by reference with almost any number of parameters and return values. This is done by
|
||||
providing a number of overloads of the same name with variable number of template-type parameters. To
|
||||
separate the arguments from the return values, a special type of cLuaState::cRet is used.
|
||||
--]]
|
||||
|
||||
|
||||
|
||||
|
||||
print("Generating LuaState_Call.inc . . .")
|
||||
|
||||
|
||||
|
||||
|
||||
-- List of combinations (# params, # returns) to generate:
|
||||
local Combinations =
|
||||
{
|
||||
-- no return values:
|
||||
{0, 0},
|
||||
{1, 0},
|
||||
{2, 0},
|
||||
{3, 0},
|
||||
{4, 0},
|
||||
|
||||
-- 1 return value:
|
||||
{0, 1},
|
||||
{1, 1},
|
||||
{2, 1},
|
||||
{3, 1},
|
||||
{4, 1},
|
||||
{5, 1},
|
||||
{6, 1},
|
||||
{7, 1},
|
||||
{8, 1},
|
||||
{9, 1},
|
||||
{10, 1},
|
||||
|
||||
-- 2 return values:
|
||||
{0, 2},
|
||||
{1, 2},
|
||||
{2, 2},
|
||||
{3, 2},
|
||||
{4, 2},
|
||||
{5, 2},
|
||||
{6, 2},
|
||||
{7, 2},
|
||||
{8, 2},
|
||||
{9, 2},
|
||||
|
||||
-- Special combinations:
|
||||
{5, 5},
|
||||
{7, 3},
|
||||
{8, 3},
|
||||
{9, 5},
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
--- Writes a single overloaded function definition for the specified number of params and returns into f
|
||||
--[[
|
||||
The format for the generated function is this:
|
||||
/** Call the specified 3-param 2-return Lua function:
|
||||
Returns true if call succeeded, false if there was an error. */
|
||||
template <typename FnT, typename ParamT1, typename ParamT2, typename ParamT3, typename RetT1, typename RetT2>
|
||||
bool Call(FnT a_Function, ParamT1 a_Param1, ParamT2 a_Param2, ParamT3 a_Param3, const cLuaState::cRet & a_RetMark, RetT1 & a_Ret1, RetT2 & a_Ret2)
|
||||
{
|
||||
UNUSED(a_RetMark);
|
||||
if (!PushFunction(a_Function))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Push(a_Param1);
|
||||
Push(a_Param2);
|
||||
Push(a_Param3);
|
||||
if (!CallFunction(2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
GetStackValue(-2, a_Ret1);
|
||||
GetStackValue(-1, a_Ret2);
|
||||
lua_pop(m_LuaState, 2);
|
||||
return true;
|
||||
}
|
||||
Note especially the negative numbers in GetStackValue() calls.
|
||||
--]]
|
||||
local function WriteOverload(f, a_NumParams, a_NumReturns)
|
||||
-- Write the function doxy-comments:
|
||||
f:write("/** Call the specified ", a_NumParams, "-param ", a_NumReturns, "-return Lua function:\n")
|
||||
f:write("Returns true if call succeeded, false if there was an error. */\n")
|
||||
|
||||
-- Write the template <...> line:
|
||||
f:write("template <typename FnT")
|
||||
for i = 1, a_NumParams do
|
||||
f:write(", typename ParamT", i)
|
||||
end
|
||||
if (a_NumReturns > 0) then
|
||||
for i = 1, a_NumReturns do
|
||||
f:write(", typename RetT", i)
|
||||
end
|
||||
end
|
||||
f:write(">\n")
|
||||
|
||||
-- Write the function signature:
|
||||
f:write("bool Call(")
|
||||
f:write("const FnT & a_Function")
|
||||
for i = 1, a_NumParams do
|
||||
f:write(", ParamT", i, " a_Param", i)
|
||||
end
|
||||
if (a_NumReturns > 0) then
|
||||
f:write(", const cLuaState::cRet & a_RetMark")
|
||||
for i = 1, a_NumReturns do
|
||||
f:write(", RetT", i, " & a_Ret", i)
|
||||
end
|
||||
end
|
||||
f:write(")\n")
|
||||
|
||||
-- Common code:
|
||||
f:write("{\n")
|
||||
if (a_NumReturns > 0) then
|
||||
f:write("\tUNUSED(a_RetMark);\n")
|
||||
end
|
||||
f:write("\tif (!PushFunction(a_Function))\n")
|
||||
f:write("\t{\n")
|
||||
f:write("\t\treturn false;\n")
|
||||
f:write("\t}\n")
|
||||
|
||||
-- Push the params:
|
||||
for i = 1, a_NumParams do
|
||||
f:write("\tPush(a_Param", i, ");\n")
|
||||
end
|
||||
|
||||
-- Call the function:
|
||||
f:write("\tif (!CallFunction(", a_NumReturns, "))\n")
|
||||
f:write("\t{\n")
|
||||
f:write("\t\treturn false;\n")
|
||||
f:write("\t}\n")
|
||||
|
||||
-- Get the return values:
|
||||
for i = 1, a_NumReturns do
|
||||
f:write("\tGetStackValue(", -1 - a_NumReturns + i, ", a_Ret", i, ");\n")
|
||||
end
|
||||
|
||||
-- Pop the returns off the stack, if needed:
|
||||
if (a_NumReturns > 0) then
|
||||
f:write("\tlua_pop(m_LuaState, ", a_NumReturns, ");\n")
|
||||
end
|
||||
|
||||
-- Everything ok:
|
||||
f:write("\treturn true;\n")
|
||||
f:write("}\n")
|
||||
|
||||
-- Separate from the next function:
|
||||
f:write("\n\n\n\n\n")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local f = assert(io.open("LuaState_Call.inc", "w"))
|
||||
|
||||
-- Write file header:
|
||||
f:write([[
|
||||
// LuaState_Call.inc
|
||||
|
||||
// This file is auto-generated by gen_LuaState_Call.lua
|
||||
// Make changes to the generator instead of to this file!
|
||||
|
||||
// This file contains the various overloads for the cLuaState::Call() function
|
||||
// Each overload handles a different number of parameters / return values
|
||||
]])
|
||||
f:write("\n\n\n\n\n")
|
||||
|
||||
-- Write out a template function for each overload:
|
||||
for _, combination in ipairs(Combinations) do
|
||||
WriteOverload(f, combination[1], combination[2])
|
||||
end
|
||||
|
||||
-- Generate the cLuaState::GetStackValues() multi-param templates:
|
||||
for i = 2, 6 do
|
||||
f:write("/** Reads ", i, " consecutive values off the stack */\ntemplate <\n")
|
||||
|
||||
-- Write the template function header:
|
||||
local txt = {}
|
||||
for idx = 1, i do
|
||||
table.insert(txt, "\ttypename ArgT" .. idx)
|
||||
end
|
||||
f:write(table.concat(txt, ",\n"))
|
||||
|
||||
-- Write the argument declarations:
|
||||
txt = {}
|
||||
f:write("\n>\nvoid GetStackValues(\n\tint a_BeginPos,\n")
|
||||
for idx = 1, i do
|
||||
table.insert(txt, "\tArgT" .. idx .. " & Arg" .. idx)
|
||||
end
|
||||
f:write(table.concat(txt, ",\n"))
|
||||
|
||||
-- Write the function body:
|
||||
f:write("\n)\n{\n")
|
||||
for idx = 1, i do
|
||||
f:write("\tGetStackValue(a_BeginPos + ", idx - 1, ", Arg", idx, ");\n")
|
||||
end
|
||||
f:write("}\n\n\n\n\n\n")
|
||||
end
|
||||
|
||||
-- Close the generated file
|
||||
f:close()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print("LuaState_Call.inc generated.")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,16 +7,6 @@ local default_private_access = false
|
||||
|
||||
|
||||
|
||||
-- Code generators used by the build
|
||||
-- Note that these are not exactly needed for the bindings, but rather we
|
||||
-- misuse tolua's Lua engine to process files for us
|
||||
dofile("gen_LuaState_Call.lua")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local access = {public = 0, protected = 1, private = 2}
|
||||
|
||||
function preparse_hook(p)
|
||||
|
||||
@@ -160,3 +160,65 @@ bool IsBiomeNoDownfall(EMCSBiome a_Biome)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool IsBiomeVeryCold(EMCSBiome a_Biome)
|
||||
{
|
||||
switch (a_Biome)
|
||||
{
|
||||
case biFrozenOcean:
|
||||
case biFrozenRiver:
|
||||
case biIcePlains:
|
||||
case biIceMountains:
|
||||
case biColdBeach:
|
||||
case biColdTaiga:
|
||||
case biColdTaigaHills:
|
||||
case biIcePlainsSpikes:
|
||||
case biColdTaigaM:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool IsBiomeCold(EMCSBiome a_Biome)
|
||||
{
|
||||
switch (a_Biome)
|
||||
{
|
||||
case biExtremeHills:
|
||||
case biTaiga:
|
||||
case biTaigaHills:
|
||||
case biExtremeHillsEdge:
|
||||
case biStoneBeach:
|
||||
case biMegaTaiga:
|
||||
case biMegaTaigaHills:
|
||||
case biExtremeHillsPlus:
|
||||
case biExtremeHillsM:
|
||||
case biTaigaM:
|
||||
case biColdTaigaM:
|
||||
case biMegaSpruceTaiga:
|
||||
case biMegaSpruceTaigaHills:
|
||||
case biExtremeHillsPlusM:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -113,5 +113,20 @@ extern AString BiomeToString(int a_Biome);
|
||||
/** Returns true if the biome has no downfall - deserts and savannas */
|
||||
extern bool IsBiomeNoDownfall(EMCSBiome a_Biome);
|
||||
|
||||
/** Returns true if the biome is an ocean biome. */
|
||||
inline bool IsBiomeOcean(int a_Biome)
|
||||
{
|
||||
return ((a_Biome == biOcean) || (a_Biome == biDeepOcean));
|
||||
}
|
||||
|
||||
/** Returns true if the biome is very cold
|
||||
(has snow on ground everywhere, turns top water to ice, has snowfall instead of rain everywhere).
|
||||
Doesn't report mildly cold biomes (where it snows above certain elevation), use IsBiomeCold() for those. */
|
||||
extern bool IsBiomeVeryCold(EMCSBiome a_Biome);
|
||||
|
||||
/** Returns true if the biome is cold
|
||||
(has snow and snowfall at higher elevations but not at regular heights).
|
||||
Doesn't report Very Cold biomes, use IsBiomeVeryCold() for those. */
|
||||
extern bool IsBiomeCold(EMCSBiome a_Biome);
|
||||
|
||||
// tolua_end
|
||||
|
||||
@@ -273,10 +273,10 @@ void MergeCombinatorMask(BLOCKTYPE & a_DstType, BLOCKTYPE a_SrcType, NIBBLETYPE
|
||||
// cBlockArea:
|
||||
|
||||
cBlockArea::cBlockArea(void) :
|
||||
m_BlockTypes(NULL),
|
||||
m_BlockMetas(NULL),
|
||||
m_BlockLight(NULL),
|
||||
m_BlockSkyLight(NULL)
|
||||
m_BlockTypes(nullptr),
|
||||
m_BlockMetas(nullptr),
|
||||
m_BlockLight(nullptr),
|
||||
m_BlockSkyLight(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -295,10 +295,10 @@ cBlockArea::~cBlockArea()
|
||||
|
||||
void cBlockArea::Clear(void)
|
||||
{
|
||||
delete[] m_BlockTypes; m_BlockTypes = NULL;
|
||||
delete[] m_BlockMetas; m_BlockMetas = NULL;
|
||||
delete[] m_BlockLight; m_BlockLight = NULL;
|
||||
delete[] m_BlockSkyLight; m_BlockSkyLight = NULL;
|
||||
delete[] m_BlockTypes; m_BlockTypes = nullptr;
|
||||
delete[] m_BlockMetas; m_BlockMetas = nullptr;
|
||||
delete[] m_BlockLight; m_BlockLight = nullptr;
|
||||
delete[] m_BlockSkyLight; m_BlockSkyLight = nullptr;
|
||||
m_Origin.Set(0, 0, 0);
|
||||
m_Size.Set(0, 0, 0);
|
||||
}
|
||||
@@ -711,7 +711,7 @@ void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_R
|
||||
const NIBBLETYPE * SrcMetas = a_Src.GetBlockMetas();
|
||||
NIBBLETYPE * DstMetas = m_BlockMetas;
|
||||
|
||||
bool IsDummyMetas = ((SrcMetas == NULL) || (DstMetas == NULL));
|
||||
bool IsDummyMetas = ((SrcMetas == nullptr) || (DstMetas == nullptr));
|
||||
|
||||
if (IsDummyMetas)
|
||||
{
|
||||
@@ -1013,8 +1013,8 @@ void cBlockArea::RotateCCW(void)
|
||||
} // for x
|
||||
std::swap(m_BlockTypes, NewTypes);
|
||||
std::swap(m_BlockMetas, NewMetas);
|
||||
delete[] NewTypes; NewTypes = NULL;
|
||||
delete[] NewMetas; NewMetas = NULL;
|
||||
delete[] NewTypes; NewTypes = nullptr;
|
||||
delete[] NewMetas; NewMetas = nullptr;
|
||||
|
||||
std::swap(m_Size.x, m_Size.z);
|
||||
}
|
||||
@@ -1058,8 +1058,8 @@ void cBlockArea::RotateCW(void)
|
||||
} // for x
|
||||
std::swap(m_BlockTypes, NewTypes);
|
||||
std::swap(m_BlockMetas, NewMetas);
|
||||
delete[] NewTypes; NewTypes = NULL;
|
||||
delete[] NewMetas; NewMetas = NULL;
|
||||
delete[] NewTypes; NewTypes = nullptr;
|
||||
delete[] NewMetas; NewMetas = nullptr;
|
||||
|
||||
std::swap(m_Size.x, m_Size.z);
|
||||
}
|
||||
@@ -1206,7 +1206,7 @@ void cBlockArea::RotateCCWNoMeta(void)
|
||||
} // for z
|
||||
} // for x
|
||||
std::swap(m_BlockTypes, NewTypes);
|
||||
delete[] NewTypes; NewTypes = NULL;
|
||||
delete[] NewTypes; NewTypes = nullptr;
|
||||
}
|
||||
if (HasBlockMetas())
|
||||
{
|
||||
@@ -1224,7 +1224,7 @@ void cBlockArea::RotateCCWNoMeta(void)
|
||||
} // for z
|
||||
} // for x
|
||||
std::swap(m_BlockMetas, NewMetas);
|
||||
delete[] NewMetas; NewMetas = NULL;
|
||||
delete[] NewMetas; NewMetas = nullptr;
|
||||
}
|
||||
std::swap(m_Size.x, m_Size.z);
|
||||
}
|
||||
@@ -1251,7 +1251,7 @@ void cBlockArea::RotateCWNoMeta(void)
|
||||
} // for x
|
||||
} // for z
|
||||
std::swap(m_BlockTypes, NewTypes);
|
||||
delete[] NewTypes; NewTypes = NULL;
|
||||
delete[] NewTypes; NewTypes = nullptr;
|
||||
}
|
||||
if (HasBlockMetas())
|
||||
{
|
||||
@@ -1269,7 +1269,7 @@ void cBlockArea::RotateCWNoMeta(void)
|
||||
} // for x
|
||||
} // for z
|
||||
std::swap(m_BlockMetas, NewMetas);
|
||||
delete[] NewMetas; NewMetas = NULL;
|
||||
delete[] NewMetas; NewMetas = nullptr;
|
||||
}
|
||||
std::swap(m_Size.x, m_Size.z);
|
||||
}
|
||||
@@ -1391,7 +1391,7 @@ void cBlockArea::MirrorYZNoMeta(void)
|
||||
|
||||
void cBlockArea::SetRelBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
|
||||
{
|
||||
if (m_BlockTypes == NULL)
|
||||
if (m_BlockTypes == nullptr)
|
||||
{
|
||||
LOGWARNING("cBlockArea: BlockTypes have not been read!");
|
||||
return;
|
||||
@@ -1468,7 +1468,7 @@ void cBlockArea::SetBlockSkyLight(int a_BlockX, int a_BlockY, int a_BlockZ, NIBB
|
||||
|
||||
BLOCKTYPE cBlockArea::GetRelBlockType(int a_RelX, int a_RelY, int a_RelZ) const
|
||||
{
|
||||
if (m_BlockTypes == NULL)
|
||||
if (m_BlockTypes == nullptr)
|
||||
{
|
||||
LOGWARNING("cBlockArea: BlockTypes have not been read!");
|
||||
return E_BLOCK_AIR;
|
||||
@@ -1555,7 +1555,7 @@ void cBlockArea::SetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOC
|
||||
void cBlockArea::SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
|
||||
{
|
||||
int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
|
||||
if (m_BlockTypes == NULL)
|
||||
if (m_BlockTypes == nullptr)
|
||||
{
|
||||
LOGWARNING("%s: BlockTypes not available but requested to be written to.", __FUNCTION__);
|
||||
}
|
||||
@@ -1563,7 +1563,7 @@ void cBlockArea::SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, B
|
||||
{
|
||||
m_BlockTypes[idx] = a_BlockType;
|
||||
}
|
||||
if (m_BlockMetas == NULL)
|
||||
if (m_BlockMetas == nullptr)
|
||||
{
|
||||
LOGWARNING("%s: BlockMetas not available but requested to be written to.", __FUNCTION__);
|
||||
}
|
||||
@@ -1589,7 +1589,7 @@ void cBlockArea::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOC
|
||||
void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
|
||||
{
|
||||
int idx = MakeIndex(a_RelX, a_RelY, a_RelZ);
|
||||
if (m_BlockTypes == NULL)
|
||||
if (m_BlockTypes == nullptr)
|
||||
{
|
||||
LOGWARNING("cBlockArea: BlockTypes have not been read!");
|
||||
a_BlockType = E_BLOCK_AIR;
|
||||
@@ -1599,7 +1599,7 @@ void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTY
|
||||
a_BlockType = m_BlockTypes[idx];
|
||||
}
|
||||
|
||||
if (m_BlockMetas == NULL)
|
||||
if (m_BlockMetas == nullptr)
|
||||
{
|
||||
LOGWARNING("cBlockArea: BlockMetas have not been read!");
|
||||
a_BlockMeta = 0;
|
||||
@@ -1617,19 +1617,19 @@ void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTY
|
||||
int cBlockArea::GetDataTypes(void) const
|
||||
{
|
||||
int res = 0;
|
||||
if (m_BlockTypes != NULL)
|
||||
if (m_BlockTypes != nullptr)
|
||||
{
|
||||
res |= baTypes;
|
||||
}
|
||||
if (m_BlockMetas != NULL)
|
||||
if (m_BlockMetas != nullptr)
|
||||
{
|
||||
res |= baMetas;
|
||||
}
|
||||
if (m_BlockLight != NULL)
|
||||
if (m_BlockLight != nullptr)
|
||||
{
|
||||
res |= baLight;
|
||||
}
|
||||
if (m_BlockSkyLight != NULL)
|
||||
if (m_BlockSkyLight != nullptr)
|
||||
{
|
||||
res |= baSkyLight;
|
||||
}
|
||||
@@ -1642,12 +1642,12 @@ int cBlockArea::GetDataTypes(void) const
|
||||
|
||||
bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
|
||||
{
|
||||
ASSERT(m_BlockTypes == NULL); // Has been cleared
|
||||
ASSERT(m_BlockTypes == nullptr); // Has been cleared
|
||||
|
||||
if (a_DataTypes & baTypes)
|
||||
{
|
||||
m_BlockTypes = new BLOCKTYPE[a_SizeX * a_SizeY * a_SizeZ];
|
||||
if (m_BlockTypes == NULL)
|
||||
if (m_BlockTypes == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1655,36 +1655,36 @@ bool cBlockArea::SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
|
||||
if (a_DataTypes & baMetas)
|
||||
{
|
||||
m_BlockMetas = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
|
||||
if (m_BlockMetas == NULL)
|
||||
if (m_BlockMetas == nullptr)
|
||||
{
|
||||
delete[] m_BlockTypes;
|
||||
m_BlockTypes = NULL;
|
||||
m_BlockTypes = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (a_DataTypes & baLight)
|
||||
{
|
||||
m_BlockLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
|
||||
if (m_BlockLight == NULL)
|
||||
if (m_BlockLight == nullptr)
|
||||
{
|
||||
delete[] m_BlockMetas;
|
||||
m_BlockMetas = NULL;
|
||||
m_BlockMetas = nullptr;
|
||||
delete[] m_BlockTypes;
|
||||
m_BlockTypes = NULL;
|
||||
m_BlockTypes = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (a_DataTypes & baSkyLight)
|
||||
{
|
||||
m_BlockSkyLight = new NIBBLETYPE[a_SizeX * a_SizeY * a_SizeZ];
|
||||
if (m_BlockSkyLight == NULL)
|
||||
if (m_BlockSkyLight == nullptr)
|
||||
{
|
||||
delete[] m_BlockLight;
|
||||
m_BlockLight = NULL;
|
||||
m_BlockLight = nullptr;
|
||||
delete[] m_BlockMetas;
|
||||
m_BlockMetas = NULL;
|
||||
m_BlockMetas = nullptr;
|
||||
delete[] m_BlockTypes;
|
||||
m_BlockTypes = NULL;
|
||||
m_BlockTypes = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1714,7 +1714,7 @@ int cBlockArea::MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const
|
||||
|
||||
void cBlockArea::SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array)
|
||||
{
|
||||
if (a_Array == NULL)
|
||||
if (a_Array == nullptr)
|
||||
{
|
||||
LOGWARNING("cBlockArea: datatype has not been read!");
|
||||
return;
|
||||
@@ -1737,7 +1737,7 @@ void cBlockArea::SetNibble(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE
|
||||
|
||||
NIBBLETYPE cBlockArea::GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const
|
||||
{
|
||||
if (a_Array == NULL)
|
||||
if (a_Array == nullptr)
|
||||
{
|
||||
LOGWARNING("cBlockArea: datatype has not been read!");
|
||||
return 16;
|
||||
@@ -1896,7 +1896,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
|
||||
}
|
||||
|
||||
// Copy the blocktypes:
|
||||
if (m_Area.m_BlockTypes != NULL)
|
||||
if (m_Area.m_BlockTypes != nullptr)
|
||||
{
|
||||
for (int y = 0; y < SizeY; y++)
|
||||
{
|
||||
@@ -1917,7 +1917,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
|
||||
}
|
||||
|
||||
// Copy the block metas:
|
||||
if (m_Area.m_BlockMetas != NULL)
|
||||
if (m_Area.m_BlockMetas != nullptr)
|
||||
{
|
||||
for (int y = 0; y < SizeY; y++)
|
||||
{
|
||||
@@ -1938,7 +1938,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
|
||||
}
|
||||
|
||||
// Copy the blocklight:
|
||||
if (m_Area.m_BlockLight != NULL)
|
||||
if (m_Area.m_BlockLight != nullptr)
|
||||
{
|
||||
for (int y = 0; y < SizeY; y++)
|
||||
{
|
||||
@@ -1959,7 +1959,7 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
|
||||
}
|
||||
|
||||
// Copy the skylight:
|
||||
if (m_Area.m_BlockSkyLight != NULL)
|
||||
if (m_Area.m_BlockSkyLight != nullptr)
|
||||
{
|
||||
for (int y = 0; y < SizeY; y++)
|
||||
{
|
||||
|
||||
@@ -282,10 +282,10 @@ public:
|
||||
/** Returns the datatypes that are stored in the object (bitmask of baXXX values) */
|
||||
int GetDataTypes(void) const;
|
||||
|
||||
bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); }
|
||||
bool HasBlockMetas (void) const { return (m_BlockMetas != NULL); }
|
||||
bool HasBlockLights (void) const { return (m_BlockLight != NULL); }
|
||||
bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != NULL); }
|
||||
bool HasBlockTypes (void) const { return (m_BlockTypes != nullptr); }
|
||||
bool HasBlockMetas (void) const { return (m_BlockMetas != nullptr); }
|
||||
bool HasBlockLights (void) const { return (m_BlockLight != nullptr); }
|
||||
bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != nullptr); }
|
||||
|
||||
// tolua_end
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ bool cBeaconEntity::SetPrimaryEffect(cEntityEffect::eType a_Effect)
|
||||
m_PrimaryEffect = a_Effect;
|
||||
|
||||
// Send window update:
|
||||
if (GetWindow() != NULL)
|
||||
if (GetWindow() != nullptr)
|
||||
{
|
||||
GetWindow()->SetProperty(1, m_PrimaryEffect);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ bool cBeaconEntity::SetSecondaryEffect(cEntityEffect::eType a_Effect)
|
||||
m_SecondaryEffect = a_Effect;
|
||||
|
||||
// Send window update:
|
||||
if (GetWindow() != NULL)
|
||||
if (GetWindow() != nullptr)
|
||||
{
|
||||
GetWindow()->SetProperty(2, m_SecondaryEffect);
|
||||
}
|
||||
@@ -184,7 +184,7 @@ void cBeaconEntity::UpdateBeacon(void)
|
||||
if (m_BeaconLevel != OldBeaconLevel)
|
||||
{
|
||||
// Send window update:
|
||||
if (GetWindow() != NULL)
|
||||
if (GetWindow() != nullptr)
|
||||
{
|
||||
GetWindow()->SetProperty(0, m_BeaconLevel);
|
||||
}
|
||||
@@ -283,13 +283,13 @@ bool cBeaconEntity::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
void cBeaconEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
cWindow * Window = GetWindow();
|
||||
if (Window == NULL)
|
||||
if (Window == nullptr)
|
||||
{
|
||||
OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this));
|
||||
Window = GetWindow();
|
||||
}
|
||||
|
||||
if (Window != NULL)
|
||||
if (Window != nullptr)
|
||||
{
|
||||
// if (a_Player->GetWindow() != Window)
|
||||
// -> Because mojang doesn't send a 'close window' packet when you click the cancel button in the beacon inventory ...
|
||||
@@ -303,68 +303,6 @@ void cBeaconEntity::UsedBy(cPlayer * a_Player)
|
||||
|
||||
|
||||
|
||||
bool cBeaconEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
Json::Value AllSlots = a_Value.get("Slots", 0);
|
||||
int SlotIdx = 0;
|
||||
for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
|
||||
{
|
||||
cItem Item;
|
||||
Item.FromJson(*itr);
|
||||
SetSlot(SlotIdx, Item);
|
||||
SlotIdx++;
|
||||
}
|
||||
|
||||
m_BeaconLevel = (char)a_Value.get("Level", 0).asInt();
|
||||
int PrimaryEffect = a_Value.get("PrimaryEffect", 0).asInt();
|
||||
int SecondaryEffect = a_Value.get("SecondaryEffect", 0).asInt();
|
||||
|
||||
if ((PrimaryEffect >= 0) && (PrimaryEffect <= (int)cEntityEffect::effSaturation))
|
||||
{
|
||||
m_PrimaryEffect = (cEntityEffect::eType)PrimaryEffect;
|
||||
}
|
||||
|
||||
if ((SecondaryEffect >= 0) && (SecondaryEffect <= (int)cEntityEffect::effSaturation))
|
||||
{
|
||||
m_SecondaryEffect = (cEntityEffect::eType)SecondaryEffect;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBeaconEntity::SaveToJson(Json::Value& a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
Json::Value AllSlots;
|
||||
int NumSlots = m_Contents.GetNumSlots();
|
||||
for (int i = 0; i < NumSlots; i++)
|
||||
{
|
||||
Json::Value Slot;
|
||||
m_Contents.GetSlot(i).GetJson(Slot);
|
||||
AllSlots.append(Slot);
|
||||
}
|
||||
a_Value["Slots"] = AllSlots;
|
||||
|
||||
a_Value["Level"] = m_BeaconLevel;
|
||||
a_Value["PrimaryEffect"] = (int)m_PrimaryEffect;
|
||||
a_Value["SecondaryEffect"] = (int)m_SecondaryEffect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBeaconEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendUpdateBlockEntity(*this);
|
||||
|
||||
@@ -32,11 +32,11 @@ class cBeaconEntity :
|
||||
public:
|
||||
// tolua_end
|
||||
|
||||
BLOCKENTITY_PROTODEF(cBeaconEntity);
|
||||
|
||||
cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
// cBlockEntity overrides:
|
||||
virtual void SaveToJson(Json::Value& a_Value) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
|
||||
@@ -50,7 +50,7 @@ cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE
|
||||
__FUNCTION__, a_BlockType, ItemTypeToString(a_BlockType).c_str()
|
||||
);
|
||||
ASSERT(!"Requesting creation of an unknown block entity");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,28 @@
|
||||
|
||||
|
||||
|
||||
/** Place this macro in the declaration of each cBlockEntity descendant. */
|
||||
#define BLOCKENTITY_PROTODEF(classname) \
|
||||
virtual bool IsA(const char * a_ClassName) const override \
|
||||
{ \
|
||||
return ((strcmp(a_ClassName, #classname) == 0) || super::IsA(a_ClassName)); \
|
||||
} \
|
||||
virtual const char * GetClass(void) const override \
|
||||
{ \
|
||||
return #classname; \
|
||||
} \
|
||||
static const char * GetClassStatic(void) \
|
||||
{ \
|
||||
return #classname; \
|
||||
} \
|
||||
virtual const char * GetParentClass(void) const override \
|
||||
{ \
|
||||
return super::GetClass(); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Json
|
||||
{
|
||||
@@ -48,13 +70,22 @@ public:
|
||||
|
||||
/// 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);
|
||||
/// Returns nullptr 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 = nullptr);
|
||||
|
||||
static const char * GetClassStatic(void) // Needed for ManualBindings's ForEach templates
|
||||
{
|
||||
return "cBlockEntity";
|
||||
}
|
||||
|
||||
/** Returns true if the object is the specified class, or its descendant. */
|
||||
virtual bool IsA(const char * a_ClassName) const { return (strcmp(a_ClassName, "cBlockEntity") == 0); }
|
||||
|
||||
/** Returns the name of the tompost class (the most descendant). Used for Lua bindings to push the correct object type. */
|
||||
virtual const char * GetClass(void) const { return GetClassStatic(); }
|
||||
|
||||
/** Returns the name of the parent class, or empty string if no parent class. */
|
||||
virtual const char * GetParentClass(void) const { return ""; }
|
||||
|
||||
// tolua_begin
|
||||
|
||||
@@ -74,8 +105,6 @@ public:
|
||||
int GetRelZ(void) const { return m_RelZ; }
|
||||
|
||||
// tolua_end
|
||||
|
||||
virtual void SaveToJson (Json::Value & a_Value) = 0;
|
||||
|
||||
/// Called when a player uses this entity; should open the UI window
|
||||
virtual void UsedBy( cPlayer * a_Player) = 0;
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
|
||||
// tolua_begin
|
||||
class cBlockEntityWithItems :
|
||||
public cBlockEntity
|
||||
// tolua_end
|
||||
// tolua doesn't seem to support multiple inheritance?
|
||||
, public cItemGrid::cListener
|
||||
, public cBlockEntityWindowOwner
|
||||
// tolua_begin
|
||||
public cBlockEntity,
|
||||
public cItemGrid::cListener,
|
||||
public cBlockEntityWindowOwner
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
|
||||
|
||||
public:
|
||||
// tolua_end
|
||||
|
||||
BLOCKENTITY_PROTODEF(cBlockEntityWithItems);
|
||||
|
||||
cBlockEntityWithItems(
|
||||
BLOCKTYPE a_BlockType, // Type of the block that the entity represents
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, // Position of the block entity
|
||||
@@ -39,6 +38,7 @@ public:
|
||||
cWorld * a_World // Optional world to assign to the entity
|
||||
) :
|
||||
super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World),
|
||||
cBlockEntityWindowOwner(this),
|
||||
m_Contents(a_ItemGridWidth, a_ItemGridHeight)
|
||||
{
|
||||
m_Contents.AddListener(*this);
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
virtual void Destroy(void) override
|
||||
{
|
||||
// Drop the contents as pickups:
|
||||
ASSERT(m_World != NULL);
|
||||
ASSERT(m_World != nullptr);
|
||||
cItems Pickups;
|
||||
m_Contents.CopyToItems(Pickups);
|
||||
m_Contents.Clear();
|
||||
@@ -78,9 +78,9 @@ protected:
|
||||
{
|
||||
UNUSED(a_SlotNum);
|
||||
ASSERT(a_Grid == &m_Contents);
|
||||
if (m_World != NULL)
|
||||
if (m_World != nullptr)
|
||||
{
|
||||
if (GetWindow() != NULL)
|
||||
if (GetWindow() != nullptr)
|
||||
{
|
||||
GetWindow()->BroadcastWholeWindow();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_
|
||||
super(a_Type, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
|
||||
m_NumActivePlayers(0)
|
||||
{
|
||||
cBlockEntityWindowOwner::SetBlockEntity(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +23,7 @@ cChestEntity::cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_
|
||||
cChestEntity::~cChestEntity()
|
||||
{
|
||||
cWindow * Window = GetWindow();
|
||||
if (Window != NULL)
|
||||
if (Window != nullptr)
|
||||
{
|
||||
Window->OwnerDestroyed();
|
||||
}
|
||||
@@ -34,48 +33,6 @@ cChestEntity::~cChestEntity()
|
||||
|
||||
|
||||
|
||||
bool cChestEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
Json::Value AllSlots = a_Value.get("Slots", 0);
|
||||
int SlotIdx = 0;
|
||||
for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
|
||||
{
|
||||
cItem Item;
|
||||
Item.FromJson(*itr);
|
||||
SetSlot(SlotIdx, Item);
|
||||
SlotIdx++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChestEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
Json::Value AllSlots;
|
||||
for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
|
||||
{
|
||||
Json::Value Slot;
|
||||
m_Contents.GetSlot(i).GetJson(Slot);
|
||||
AllSlots.append(Slot);
|
||||
}
|
||||
a_Value["Slots"] = AllSlots;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChestEntity::SendTo(cClientHandle & a_Client)
|
||||
{
|
||||
// The chest entity doesn't need anything sent to the client when it's created / gets in the viewdistance
|
||||
@@ -92,14 +49,14 @@ void cChestEntity::UsedBy(cPlayer * a_Player)
|
||||
{
|
||||
// If the window is not created, open it anew:
|
||||
cWindow * Window = GetWindow();
|
||||
if (Window == NULL)
|
||||
if (Window == nullptr)
|
||||
{
|
||||
OpenNewWindow();
|
||||
Window = GetWindow();
|
||||
}
|
||||
|
||||
// Open the window for the player:
|
||||
if (Window != NULL)
|
||||
if (Window != nullptr)
|
||||
{
|
||||
if (a_Player->GetWindow() != Window)
|
||||
{
|
||||
|
||||
@@ -33,17 +33,14 @@ public:
|
||||
|
||||
// tolua_end
|
||||
|
||||
BLOCKENTITY_PROTODEF(cChestEntity);
|
||||
|
||||
/** Constructor used for normal operation */
|
||||
cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type);
|
||||
|
||||
virtual ~cChestEntity();
|
||||
|
||||
static const char * GetClassStatic(void) { return "cChestEntity"; }
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
|
||||
// cBlockEntity overrides:
|
||||
virtual void SaveToJson(Json::Value & a_Value) override;
|
||||
virtual void SendTo(cClientHandle & a_Client) override;
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
|
||||
|
||||
@@ -152,41 +152,9 @@ void cCommandBlockEntity::SendTo(cClientHandle & a_Client)
|
||||
|
||||
|
||||
|
||||
bool cCommandBlockEntity::LoadFromJson(const Json::Value & a_Value)
|
||||
{
|
||||
m_PosX = a_Value.get("x", 0).asInt();
|
||||
m_PosY = a_Value.get("y", 0).asInt();
|
||||
m_PosZ = a_Value.get("z", 0).asInt();
|
||||
|
||||
m_Command = a_Value.get("Command", "").asString();
|
||||
m_LastOutput = a_Value.get("LastOutput", "").asString();
|
||||
m_Result = (NIBBLETYPE)a_Value.get("SuccessCount", 0).asInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cCommandBlockEntity::SaveToJson(Json::Value & a_Value)
|
||||
{
|
||||
a_Value["x"] = m_PosX;
|
||||
a_Value["y"] = m_PosY;
|
||||
a_Value["z"] = m_PosZ;
|
||||
|
||||
a_Value["Command"] = m_Command;
|
||||
a_Value["LastOutput"] = m_LastOutput;
|
||||
a_Value["SuccessCount"] = m_Result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cCommandBlockEntity::Execute()
|
||||
{
|
||||
ASSERT(m_World != NULL); // Execute should not be called before the command block is attached to a world
|
||||
ASSERT(m_World != nullptr); // Execute should not be called before the command block is attached to a world
|
||||
|
||||
if (!m_World->AreCommandBlocksEnabled())
|
||||
{
|
||||
|
||||