Skip to content

Commit

Permalink
Merge pull request #1624 from mc-server/LuaDeprecating
Browse files Browse the repository at this point in the history
Mark StringToMobType() as deprecated. Use cMonster:StringToMobType() instead
  • Loading branch information
madmaxoft committed Dec 1, 2014
2 parents cc313c9 + c173bf6 commit 36500f8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion MCServer/Plugins/APIDump/APIDesc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2928,7 +2928,7 @@ end
StringToDamageType = {Params = "string", Return = "{{Globals#DamageType|DamageType}}", Notes = "Converts a string representation to a {{Globals#DamageType|DamageType}} enumerated value."},
StringToDimension = {Params = "string", Return = "{{Globals#WorldDimension|Dimension}}", Notes = "Converts a string representation to a {{Globals#WorldDimension|Dimension}} enumerated value"},
StringToItem = {Params = "string, {{cItem|cItem}}", Return = "bool", Notes = "Parses the given string and sets the item; returns true if successful"},
StringToMobType = {Params = "string", Return = "{{cMonster#MobType|MobType}}", Notes = "Converts a string representation to a {{cMonster#MobType|MobType}} enumerated value"},
StringToMobType = {Params = "string", Return = "{{cMonster#MobType|MobType}}", Notes = "<b>DEPRECATED!</b> Please use cMonster:StringToMobType(). Converts a string representation to a {{cMonster#MobType|MobType}} enumerated value"},
StripColorCodes = {Params = "string", Return = "string", Notes = "Removes all control codes used by MC for colors and styles"},
TrimString = {Params = "string", Return = "string", Notes = "Trims whitespace at both ends of the string"},
md5 = {Params = "string", Return = "string", Notes = "converts a string to an md5 hash"},
Expand Down
38 changes: 38 additions & 0 deletions src/Bindings/DeprecatedBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,42 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)



/* function: StringToMobType */
static int tolua_AllToLua_StringToMobType00(lua_State* tolua_S)
{
cLuaState LuaState(tolua_S);

#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_iscppstring(tolua_S,1,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const AString a_MobString = tolua_tocppstring(LuaState, 1, 0);
eMonsterType MobType = cMonster::StringToMobType(a_MobString);
tolua_pushnumber(LuaState, (lua_Number) MobType);
tolua_pushcppstring(LuaState, (const char *) a_MobString);
}

LOGWARNING("Warning in function call 'StringToMobType': StringToMobType() is deprecated. Please use cMonster:StringToMobType()");
LuaState.LogStackTrace(0);
return 2;

#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(LuaState, "#ferror in function 'StringToMobType'.", &tolua_err);
return 0;
#endif
}





/** function: cWorld:SetSignLines */
static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
{
Expand Down Expand Up @@ -296,6 +332,8 @@ void DeprecatedBindings::Bind(lua_State * tolua_S)
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_function(tolua_S, "StringToMobType", tolua_AllToLua_StringToMobType00);

tolua_beginmodule(tolua_S, "cWorld");
tolua_function(tolua_S, "UpdateSign", tolua_cWorld_SetSignLines);
tolua_endmodule(tolua_S);
Expand Down
10 changes: 0 additions & 10 deletions src/Mobs/Monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ static const struct



eMonsterType StringToMobType(const AString & a_MobString)
{
LOGWARNING("%s: Function is obsolete, use cMonster::StringToMobType() instead", __FUNCTION__);
return cMonster::StringToMobType(a_MobString);
}





////////////////////////////////////////////////////////////////////////////////
// cMonster:

Expand Down
10 changes: 1 addition & 9 deletions src/Mobs/MonsterTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once

/// This identifies individual monster type, as well as their network type-ID

// tolua_begin
enum eMonsterType
{
Expand Down Expand Up @@ -38,15 +39,6 @@ enum eMonsterType
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
} ;





/** Translates a mob string ("ocelot") to mobtype (mtOcelot).
OBSOLETE, use cMonster::StringToMobType() instead.
Implemented in Monster.cpp. */
extern eMonsterType StringToMobType(const AString & a_MobString);

// tolua_end


Expand Down

0 comments on commit 36500f8

Please sign in to comment.