1
0
This commit is contained in:
Tiger Wang 2014-10-19 12:34:05 +01:00
commit cc600de51f
39 changed files with 260 additions and 496 deletions

View File

@ -37,14 +37,12 @@ SET (HDRS
set (BINDING_OUTPUTS set (BINDING_OUTPUTS
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Call.inc
) )
set(BINDING_DEPENDENCIES set(BINDING_DEPENDENCIES
tolua tolua
../Bindings/virtual_method_hooks.lua ../Bindings/virtual_method_hooks.lua
../Bindings/AllToLua.pkg ../Bindings/AllToLua.pkg
../Bindings/gen_LuaState_Call.lua
../Bindings/LuaFunctions.h ../Bindings/LuaFunctions.h
../Bindings/LuaWindow.h ../Bindings/LuaWindow.h
../Bindings/Plugin.h ../Bindings/Plugin.h
@ -127,7 +125,6 @@ if (NOT MSVC)
endif () 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.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/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) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)

View File

@ -16,6 +16,8 @@ extern "C"
#include "Bindings.h" #include "Bindings.h"
#include "ManualBindings.h" #include "ManualBindings.h"
#include "DeprecatedBindings.h" #include "DeprecatedBindings.h"
#include "../Entities/Entity.h"
#include "../BlockEntities/BlockEntity.h"
// fwd: SQLite/lsqlite3.c // fwd: SQLite/lsqlite3.c
extern "C" extern "C"
@ -520,7 +522,7 @@ void cLuaState::Push(cBlockEntity * a_BlockEntity)
{ {
ASSERT(IsValid()); 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; m_NumCurrentFunctionArgs += 1;
} }
@ -556,7 +558,16 @@ void cLuaState::Push(cEntity * a_Entity)
{ {
ASSERT(IsValid()); ASSERT(IsValid());
tolua_pushusertype(m_LuaState, a_Entity, "cEntity"); if (a_Entity->IsMob())
{
// Don't push specific mob types, as those are not exported in the API:
tolua_pushusertype(m_LuaState, a_Entity, "cMonster");
}
else
{
// Push the specific class type:
tolua_pushusertype(m_LuaState, a_Entity, (a_Entity == nullptr) ? "cEntity" : a_Entity->GetClass());
}
m_NumCurrentFunctionArgs += 1; m_NumCurrentFunctionArgs += 1;
} }

View File

@ -34,7 +34,7 @@ static int tolua_cRankManager_AddGroup(lua_State * L)
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Add the group: // Add the group:
cRoot::Get()->GetRankManager().AddGroup(GroupName); cRoot::Get()->GetRankManager()->AddGroup(GroupName);
return 0; return 0;
} }
@ -63,7 +63,7 @@ static int tolua_cRankManager_AddGroupToRank(lua_State * L)
S.GetStackValues(2, GroupName, RankName); S.GetStackValues(2, GroupName, RankName);
// Add the group to the rank: // Add the group to the rank:
S.Push(cRoot::Get()->GetRankManager().AddGroupToRank(GroupName, RankName)); S.Push(cRoot::Get()->GetRankManager()->AddGroupToRank(GroupName, RankName));
return 1; return 1;
} }
@ -92,7 +92,7 @@ static int tolua_cRankManager_AddPermissionToGroup(lua_State * L)
S.GetStackValues(2, Permission, GroupName); S.GetStackValues(2, Permission, GroupName);
// Add the group to the rank: // Add the group to the rank:
S.Push(cRoot::Get()->GetRankManager().AddPermissionToGroup(Permission, GroupName)); S.Push(cRoot::Get()->GetRankManager()->AddPermissionToGroup(Permission, GroupName));
return 1; return 1;
} }
@ -121,7 +121,7 @@ static int tolua_cRankManager_AddRank(lua_State * L)
S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode); S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
// Add the rank: // Add the rank:
cRoot::Get()->GetRankManager().AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode); cRoot::Get()->GetRankManager()->AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
return 0; return 0;
} }
@ -142,7 +142,7 @@ static int tolua_cRankManager_ClearPlayerRanks(lua_State * L)
} }
// Remove all players: // Remove all players:
cRoot::Get()->GetRankManager().ClearPlayerRanks(); cRoot::Get()->GetRankManager()->ClearPlayerRanks();
return 1; return 1;
} }
@ -166,7 +166,7 @@ static int tolua_cRankManager_GetAllGroups(lua_State * L)
} }
// Get the groups: // Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager().GetAllGroups(); AStringVector Groups = cRoot::Get()->GetRankManager()->GetAllGroups();
// Push the results: // Push the results:
S.Push(Groups); S.Push(Groups);
@ -193,7 +193,7 @@ static int tolua_cRankManager_GetAllPermissions(lua_State * L)
} }
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager().GetAllPermissions(); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetAllPermissions();
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
@ -220,7 +220,7 @@ static int tolua_cRankManager_GetAllPlayerUUIDs(lua_State * L)
} }
// Get the player uuid's: // Get the player uuid's:
AStringVector Players = cRoot::Get()->GetRankManager().GetAllPlayerUUIDs(); AStringVector Players = cRoot::Get()->GetRankManager()->GetAllPlayerUUIDs();
// Push the results: // Push the results:
S.Push(Players); S.Push(Players);
@ -247,7 +247,7 @@ static int tolua_cRankManager_GetAllRanks(lua_State * L)
} }
// Get the ranks: // Get the ranks:
AStringVector Ranks = cRoot::Get()->GetRankManager().GetAllRanks(); AStringVector Ranks = cRoot::Get()->GetRankManager()->GetAllRanks();
// Push the results: // Push the results:
S.Push(Ranks); S.Push(Ranks);
@ -274,7 +274,7 @@ static int tolua_cRankManager_GetDefaultRank(lua_State * L)
} }
// Return the rank name: // Return the rank name:
S.Push(cRoot::Get()->GetRankManager().GetDefaultRank()); S.Push(cRoot::Get()->GetRankManager()->GetDefaultRank());
return 1; return 1;
} }
@ -303,7 +303,7 @@ static int tolua_cRankManager_GetGroupPermissions(lua_State * L)
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager().GetGroupPermissions(GroupName); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetGroupPermissions(GroupName);
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
@ -335,7 +335,7 @@ static int tolua_cRankManager_GetPlayerGroups(lua_State * L)
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the groups: // Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager().GetPlayerGroups(PlayerUUID); AStringVector Groups = cRoot::Get()->GetRankManager()->GetPlayerGroups(PlayerUUID);
// Push the results: // Push the results:
S.Push(Groups); S.Push(Groups);
@ -368,7 +368,7 @@ static int tolua_cRankManager_GetPlayerMsgVisuals(lua_State * L)
// Get the permissions: // Get the permissions:
AString MsgPrefix, MsgSuffix, MsgNameColorCode; AString MsgPrefix, MsgSuffix, MsgNameColorCode;
if (!cRoot::Get()->GetRankManager().GetPlayerMsgVisuals(PlayerUUID, MsgPrefix, MsgSuffix, MsgNameColorCode)) if (!cRoot::Get()->GetRankManager()->GetPlayerMsgVisuals(PlayerUUID, MsgPrefix, MsgSuffix, MsgNameColorCode))
{ {
return 0; return 0;
} }
@ -405,7 +405,7 @@ static int tolua_cRankManager_GetPlayerPermissions(lua_State * L)
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager().GetPlayerPermissions(PlayerUUID); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetPlayerPermissions(PlayerUUID);
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
@ -437,7 +437,7 @@ static int tolua_cRankManager_GetPlayerRankName(lua_State * L)
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the rank name: // Get the rank name:
AString RankName = cRoot::Get()->GetRankManager().GetPlayerRankName(PlayerUUID); AString RankName = cRoot::Get()->GetRankManager()->GetPlayerRankName(PlayerUUID);
// Push the result: // Push the result:
S.Push(RankName); S.Push(RankName);
@ -469,7 +469,7 @@ static int tolua_cRankManager_GetPlayerName(lua_State * L)
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the player name: // Get the player name:
AString PlayerName = cRoot::Get()->GetRankManager().GetPlayerName(PlayerUUID); AString PlayerName = cRoot::Get()->GetRankManager()->GetPlayerName(PlayerUUID);
// Push the result: // Push the result:
S.Push(PlayerName); S.Push(PlayerName);
@ -501,7 +501,7 @@ static int tolua_cRankManager_GetRankGroups(lua_State * L)
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Get the groups: // Get the groups:
AStringVector Groups = cRoot::Get()->GetRankManager().GetRankGroups(RankName); AStringVector Groups = cRoot::Get()->GetRankManager()->GetRankGroups(RankName);
// Push the results: // Push the results:
S.Push(Groups); S.Push(Groups);
@ -533,7 +533,7 @@ static int tolua_cRankManager_GetRankPermissions(lua_State * L)
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Get the permissions: // Get the permissions:
AStringVector Permissions = cRoot::Get()->GetRankManager().GetRankPermissions(RankName); AStringVector Permissions = cRoot::Get()->GetRankManager()->GetRankPermissions(RankName);
// Push the results: // Push the results:
S.Push(Permissions); S.Push(Permissions);
@ -566,7 +566,7 @@ static int tolua_cRankManager_GetRankVisuals(lua_State * L)
// Get the visuals: // Get the visuals:
AString MsgPrefix, MsgSuffix, MsgNameColorCode; 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: // No such rank, return nothing:
return 0; return 0;
@ -604,7 +604,7 @@ static int tolua_cRankManager_GroupExists(lua_State * L)
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager().GroupExists(GroupName); bool res = cRoot::Get()->GetRankManager()->GroupExists(GroupName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
@ -636,7 +636,7 @@ static int tolua_cRankManager_IsGroupInRank(lua_State * L)
S.GetStackValues(2, GroupName, RankName); S.GetStackValues(2, GroupName, RankName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager().IsGroupInRank(GroupName, RankName); bool res = cRoot::Get()->GetRankManager()->IsGroupInRank(GroupName, RankName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
@ -668,7 +668,7 @@ static int tolua_cRankManager_IsPermissionInGroup(lua_State * L)
S.GetStackValues(2, Permission, GroupName); S.GetStackValues(2, Permission, GroupName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager().IsPermissionInGroup(Permission, GroupName); bool res = cRoot::Get()->GetRankManager()->IsPermissionInGroup(Permission, GroupName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
@ -700,7 +700,7 @@ static int tolua_cRankManager_IsPlayerRankSet(lua_State * L)
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager().IsPlayerRankSet(PlayerUUID); bool res = cRoot::Get()->GetRankManager()->IsPlayerRankSet(PlayerUUID);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
@ -732,7 +732,7 @@ static int tolua_cRankManager_RankExists(lua_State * L)
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Get the response: // Get the response:
bool res = cRoot::Get()->GetRankManager().RankExists(RankName); bool res = cRoot::Get()->GetRankManager()->RankExists(RankName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
@ -764,7 +764,7 @@ static int tolua_cRankManager_RemoveGroup(lua_State * L)
S.GetStackValue(2, GroupName); S.GetStackValue(2, GroupName);
// Remove the group: // Remove the group:
cRoot::Get()->GetRankManager().RemoveGroup(GroupName); cRoot::Get()->GetRankManager()->RemoveGroup(GroupName);
return 0; return 0;
} }
@ -793,7 +793,7 @@ static int tolua_cRankManager_RemoveGroupFromRank(lua_State * L)
S.GetStackValues(2, GroupName, RankName); S.GetStackValues(2, GroupName, RankName);
// Remove the group: // Remove the group:
cRoot::Get()->GetRankManager().RemoveGroupFromRank(GroupName, RankName); cRoot::Get()->GetRankManager()->RemoveGroupFromRank(GroupName, RankName);
return 0; return 0;
} }
@ -822,7 +822,7 @@ static int tolua_cRankManager_RemovePermissionFromGroup(lua_State * L)
S.GetStackValues(2, Permission, GroupName); S.GetStackValues(2, Permission, GroupName);
// Remove the group: // Remove the group:
cRoot::Get()->GetRankManager().RemovePermissionFromGroup(Permission, GroupName); cRoot::Get()->GetRankManager()->RemovePermissionFromGroup(Permission, GroupName);
return 0; return 0;
} }
@ -851,7 +851,7 @@ static int tolua_cRankManager_RemovePlayerRank(lua_State * L)
S.GetStackValue(2, PlayerUUID); S.GetStackValue(2, PlayerUUID);
// Remove the player's rank: // Remove the player's rank:
cRoot::Get()->GetRankManager().RemovePlayerRank(PlayerUUID); cRoot::Get()->GetRankManager()->RemovePlayerRank(PlayerUUID);
return 0; return 0;
} }
@ -881,7 +881,7 @@ static int tolua_cRankManager_RemoveRank(lua_State * L)
S.GetStackValues(2, RankName, ReplacementRankName); S.GetStackValues(2, RankName, ReplacementRankName);
// Remove the rank: // Remove the rank:
cRoot::Get()->GetRankManager().RemoveRank(RankName, ReplacementRankName); cRoot::Get()->GetRankManager()->RemoveRank(RankName, ReplacementRankName);
return 0; return 0;
} }
@ -910,7 +910,7 @@ static int tolua_cRankManager_RenameGroup(lua_State * L)
S.GetStackValues(2, OldName, NewName); S.GetStackValues(2, OldName, NewName);
// Remove the group: // Remove the group:
bool res = cRoot::Get()->GetRankManager().RenameGroup(OldName, NewName); bool res = cRoot::Get()->GetRankManager()->RenameGroup(OldName, NewName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
@ -942,7 +942,7 @@ static int tolua_cRankManager_RenameRank(lua_State * L)
S.GetStackValues(2, OldName, NewName); S.GetStackValues(2, OldName, NewName);
// Remove the rank: // Remove the rank:
bool res = cRoot::Get()->GetRankManager().RenameRank(OldName, NewName); bool res = cRoot::Get()->GetRankManager()->RenameRank(OldName, NewName);
// Push the result: // Push the result:
S.Push(res); S.Push(res);
@ -974,7 +974,7 @@ static int tolua_cRankManager_SetDefaultRank(lua_State * L)
S.GetStackValue(2, RankName); S.GetStackValue(2, RankName);
// Set the rank, return the result: // Set the rank, return the result:
S.Push(cRoot::Get()->GetRankManager().SetDefaultRank(RankName)); S.Push(cRoot::Get()->GetRankManager()->SetDefaultRank(RankName));
return 1; return 1;
} }
@ -1003,7 +1003,7 @@ static int tolua_cRankManager_SetPlayerRank(lua_State * L)
S.GetStackValues(2, PlayerUUID, PlayerName, RankName); S.GetStackValues(2, PlayerUUID, PlayerName, RankName);
// Set the rank: // Set the rank:
cRoot::Get()->GetRankManager().SetPlayerRank(PlayerUUID, PlayerName, RankName); cRoot::Get()->GetRankManager()->SetPlayerRank(PlayerUUID, PlayerName, RankName);
return 0; return 0;
} }
@ -1032,7 +1032,7 @@ static int tolua_cRankManager_SetRankVisuals(lua_State * L)
S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode); S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
// Set the visuals: // Set the visuals:
cRoot::Get()->GetRankManager().SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode); cRoot::Get()->GetRankManager()->SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
return 0; return 0;
} }

View File

@ -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.")

View File

@ -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} local access = {public = 0, protected = 1, private = 2}
function preparse_hook(p) function preparse_hook(p)

View File

@ -32,6 +32,8 @@ class cBeaconEntity :
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cBeaconEntity);
cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
// cBlockEntity overrides: // cBlockEntity overrides:

View File

@ -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 namespace Json
{ {
@ -55,6 +77,15 @@ public:
{ {
return "cBlockEntity"; 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 // tolua_begin

View File

@ -25,10 +25,12 @@ class cBlockEntityWithItems :
public cBlockEntityWindowOwner public cBlockEntityWindowOwner
{ {
typedef cBlockEntity super; typedef cBlockEntity super;
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cBlockEntityWithItems);
cBlockEntityWithItems( cBlockEntityWithItems(
BLOCKTYPE a_BlockType, // Type of the block that the entity represents 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 int a_BlockX, int a_BlockY, int a_BlockZ, // Position of the block entity

View File

@ -33,13 +33,13 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cChestEntity);
/** Constructor used for normal operation */ /** Constructor used for normal operation */
cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type); cChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World, BLOCKTYPE a_Type);
virtual ~cChestEntity(); virtual ~cChestEntity();
static const char * GetClassStatic(void) { return "cChestEntity"; }
// cBlockEntity overrides: // cBlockEntity overrides:
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;
virtual void UsedBy(cPlayer * a_Player) override; virtual void UsedBy(cPlayer * a_Player) override;

View File

@ -36,6 +36,8 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cCommandBlockEntity);
/// Creates a new empty command block entity /// Creates a new empty command block entity
cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World); cCommandBlockEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);

View File

@ -17,11 +17,11 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cDispenserEntity);
/** Constructor used for normal operation */ /** Constructor used for normal operation */
cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cDispenserEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
static const char * GetClassStatic(void) { return "cDispenserEntity"; }
// tolua_begin // tolua_begin
/** Spawns a projectile of the given kind in front of the dispenser with the specified speed. */ /** Spawns a projectile of the given kind in front of the dispenser with the specified speed. */

View File

@ -45,11 +45,11 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cDropSpenserEntity);
cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cDropSpenserEntity(); virtual ~cDropSpenserEntity();
static const char * GetClassStatic(void) { return "cDropSpenserEntity"; }
// cBlockEntity overrides: // cBlockEntity overrides:
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override; virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;

View File

@ -25,11 +25,11 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cDropperEntity);
/// Constructor used for normal operation /// Constructor used for normal operation
cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cDropperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
static const char * GetClassStatic(void) { return "cDropperEntity"; }
protected: protected:
// cDropSpenserEntity overrides: // cDropSpenserEntity overrides:
virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override; virtual void DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum) override;

View File

@ -18,11 +18,11 @@ class cEnderChestEntity :
public: public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cEnderChestEntity);
cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cEnderChestEntity(); virtual ~cEnderChestEntity();
static const char * GetClassStatic(void) { return "cEnderChestEntity"; }
// cBlockEntity overrides: // cBlockEntity overrides:
virtual void UsedBy(cPlayer * a_Player) override; virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override { UNUSED(a_Client); } virtual void SendTo(cClientHandle & a_Client) override { UNUSED(a_Client); }

View File

@ -36,6 +36,8 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cFlowerPotEntity);
/** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */ /** Creates a new flowerpot entity at the specified block coords. a_World may be NULL */
cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World); cFlowerPotEntity(int a_BlocX, int a_BlockY, int a_BlockZ, cWorld * a_World);
@ -59,8 +61,6 @@ public:
static bool IsFlower(short m_ItemType, short m_ItemData); static bool IsFlower(short m_ItemType, short m_ItemData);
static const char * GetClassStatic(void) { return "cFlowerPotEntity"; }
private: private:
cItem m_Item; cItem m_Item;

View File

@ -5,6 +5,7 @@
#include "../UI/Window.h" #include "../UI/Window.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"
#include "../Root.h" #include "../Root.h"
#include "../Chunk.h"
@ -13,8 +14,9 @@
enum enum
{ {
PROGRESSBAR_SMELTING = 0, PROGRESSBAR_FUEL = 0,
PROGRESSBAR_FUEL = 1, PROGRESSBAR_SMELTING = 2,
PROGRESSBAR_SMELTING_CONFIRM = 3,
} ; } ;
@ -22,17 +24,15 @@ enum
cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World) : cFurnaceEntity::cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World) :
super(E_BLOCK_FURNACE, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World), super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
m_BlockType(a_BlockType),
m_BlockMeta(a_BlockMeta), m_BlockMeta(a_BlockMeta),
m_CurrentRecipe(NULL), m_CurrentRecipe(NULL),
m_IsCooking((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_LIT_FURNACE)), m_IsDestroyed(false),
m_IsCooking(a_BlockType == E_BLOCK_LIT_FURNACE),
m_NeedCookTime(0), m_NeedCookTime(0),
m_TimeCooked(0), m_TimeCooked(0),
m_FuelBurnTime(0), m_FuelBurnTime(0),
m_TimeBurned(0), m_TimeBurned(0)
m_LastProgressFuel(0),
m_LastProgressCook(0)
{ {
m_Contents.AddListener(*this); m_Contents.AddListener(*this);
} }
@ -57,27 +57,28 @@ cFurnaceEntity::~cFurnaceEntity()
void cFurnaceEntity::UsedBy(cPlayer * a_Player) void cFurnaceEntity::UsedBy(cPlayer * a_Player)
{ {
if (GetWindow() == NULL) cWindow * Window = GetWindow();
if (Window == nullptr)
{ {
OpenWindow(new cFurnaceWindow(m_PosX, m_PosY, m_PosZ, this)); OpenWindow(new cFurnaceWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow();
} }
cWindow * Window = GetWindow();
if (Window != NULL) if (Window != nullptr)
{ {
if (a_Player->GetWindow() != Window) if (a_Player->GetWindow() != Window)
{ {
a_Player->OpenWindow(Window); a_Player->OpenWindow(Window);
BroadcastProgress(PROGRESSBAR_FUEL, (short)m_LastProgressFuel);
BroadcastProgress(PROGRESSBAR_SMELTING, (short)m_LastProgressCook);
} }
} }
UpdateProgressBars(true);
} }
/// Restarts cooking. Used after the furnace is loaded from storage to set up the internal variables so that cooking continues, if it was active. Returns true if cooking.
bool cFurnaceEntity::ContinueCooking(void) bool cFurnaceEntity::ContinueCooking(void)
{ {
UpdateInput(); UpdateInput();
@ -92,14 +93,16 @@ bool cFurnaceEntity::ContinueCooking(void)
bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk) bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk)
{ {
UNUSED(a_Dt); UNUSED(a_Dt);
UNUSED(a_Chunk);
if (m_FuelBurnTime <= 0) if (m_FuelBurnTime <= 0)
{ {
// No fuel is burning, reset progressbars and bail out // If a furnace is out of fuel, the progress bar reverses at twice the speed of cooking.
if ((m_LastProgressCook > 0) || (m_LastProgressFuel > 0)) m_TimeCooked = std::max((m_TimeCooked - 2), 0);
{
UpdateProgressBars(); // Reset progressbars, block type, and bail out
} m_BlockType = E_BLOCK_FURNACE;
a_Chunk.FastSetBlock(GetRelX(), m_PosY, GetRelZ(), E_BLOCK_FURNACE, m_BlockMeta);
UpdateProgressBars();
return false; return false;
} }
@ -139,12 +142,12 @@ void cFurnaceEntity::SendTo(cClientHandle & a_Client)
void cFurnaceEntity::BroadcastProgress(int a_ProgressbarID, short a_Value) void cFurnaceEntity::BroadcastProgress(short a_ProgressbarID, short a_Value)
{ {
cWindow * Window = GetWindow(); cWindow * Window = GetWindow();
if (Window != NULL) if (Window != NULL)
{ {
Window->BroadcastProgress(a_ProgressbarID, a_Value); Window->SetProperty(a_ProgressbarID, a_Value);
} }
} }
@ -152,7 +155,6 @@ void cFurnaceEntity::BroadcastProgress(int a_ProgressbarID, short a_Value)
/// One item finished cooking
void cFurnaceEntity::FinishOne() void cFurnaceEntity::FinishOne()
{ {
m_TimeCooked = 0; m_TimeCooked = 0;
@ -166,8 +168,6 @@ void cFurnaceEntity::FinishOne()
m_Contents.ChangeSlotCount(fsOutput, m_CurrentRecipe->Out->m_ItemCount); m_Contents.ChangeSlotCount(fsOutput, m_CurrentRecipe->Out->m_ItemCount);
} }
m_Contents.ChangeSlotCount(fsInput, -m_CurrentRecipe->In->m_ItemCount); m_Contents.ChangeSlotCount(fsInput, -m_CurrentRecipe->In->m_ItemCount);
UpdateIsCooking();
} }
@ -181,8 +181,7 @@ void cFurnaceEntity::BurnNewFuel(void)
if (NewTime == 0) if (NewTime == 0)
{ {
// The item in the fuel slot is not suitable // The item in the fuel slot is not suitable
m_FuelBurnTime = 0; SetBurnTimes(0, 0);
m_TimeBurned = 0;
SetIsCooking(false); SetIsCooking(false);
return; return;
} }
@ -194,8 +193,7 @@ void cFurnaceEntity::BurnNewFuel(void)
} }
// Burn one new fuel: // Burn one new fuel:
m_FuelBurnTime = NewTime; SetBurnTimes(NewTime, 0);
m_TimeBurned = 0;
SetIsCooking(true); SetIsCooking(true);
if (m_Contents.GetSlot(fsFuel).m_ItemType == E_ITEM_LAVA_BUCKET) if (m_Contents.GetSlot(fsFuel).m_ItemType == E_ITEM_LAVA_BUCKET)
{ {
@ -214,33 +212,19 @@ void cFurnaceEntity::BurnNewFuel(void)
void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
{ {
super::OnSlotChanged(a_ItemGrid, a_SlotNum); super::OnSlotChanged(a_ItemGrid, a_SlotNum);
if (m_World == NULL) if (m_IsDestroyed)
{ {
// The furnace isn't initialized yet, do no processing
return; return;
} }
ASSERT(a_ItemGrid == &m_Contents); ASSERT(a_ItemGrid == &m_Contents);
switch (a_SlotNum) switch (a_SlotNum)
{ {
case fsInput: case fsInput: UpdateInput(); break;
{ case fsFuel: UpdateFuel(); break;
UpdateInput(); case fsOutput: UpdateOutput(); break;
break; default: ASSERT(!"Invalid furnace slot update!"); break;
}
case fsFuel:
{
UpdateFuel();
break;
}
case fsOutput:
{
UpdateOutput();
break;
}
} }
} }
@ -249,7 +233,6 @@ void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
/// Updates the current recipe, based on the current input
void cFurnaceEntity::UpdateInput(void) void cFurnaceEntity::UpdateInput(void)
{ {
if (!m_Contents.GetSlot(fsInput).IsEqual(m_LastInput)) if (!m_Contents.GetSlot(fsInput).IsEqual(m_LastInput))
@ -263,8 +246,8 @@ void cFurnaceEntity::UpdateInput(void)
m_CurrentRecipe = FR->GetRecipeFrom(m_Contents.GetSlot(fsInput)); m_CurrentRecipe = FR->GetRecipeFrom(m_Contents.GetSlot(fsInput));
if (!CanCookInputToOutput()) if (!CanCookInputToOutput())
{ {
// This input cannot be cooked // This input cannot be cooked, reset cook counter immediately
m_NeedCookTime = 0; SetCookTimes(0, 0);
SetIsCooking(false); SetIsCooking(false);
} }
else else
@ -284,7 +267,6 @@ void cFurnaceEntity::UpdateInput(void)
/// Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropriate
void cFurnaceEntity::UpdateFuel(void) void cFurnaceEntity::UpdateFuel(void)
{ {
if (m_FuelBurnTime > m_TimeBurned) if (m_FuelBurnTime > m_TimeBurned)
@ -301,14 +283,12 @@ void cFurnaceEntity::UpdateFuel(void)
/// Called when the output slot changes; starts burning if space became available
void cFurnaceEntity::UpdateOutput(void) void cFurnaceEntity::UpdateOutput(void)
{ {
if (!CanCookInputToOutput()) if (!CanCookInputToOutput())
{ {
// Cannot cook anymore: // Cannot cook anymore:
m_TimeCooked = 0; SetCookTimes(0, 0);
m_NeedCookTime = 0;
SetIsCooking(false); SetIsCooking(false);
return; return;
} }
@ -324,30 +304,6 @@ void cFurnaceEntity::UpdateOutput(void)
/// Updates the m_IsCooking, based on the input slot, output slot and m_FuelBurnTime / m_TimeBurned
void cFurnaceEntity::UpdateIsCooking(void)
{
if (
!CanCookInputToOutput() || // Cannot cook this
(m_FuelBurnTime <= 0) || // No fuel
(m_TimeBurned >= m_FuelBurnTime) // Fuel burnt out
)
{
// Reset everything
SetIsCooking(false);
m_TimeCooked = 0;
m_NeedCookTime = 0;
return;
}
SetIsCooking(true);
}
/// Returns true if the input can be cooked into output and the item counts allow for another cooking operation
bool cFurnaceEntity::CanCookInputToOutput(void) const bool cFurnaceEntity::CanCookInputToOutput(void) const
{ {
if (m_CurrentRecipe == NULL) if (m_CurrentRecipe == NULL)
@ -382,25 +338,20 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
/// Broadcasts progressbar updates, if needed void cFurnaceEntity::UpdateProgressBars(bool a_ForceUpdate)
void cFurnaceEntity::UpdateProgressBars(void)
{ {
// In order to preserve bandwidth, an update is sent only every 10th tick // In order to preserve bandwidth, an update is sent only every 10th tick
// That's why the comparisons use the division by eight if (!a_ForceUpdate && (m_World->GetWorldAge() % 10 != 0))
int CurFuel = (m_FuelBurnTime > 0) ? (200 - 200 * m_TimeBurned / m_FuelBurnTime) : 0;
if ((CurFuel / 8) != (m_LastProgressFuel / 8))
{ {
BroadcastProgress(PROGRESSBAR_FUEL, (short)CurFuel); return;
m_LastProgressFuel = CurFuel;
} }
int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0; int CurFuel = (m_FuelBurnTime > 0) ? 200 - (200 * m_TimeBurned / m_FuelBurnTime) : 0;
if ((CurCook / 8) != (m_LastProgressCook / 8)) BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(CurFuel));
{
BroadcastProgress(PROGRESSBAR_SMELTING, (short)CurCook); int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
m_LastProgressCook = CurCook; BroadcastProgress(PROGRESSBAR_SMELTING_CONFIRM, 200); // Post 1.8, Mojang requires a random packet with an ID of three and value of 200. Wat. Wat. Wat.
} BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(CurCook));
} }
@ -413,11 +364,14 @@ void cFurnaceEntity::SetIsCooking(bool a_IsCooking)
{ {
return; return;
} }
m_IsCooking = a_IsCooking; m_IsCooking = a_IsCooking;
// Light or extinguish the furnace: // Only light the furnace as it is extinguished only when the fuel runs out, not when cooking stops - handled in this::Tick()
m_World->FastSetBlock(m_PosX, m_PosY, m_PosZ, m_IsCooking ? E_BLOCK_LIT_FURNACE : E_BLOCK_FURNACE, m_BlockMeta); if (m_IsCooking)
{
m_BlockType = E_BLOCK_LIT_FURNACE;
m_World->FastSetBlock(m_PosX, m_PosY, m_PosZ, E_BLOCK_LIT_FURNACE, m_BlockMeta);
}
} }

View File

@ -38,114 +38,128 @@ public:
// tolua_end // tolua_end
/// Constructor used for normal operation BLOCKENTITY_PROTODEF(cFurnaceEntity);
/** Constructor used for normal operation */
cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World); cFurnaceEntity(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cWorld * a_World);
virtual ~cFurnaceEntity(); virtual ~cFurnaceEntity();
static const char * GetClassStatic() { return "cFurnaceEntity"; }
// cBlockEntity overrides: // cBlockEntity overrides:
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;
virtual bool Tick(float a_Dt, cChunk & a_Chunk) override; virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void UsedBy(cPlayer * a_Player) override; virtual void UsedBy(cPlayer * a_Player) override;
virtual void Destroy() override
{
m_IsDestroyed = true;
super::Destroy();
}
/// Restarts cooking. Used after the furnace is loaded from storage to set up the internal variables so that cooking continues, if it was active. Returns true if cooking. /** Restarts cooking
Used after the furnace is loaded from storage to set up the internal variables so that cooking continues, if it was active
Returns true if cooking */
bool ContinueCooking(void); bool ContinueCooking(void);
void ResetCookTimer();
// tolua_begin // tolua_begin
/// Returns the item in the input slot /** Returns the item in the input slot */
const cItem & GetInputSlot(void) const { return GetSlot(fsInput); } const cItem & GetInputSlot(void) const { return GetSlot(fsInput); }
/// Returns the item in the fuel slot /** Returns the item in the fuel slot */
const cItem & GetFuelSlot(void) const { return GetSlot(fsFuel); } const cItem & GetFuelSlot(void) const { return GetSlot(fsFuel); }
/// Returns the item in the output slot /** Returns the item in the output slot */
const cItem & GetOutputSlot(void) const { return GetSlot(fsOutput); } const cItem & GetOutputSlot(void) const { return GetSlot(fsOutput); }
/// Sets the item in the input slot /** Sets the item in the input slot */
void SetInputSlot(const cItem & a_Item) { SetSlot(fsInput, a_Item); } void SetInputSlot(const cItem & a_Item) { SetSlot(fsInput, a_Item); }
/// Sets the item in the fuel slot /** Sets the item in the fuel slot */
void SetFuelSlot(const cItem & a_Item) { SetSlot(fsFuel, a_Item); } void SetFuelSlot(const cItem & a_Item) { SetSlot(fsFuel, a_Item); }
/// Sets the item in the output slot /** Sets the item in the output slot */
void SetOutputSlot(const cItem & a_Item) { SetSlot(fsOutput, a_Item); } void SetOutputSlot(const cItem & a_Item) { SetSlot(fsOutput, a_Item); }
/// Returns the time that the current item has been cooking, in ticks /** Returns the time that the current item has been cooking, in ticks */
int GetTimeCooked(void) const {return m_TimeCooked; } int GetTimeCooked(void) const { return m_TimeCooked; }
/// Returns the time until the current item finishes cooking, in ticks /** Returns the time until the current item finishes cooking, in ticks */
int GetCookTimeLeft(void) const { return m_NeedCookTime - m_TimeCooked; } int GetCookTimeLeft(void) const { return m_NeedCookTime - m_TimeCooked; }
/// Returns the time until the current fuel is depleted, in ticks /** Returns the time until the current fuel is depleted, in ticks */
int GetFuelBurnTimeLeft(void) const {return m_FuelBurnTime - m_TimeBurned; } int GetFuelBurnTimeLeft(void) const { return m_FuelBurnTime - m_TimeBurned; }
/// Returns true if there's time left before the current fuel is depleted /** Returns true if there's time left before the current fuel is depleted */
bool HasFuelTimeLeft(void) const { return (GetFuelBurnTimeLeft() > 0); } bool HasFuelTimeLeft(void) const { return (GetFuelBurnTimeLeft() > 0); }
// tolua_end // tolua_end
void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned) {m_FuelBurnTime = a_FuelBurnTime; m_TimeBurned = a_TimeBurned; } void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned)
void SetCookTimes(int a_NeedCookTime, int a_TimeCooked) {m_NeedCookTime = a_NeedCookTime; m_TimeCooked = a_TimeCooked; } {
m_FuelBurnTime = a_FuelBurnTime;
m_TimeBurned = a_TimeBurned;
}
void SetCookTimes(int a_NeedCookTime, int a_TimeCooked)
{
m_NeedCookTime = a_NeedCookTime;
m_TimeCooked = a_TimeCooked;
}
protected: protected:
/// Block type of the block currently represented by this entity (changes when furnace lights up)
BLOCKTYPE m_BlockType;
/// Block meta of the block currently represented by this entity /** Block meta of the block currently represented by this entity */
NIBBLETYPE m_BlockMeta; NIBBLETYPE m_BlockMeta;
/// The recipe for the current input slot /** The recipe for the current input slot */
const cFurnaceRecipe::cRecipe * m_CurrentRecipe; const cFurnaceRecipe::cRecipe * m_CurrentRecipe;
/// The item that is being smelted /** The item that is being smelted */
cItem m_LastInput; cItem m_LastInput;
/** Set to true when the furnace entity has been destroyed to prevent the block being set again */
bool m_IsDestroyed;
bool m_IsCooking; ///< Set to true if the furnace is cooking an item /** Set to true if the furnace is cooking an item */
bool m_IsCooking;
// All timers are in ticks /** Amount of ticks needed to fully cook current item */
int m_NeedCookTime; ///< Amount of time needed to fully cook current item int m_NeedCookTime;
int m_TimeCooked; ///< Amount of time that the current item has been cooking
int m_FuelBurnTime; ///< Amount of time that the current fuel can burn (in total); zero if no fuel burning /** Amount of ticks that the current item has been cooking */
int m_TimeBurned; ///< Amount of time that the current fuel has been burning int m_TimeCooked;
/** Amount of ticks that the current fuel can burn (in total); zero if no fuel burning */
int m_FuelBurnTime;
/** Amount of ticks that the current fuel has been burning */
int m_TimeBurned;
int m_LastProgressFuel; ///< Last value sent as the progress for the fuel /** Sends the specified progressbar value to all clients of the window */
int m_LastProgressCook; ///< Last value sent as the progress for the cooking void BroadcastProgress(short a_ProgressbarID, short a_Value);
/** One item finished cooking */
/// Sends the specified progressbar value to all clients of the window
void BroadcastProgress(int a_ProgressbarID, short a_Value);
/// One item finished cooking
void FinishOne(); void FinishOne();
/// Starts burning a new fuel, if possible /** Starts burning a new fuel, if possible */
void BurnNewFuel(void); void BurnNewFuel(void);
/// Updates the recipe, based on the current input /** Updates the recipe, based on the current input */
void UpdateInput(void); void UpdateInput(void);
/// Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropriate /** Called when the fuel slot changes or when the fuel is spent, burns another piece of fuel if appropriate */
void UpdateFuel(void); void UpdateFuel(void);
/// Called when the output slot changes /** Called when the output slot changes */
void UpdateOutput(void); void UpdateOutput(void);
/// Updates the m_IsCooking, based on the input slot, output slot and m_FuelBurnTime / m_TimeBurned /** Returns true if the input can be cooked into output and the item counts allow for another cooking operation */
void UpdateIsCooking(void);
/// Returns true if the input can be cooked into output and the item counts allow for another cooking operation
bool CanCookInputToOutput(void) const; bool CanCookInputToOutput(void) const;
/// Broadcasts progressbar updates, if needed /** Broadcasts progressbar updates, if needed */
void UpdateProgressBars(void); void UpdateProgressBars(bool a_ForceUpdate = false);
/// Sets the m_IsCooking variable, updates the furnace block type based on the value /** Sets the m_IsCooking variable, updates the furnace block type based on the value */
void SetIsCooking(bool a_IsCooking); void SetIsCooking(bool a_IsCooking);
// cItemGrid::cListener overrides: // cItemGrid::cListener overrides:

View File

@ -31,6 +31,8 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cHopperEntity);
/// Constructor used for normal operation /// Constructor used for normal operation
cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cHopperEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
@ -40,8 +42,6 @@ public:
*/ */
bool GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, int & a_OutputY, int & a_OutputZ); bool GetOutputBlockPos(NIBBLETYPE a_BlockMeta, int & a_OutputX, int & a_OutputY, int & a_OutputZ);
static const char * GetClassStatic(void) { return "cHopperEntity"; }
protected: protected:
Int64 m_LastMoveItemsInTick; Int64 m_LastMoveItemsInTick;

View File

@ -26,6 +26,8 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cJukeboxEntity);
cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ~cJukeboxEntity(); virtual ~cJukeboxEntity();
@ -51,8 +53,6 @@ public:
// tolua_end // tolua_end
static const char * GetClassStatic(void) { return "cJukeboxEntity"; }
virtual void UsedBy(cPlayer * a_Player) override; virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle &) override {} virtual void SendTo(cClientHandle &) override {}

View File

@ -34,6 +34,8 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cMobHeadEntity);
/** Creates a new mob head entity at the specified block coords. a_World may be NULL */ /** Creates a new mob head entity at the specified block coords. a_World may be NULL */
cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World); cMobHeadEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
@ -62,8 +64,6 @@ public:
virtual void UsedBy(cPlayer * a_Player) override; virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;
static const char * GetClassStatic(void) { return "cMobHeadEntity"; }
private: private:
eMobHeadType m_Type; eMobHeadType m_Type;

View File

@ -40,6 +40,8 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cNoteEntity);
/// Creates a new note entity. a_World may be NULL /// Creates a new note entity. a_World may be NULL
cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World); cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
virtual ~cNoteEntity() {} virtual ~cNoteEntity() {}
@ -64,8 +66,6 @@ public:
} }
} }
static const char * GetClassStatic(void) { return "cNoteEntity"; }
private: private:
char m_Pitch; char m_Pitch;
} ; // tolua_export } ; // tolua_export

View File

@ -34,6 +34,8 @@ public:
// tolua_end // tolua_end
BLOCKENTITY_PROTODEF(cSignEntity);
/// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL /// Creates a new empty sign entity at the specified block coords and block type (wall or standing). a_World may be NULL
cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World); cSignEntity(BLOCKTYPE a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
@ -53,8 +55,6 @@ public:
virtual void UsedBy(cPlayer * a_Player) override; virtual void UsedBy(cPlayer * a_Player) override;
virtual void SendTo(cClientHandle & a_Client) override; virtual void SendTo(cClientHandle & a_Client) override;
static const char * GetClassStatic(void) { return "cSignEntity"; }
private: private:
AString m_Line[4]; AString m_Line[4];

View File

@ -333,7 +333,7 @@ void cChunk::SetAllData(cSetChunkData & a_SetChunkData)
{ {
BLOCKTYPE EntityBlockType = (*itr)->GetBlockType(); BLOCKTYPE EntityBlockType = (*itr)->GetBlockType();
BLOCKTYPE WorldBlockType = GetBlock((*itr)->GetRelX(), (*itr)->GetPosY(), (*itr)->GetRelZ()); BLOCKTYPE WorldBlockType = GetBlock((*itr)->GetRelX(), (*itr)->GetPosY(), (*itr)->GetRelZ());
ASSERT(EntityBlockType == WorldBlockType); ASSERT(WorldBlockType == EntityBlockType);
} // for itr - m_BlockEntities } // for itr - m_BlockEntities
#endif // _DEBUG #endif // _DEBUG

View File

@ -33,7 +33,7 @@ class cChunkMap;
class cBeaconEntity; class cBeaconEntity;
class cBoundingBox; class cBoundingBox;
class cChestEntity; class cChestEntity;
class cCHunkDataCallback; class cChunkDataCallback;
class cCommandBlockEntity; class cCommandBlockEntity;
class cDispenserEntity; class cDispenserEntity;
class cFurnaceEntity; class cFurnaceEntity;

View File

@ -2736,7 +2736,7 @@ void cClientHandle::SendWindowOpen(const cWindow & a_Window)
void cClientHandle::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) void cClientHandle::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
{ {
m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value); m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value);
} }

View File

@ -204,7 +204,7 @@ public:
void SendWholeInventory (const cWindow & a_Window); void SendWholeInventory (const cWindow & a_Window);
void SendWindowClose (const cWindow & a_Window); void SendWindowClose (const cWindow & a_Window);
void SendWindowOpen (const cWindow & a_Window); void SendWindowOpen (const cWindow & a_Window);
void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value); void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value);
// tolua_begin // tolua_begin
const AString & GetUsername(void) const; const AString & GetUsername(void) const;

View File

@ -172,13 +172,13 @@ public:
/// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) /// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true)
virtual bool IsA(const char * a_ClassName) const; virtual bool IsA(const char * a_ClassName) const;
/// Returns the topmost class name for the object /** Returns the class name of this class */
virtual const char * GetClass(void) const;
// Returns the class name of this class
static const char * GetClassStatic(void); static const char * GetClassStatic(void);
/// Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). /** Returns the topmost class name for the object */
virtual const char * GetClass(void) const;
/** Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). */
virtual const char * GetParentClass(void) const; virtual const char * GetParentClass(void) const;
cWorld * GetWorld(void) const { return m_World; } cWorld * GetWorld(void) const { return m_World; }

View File

@ -2134,19 +2134,19 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
void cPlayer::LoadRank(void) void cPlayer::LoadRank(void)
{ {
// Load the values from cRankManager: // Load the values from cRankManager:
cRankManager & RankMgr = cRoot::Get()->GetRankManager(); cRankManager * RankMgr = cRoot::Get()->GetRankManager();
m_Rank = RankMgr.GetPlayerRankName(m_UUID); m_Rank = RankMgr->GetPlayerRankName(m_UUID);
if (m_Rank.empty()) if (m_Rank.empty())
{ {
m_Rank = RankMgr.GetDefaultRank(); m_Rank = RankMgr->GetDefaultRank();
} }
else else
{ {
// Update the name: // Update the name:
RankMgr.UpdatePlayerName(m_UUID, m_PlayerName); RankMgr->UpdatePlayerName(m_UUID, m_PlayerName);
} }
m_Permissions = RankMgr.GetPlayerPermissions(m_UUID); m_Permissions = RankMgr->GetPlayerPermissions(m_UUID);
RankMgr.GetRankVisuals(m_Rank, m_MsgPrefix, m_MsgSuffix, m_MsgNameColorCode); RankMgr->GetRankVisuals(m_Rank, m_MsgPrefix, m_MsgSuffix, m_MsgNameColorCode);
// Break up the individual permissions on each dot, into m_SplitPermissions: // Break up the individual permissions on each dot, into m_SplitPermissions:
m_SplitPermissions.clear(); m_SplitPermissions.clear();

View File

@ -130,7 +130,7 @@ public:
virtual void SendWholeInventory (const cWindow & a_Window) = 0; virtual void SendWholeInventory (const cWindow & a_Window) = 0;
virtual void SendWindowClose (const cWindow & a_Window) = 0; virtual void SendWindowClose (const cWindow & a_Window) = 0;
virtual void SendWindowOpen (const cWindow & a_Window) = 0; virtual void SendWindowOpen (const cWindow & a_Window) = 0;
virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) = 0; virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) = 0;
/// Returns the ServerID used for authentication through session.minecraft.net /// Returns the ServerID used for authentication through session.minecraft.net
virtual AString GetAuthServerID(void) = 0; virtual AString GetAuthServerID(void) = 0;

View File

@ -1439,7 +1439,7 @@ void cProtocol172::SendWindowOpen(const cWindow & a_Window)
void cProtocol172::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
{ {
ASSERT(m_State == 3); // In game mode? ASSERT(m_State == 3); // In game mode?

View File

@ -134,7 +134,7 @@ public:
virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override; virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override; virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual AString GetAuthServerID(void) override { return m_AuthServerID; } virtual AString GetAuthServerID(void) override { return m_AuthServerID; }

View File

@ -1500,7 +1500,7 @@ void cProtocol180::SendWindowOpen(const cWindow & a_Window)
void cProtocol180::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) void cProtocol180::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
{ {
ASSERT(m_State == 3); // In game mode? ASSERT(m_State == 3); // In game mode?

View File

@ -133,7 +133,7 @@ public:
virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override; virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override; virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual AString GetAuthServerID(void) override { return m_AuthServerID; } virtual AString GetAuthServerID(void) override { return m_AuthServerID; }

View File

@ -350,7 +350,7 @@ void cProtocolRecognizer::SendHealth(void)
void cProtocolRecognizer::SendWindowProperty(const cWindow & a_Window, int a_Property, int a_Value) void cProtocolRecognizer::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
{ {
ASSERT(m_Protocol != NULL); ASSERT(m_Protocol != NULL);
m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value); m_Protocol->SendWindowProperty(a_Window, a_Property, a_Value);

View File

@ -121,7 +121,7 @@ public:
virtual void SendWholeInventory (const cWindow & a_Window) override; virtual void SendWholeInventory (const cWindow & a_Window) override;
virtual void SendWindowClose (const cWindow & a_Window) override; virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override; virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, int a_Property, int a_Value) override; virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
virtual AString GetAuthServerID(void) override; virtual AString GetAuthServerID(void) override;

View File

@ -152,7 +152,8 @@ void cRoot::Start(void)
m_WebAdmin->Init(); m_WebAdmin->Init();
LOGD("Loading settings..."); LOGD("Loading settings...");
m_RankManager.Initialize(m_MojangAPI); m_RankManager = new cRankManager();
m_RankManager->Initialize(m_MojangAPI);
m_CraftingRecipes = new cCraftingRecipes; m_CraftingRecipes = new cCraftingRecipes;
m_FurnaceRecipe = new cFurnaceRecipe(); m_FurnaceRecipe = new cFurnaceRecipe();

View File

@ -86,7 +86,7 @@ public:
cPluginManager * GetPluginManager (void) { return m_PluginManager; } // tolua_export cPluginManager * GetPluginManager (void) { return m_PluginManager; } // tolua_export
cAuthenticator & GetAuthenticator (void) { return m_Authenticator; } cAuthenticator & GetAuthenticator (void) { return m_Authenticator; }
cMojangAPI & GetMojangAPI (void) { return m_MojangAPI; } cMojangAPI & GetMojangAPI (void) { return m_MojangAPI; }
cRankManager & GetRankManager (void) { return m_RankManager; } cRankManager * GetRankManager (void) { return m_RankManager; }
/** Queues a console command for execution through the cServer class. /** Queues a console command for execution through the cServer class.
The command will be executed in the tick thread The command will be executed in the tick thread
@ -185,7 +185,7 @@ private:
cPluginManager * m_PluginManager; cPluginManager * m_PluginManager;
cAuthenticator m_Authenticator; cAuthenticator m_Authenticator;
cMojangAPI m_MojangAPI; cMojangAPI m_MojangAPI;
cRankManager m_RankManager; cRankManager * m_RankManager;
cHTTPServer m_HTTPServer; cHTTPServer m_HTTPServer;
bool m_bStop; bool m_bStop;

View File

@ -758,20 +758,7 @@ void cWindow::BroadcastWholeWindow(void)
void cWindow::BroadcastProgress(int a_Progressbar, int a_Value) void cWindow::SetProperty(short a_Property, short a_Value)
{
cCSLock Lock(m_CS);
for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
{
(*itr)->GetClientHandle()->SendWindowProperty(*this, a_Progressbar, a_Value);
} // for itr - m_OpenedBy[]
}
void cWindow::SetProperty(int a_Property, int a_Value)
{ {
cCSLock Lock(m_CS); cCSLock Lock(m_CS);
for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr) for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr)
@ -784,7 +771,7 @@ void cWindow::SetProperty(int a_Property, int a_Value)
void cWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player) void cWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player)
{ {
a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value); a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
} }
@ -919,7 +906,7 @@ cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
void cEnchantingWindow::SetProperty(int a_Property, int a_Value) void cEnchantingWindow::SetProperty(short a_Property, short a_Value)
{ {
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue))) if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
{ {
@ -935,7 +922,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value)
void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player) void cEnchantingWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player)
{ {
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue))) if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
{ {
@ -951,7 +938,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Pla
int cEnchantingWindow::GetPropertyValue(int a_Property) short cEnchantingWindow::GetPropertyValue(short a_Property)
{ {
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue))) if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
{ {

View File

@ -130,9 +130,6 @@ public:
/// Sends the contents of the whole window to all clients of this window. /// Sends the contents of the whole window to all clients of this window.
void BroadcastWholeWindow(void); void BroadcastWholeWindow(void);
/// Sends the progressbar to all clients of this window (same as SetProperty)
void BroadcastProgress(int a_Progressbar, int a_Value);
// tolua_begin // tolua_begin
@ -140,10 +137,10 @@ public:
void SetWindowTitle(const AString & a_WindowTitle) { m_WindowTitle = a_WindowTitle; } void SetWindowTitle(const AString & a_WindowTitle) { m_WindowTitle = a_WindowTitle; }
/// Sends the UpdateWindowProperty (0x69) packet to all clients of the window /// Sends the UpdateWindowProperty (0x69) packet to all clients of the window
virtual void SetProperty(int a_Property, int a_Value); virtual void SetProperty(short a_Property, short a_Value);
/// Sends the UpdateWindowPropert(0x69) packet to the specified player /// Sends the UpdateWindowPropert(0x69) packet to the specified player
virtual void SetProperty(int a_Property, int a_Value, cPlayer & a_Player); virtual void SetProperty(short a_Property, short a_Value, cPlayer & a_Player);
// tolua_end // tolua_end
@ -287,16 +284,16 @@ class cEnchantingWindow :
typedef cWindow super; typedef cWindow super;
public: public:
cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ); cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ);
virtual void SetProperty(int a_Property, int a_Value, cPlayer & a_Player) override; virtual void SetProperty(short a_Property, short a_Value, cPlayer & a_Player) override;
virtual void SetProperty(int a_Property, int a_Value) override; virtual void SetProperty(short a_Property, short a_Value) override;
/** Return the Value of a Property */ /** Return the Value of a Property */
int GetPropertyValue(int a_Property); short GetPropertyValue(short a_Property);
cSlotArea * m_SlotArea; cSlotArea * m_SlotArea;
protected: protected:
int m_PropertyValue[3]; short m_PropertyValue[3];
int m_BlockX, m_BlockY, m_BlockZ; int m_BlockX, m_BlockY, m_BlockZ;
}; };