1
0

Added a world parameter to HOOK_CHUNK_GENERATING.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@609 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-06-14 17:30:37 +00:00
parent 2bcbb6c1b8
commit 0f39e9b10b
8 changed files with 65 additions and 52 deletions

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on Thu Jun 14 14:20:17 2012.
** Generated automatically by tolua++-1.0.92 on 06/14/12 19:28:15.
*/
#ifndef __cplusplus
@ -7863,24 +7863,26 @@ static int tolua_AllToLua_cPlugin_OnChunkGenerating00(lua_State* tolua_S)
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isusertype(tolua_S,4,"cLuaChunk",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
!tolua_isusertype(tolua_S,5,"cLuaChunk",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,6,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
int a_ChunkX = ((int) tolua_tonumber(tolua_S,2,0));
int a_ChunkZ = ((int) tolua_tonumber(tolua_S,3,0));
cLuaChunk* a_pLuaChunk = ((cLuaChunk*) tolua_tousertype(tolua_S,4,0));
cWorld* a_Wordl = ((cWorld*) tolua_tousertype(tolua_S,2,0));
int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0));
int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0));
cLuaChunk* a_pLuaChunk = ((cLuaChunk*) tolua_tousertype(tolua_S,5,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'OnChunkGenerating'", NULL);
#endif
{
bool tolua_ret = (bool) self->OnChunkGenerating(a_ChunkX,a_ChunkZ,a_pLuaChunk);
bool tolua_ret = (bool) self->OnChunkGenerating(a_Wordl,a_ChunkX,a_ChunkZ,a_pLuaChunk);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
@ -8472,17 +8474,18 @@ public:
return ( void ) cPlugin:: OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ);
};
};
bool OnChunkGenerating( int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
bool OnChunkGenerating( cWorld* a_Wordl, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
if (push_method("OnChunkGenerating", tolua_AllToLua_cPlugin_OnChunkGenerating00)) {
tolua_pushusertype(lua_state, (void*)a_Wordl, "cWorld");
tolua_pushnumber(lua_state, (lua_Number)a_ChunkX);
tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ);
tolua_pushusertype(lua_state, (void*)a_pLuaChunk, "cLuaChunk");
ToluaBase::dbcall(lua_state, 4, 1);
ToluaBase::dbcall(lua_state, 5, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin:: OnChunkGenerating(a_ChunkX,a_ChunkZ,a_pLuaChunk);
return ( bool ) cPlugin:: OnChunkGenerating(a_Wordl,a_ChunkX,a_ChunkZ,a_pLuaChunk);
};
};
bool OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) {
@ -8584,8 +8587,8 @@ public:
void cPlugin__OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) {
return ( void )cPlugin::OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ);
};
bool cPlugin__OnChunkGenerating( int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
return ( bool )cPlugin::OnChunkGenerating(a_ChunkX,a_ChunkZ,a_pLuaChunk);
bool cPlugin__OnChunkGenerating( cWorld* a_Wordl, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
return ( bool )cPlugin::OnChunkGenerating(a_Wordl,a_ChunkX,a_ChunkZ,a_pLuaChunk);
};
bool cPlugin__OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) {
return ( bool )cPlugin::OnPreCrafting(a_Player,a_Grid,a_Recipe);
@ -9132,24 +9135,26 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00(lua_State* t
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isusertype(tolua_S,2,"cWorld",0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isusertype(tolua_S,4,"cLuaChunk",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
!tolua_isusertype(tolua_S,5,"cLuaChunk",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,6,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
int a_ChunkX = ((int) tolua_tonumber(tolua_S,2,0));
int a_ChunkZ = ((int) tolua_tonumber(tolua_S,3,0));
cLuaChunk* a_pLuaChunk = ((cLuaChunk*) tolua_tousertype(tolua_S,4,0));
cWorld* a_Wordl = ((cWorld*) tolua_tousertype(tolua_S,2,0));
int a_ChunkX = ((int) tolua_tonumber(tolua_S,3,0));
int a_ChunkZ = ((int) tolua_tonumber(tolua_S,4,0));
cLuaChunk* a_pLuaChunk = ((cLuaChunk*) tolua_tousertype(tolua_S,5,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin__OnChunkGenerating'", NULL);
#endif
{
bool tolua_ret = (bool) self->cPlugin__OnChunkGenerating(a_ChunkX,a_ChunkZ,a_pLuaChunk);
bool tolua_ret = (bool) self->cPlugin__OnChunkGenerating(a_Wordl,a_ChunkX,a_ChunkZ,a_pLuaChunk);
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
@ -9702,17 +9707,18 @@ public:
return ( void ) cPlugin_NewLua:: OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ);
};
};
bool OnChunkGenerating( int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
bool OnChunkGenerating( cWorld* a_Wordl, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
if (push_method("OnChunkGenerating", tolua_AllToLua_cPlugin_OnChunkGenerating00)) {
tolua_pushusertype(lua_state, (void*)a_Wordl, "cWorld");
tolua_pushnumber(lua_state, (lua_Number)a_ChunkX);
tolua_pushnumber(lua_state, (lua_Number)a_ChunkZ);
tolua_pushusertype(lua_state, (void*)a_pLuaChunk, "cLuaChunk");
ToluaBase::dbcall(lua_state, 4, 1);
ToluaBase::dbcall(lua_state, 5, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnChunkGenerating(a_ChunkX,a_ChunkZ,a_pLuaChunk);
return ( bool ) cPlugin_NewLua:: OnChunkGenerating(a_Wordl,a_ChunkX,a_ChunkZ,a_pLuaChunk);
};
};
bool OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) {
@ -9817,8 +9823,8 @@ public:
void cPlugin_NewLua__OnChunkGenerated( cWorld* a_World, int a_ChunkX, int a_ChunkZ) {
return ( void )cPlugin_NewLua::OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ);
};
bool cPlugin_NewLua__OnChunkGenerating( int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
return ( bool )cPlugin_NewLua::OnChunkGenerating(a_ChunkX,a_ChunkZ,a_pLuaChunk);
bool cPlugin_NewLua__OnChunkGenerating( cWorld* a_Wordl, int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
return ( bool )cPlugin_NewLua::OnChunkGenerating(a_Wordl,a_ChunkX,a_ChunkZ,a_pLuaChunk);
};
bool cPlugin_NewLua__OnPreCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) {
return ( bool )cPlugin_NewLua::OnPreCrafting(a_Player,a_Grid,a_Recipe);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on Thu Jun 14 14:20:17 2012.
** Generated automatically by tolua++-1.0.92 on 06/14/12 19:28:15.
*/
/* Exported function */

View File

@ -485,7 +485,7 @@ void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
cBlockEntityList BlockEntities;
cLuaChunk LuaChunk( BlockTypes, BlockMeta, HeightMap, BiomeMap );
if( cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_CHUNK_GENERATING, 3, a_ChunkX, a_ChunkZ, &LuaChunk ) )
if( cRoot::Get()->GetPluginManager()->CallHookChunkGenerating(m_World, a_ChunkX, a_ChunkZ, &LuaChunk ) )
{
// A plugin interrupted generation, handle something plugin specific
if( LuaChunk.IsUsingDefaultBiomes() )

View File

@ -60,7 +60,7 @@ public:
virtual void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) { (void)a_Pawn; (void)a_TakeDamageInfo; }
virtual bool OnKilled (cPawn* a_Killed, cEntity* a_Killer ) { (void)a_Killed; (void)a_Killer; return false; }
virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ) {}
virtual bool OnChunkGenerating (int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk ) { return false; }
virtual bool OnChunkGenerating (cWorld * a_Wordl, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk ) { return false; }
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }

View File

@ -390,28 +390,6 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...)
break;
}
case HOOK_CHUNK_GENERATING:
{
if (a_NumArgs != 3)
{
break;
}
va_list argptr;
va_start( argptr, a_NumArgs);
int ChunkX = va_arg(argptr, int);
int ChunkZ = va_arg(argptr, int);
cLuaChunk * LuaChunk = va_arg(argptr, cLuaChunk *);
va_end (argptr);
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkGenerating(ChunkX, ChunkZ, LuaChunk))
{
return true;
}
}
break;
}
default:
{
LOGWARNING("cPluginManager: Calling Unknown hook: %i", a_Hook );
@ -426,6 +404,27 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...)
bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_LuaChunk)
{
HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATING);
if (Plugins == m_Hooks.end())
{
return false;
}
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_LuaChunk))
{
return true;
}
}
return false;
}
bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING);

View File

@ -8,6 +8,12 @@ class cLuaCommandBinder;
class cPlugin;
class cPlugin_Lua;
// fwd: cWorld.h
class cWorld;
// fwd: cLuaChunk.h
class cLuaChunk;
// fwd: cPlayer.h
class cPlayer;
@ -87,6 +93,7 @@ public: //tolua_export
bool CallHook( PluginHook a_Hook, unsigned int a_NumArgs, ... );
bool CallHookChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_Chunk);
bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
bool CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);

View File

@ -388,12 +388,13 @@ void cPlugin_NewLua::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_Chun
bool cPlugin_NewLua::OnChunkGenerating( int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk )
bool cPlugin_NewLua::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk)
{
cCSLock Lock(m_CriticalSection);
if (!PushFunction("OnChunkGenerating"))
return false;
tolua_pushusertype(m_LuaState, a_World, "cWorld");
tolua_pushnumber (m_LuaState, a_ChunkX);
tolua_pushnumber (m_LuaState, a_ChunkZ);
tolua_pushusertype(m_LuaState, a_pLuaChunk, "cLuaChunk");

View File

@ -37,7 +37,7 @@ public: //tolua_export
virtual void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) override;
virtual bool OnKilled (cPawn* a_Killed, cEntity* a_Killer ) override;
virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ) override;
virtual bool OnChunkGenerating (int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk ) override;
virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk ) override;
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;