diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/AllToLua.pkg | 1 | ||||
-rw-r--r-- | source/Bindings.cpp | 191 | ||||
-rw-r--r-- | source/Bindings.h | 2 | ||||
-rw-r--r-- | source/cChunkGenerator.cpp | 31 | ||||
-rw-r--r-- | source/cLuaChunk.cpp | 4 | ||||
-rw-r--r-- | source/cLuaChunk.h | 39 | ||||
-rw-r--r-- | source/cPlugin.h | 2 | ||||
-rw-r--r-- | source/cPluginManager.cpp | 49 | ||||
-rw-r--r-- | source/cPlugin_NewLua.cpp | 21 | ||||
-rw-r--r-- | source/cPlugin_NewLua.h | 1 |
10 files changed, 316 insertions, 25 deletions
diff --git a/source/AllToLua.pkg b/source/AllToLua.pkg index 77862c1ae..9ccb0eb1d 100644 --- a/source/AllToLua.pkg +++ b/source/AllToLua.pkg @@ -45,3 +45,4 @@ $cfile "cGroup.h" $cfile "packets/cPacket_Login.h"
$cfile "packets/cPacket_BlockDig.h"
$cfile "packets/cPacket_BlockPlace.h"
+$cfile "cLuaChunk.h"
\ No newline at end of file diff --git a/source/Bindings.cpp b/source/Bindings.cpp index d510d87fb..07adbea1e 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,6 @@ /*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/09/12 17:10:20.
+** Generated automatically by tolua++-1.0.92 on 06/10/12 15:55:56.
*/
#ifndef __cplusplus
@@ -55,6 +55,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S); #include "packets/cPacket_Login.h"
#include "packets/cPacket_BlockDig.h"
#include "packets/cPacket_BlockPlace.h"
+#include "cLuaChunk.h"
/* function to release collected object via destructor */
#ifdef __cplusplus
@@ -164,6 +165,7 @@ static void tolua_reg_types (lua_State* tolua_S) {
tolua_usertype(tolua_S,"TakeDamageInfo");
tolua_usertype(tolua_S,"cPlugin");
+ tolua_usertype(tolua_S,"cLuaChunk");
tolua_usertype(tolua_S,"cStringMap");
tolua_usertype(tolua_S,"Lua__cEntity");
tolua_usertype(tolua_S,"Lua__cPacket_BlockDig");
@@ -7664,6 +7666,44 @@ static int tolua_AllToLua_cPlugin_OnChunkGenerated00(lua_State* tolua_S) }
#endif //#ifndef TOLUA_DISABLE
+/* method: OnChunkGenerating of class cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_OnChunkGenerating00
+static int tolua_AllToLua_cPlugin_OnChunkGenerating00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cPlugin",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,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)
+ )
+ 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));
+#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);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'OnChunkGenerating'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetName of class cPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_GetName00
static int tolua_AllToLua_cPlugin_GetName00(lua_State* tolua_S)
@@ -8087,6 +8127,19 @@ public: return ( void ) cPlugin:: OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ);
};
};
+ bool OnChunkGenerating( int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
+ if (push_method("OnChunkGenerating", tolua_AllToLua_cPlugin_OnChunkGenerating00)) {
+ 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);
+ 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);
+ };
+ };
void cPlugin__OnDisable( void ) {
return ( void )cPlugin::OnDisable();
@@ -8130,6 +8183,9 @@ 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);
+ };
Lua__cPlugin( void ): cPlugin(){};
};
@@ -8654,6 +8710,44 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerated00(lua_State* to }
#endif //#ifndef TOLUA_DISABLE
+/* method: cPlugin__OnChunkGenerating of class Lua__cPlugin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00
+static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Lua__cPlugin",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,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)
+ )
+ 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));
+#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);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'cPlugin__OnChunkGenerating'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: new of class Lua__cPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_new00
static int tolua_AllToLua_Lua__cPlugin_new00(lua_State* tolua_S)
@@ -9038,6 +9132,19 @@ public: return ( void ) cPlugin_NewLua:: OnChunkGenerated(a_World,a_ChunkX,a_ChunkZ);
};
};
+ bool OnChunkGenerating( int a_ChunkX, int a_ChunkZ, cLuaChunk* a_pLuaChunk) {
+ if (push_method("OnChunkGenerating", tolua_AllToLua_cPlugin_OnChunkGenerating00)) {
+ 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);
+ 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);
+ };
+ };
void cPlugin_NewLua__OnDisable( void ) {
return ( void )cPlugin_NewLua::OnDisable();
@@ -9084,6 +9191,9 @@ 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);
+ };
};
/* method: tolua__set_instance of class Lua__cPlugin_NewLua */
@@ -17416,6 +17526,78 @@ static int tolua_set_cPacket_BlockPlace_m_Uses(lua_State* tolua_S) }
#endif //#ifndef TOLUA_DISABLE
+/* method: SetBlock of class cLuaChunk */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cLuaChunk_SetBlock00
+static int tolua_AllToLua_cLuaChunk_SetBlock00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cLuaChunk",0,&tolua_err) ||
+ (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3i",0,&tolua_err)) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,5,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cLuaChunk* self = (cLuaChunk*) tolua_tousertype(tolua_S,1,0);
+ const Vector3i* a_Pos = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
+ char a_BlockID = ((char) tolua_tonumber(tolua_S,3,0));
+ unsigned char a_BlockMeta = ((unsigned char) tolua_tonumber(tolua_S,4,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlock'", NULL);
+#endif
+ {
+ self->SetBlock(*a_Pos,a_BlockID,a_BlockMeta);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'SetBlock'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: FillBlocks of class cLuaChunk */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cLuaChunk_FillBlocks00
+static int tolua_AllToLua_cLuaChunk_FillBlocks00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cLuaChunk",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cLuaChunk* self = (cLuaChunk*) tolua_tousertype(tolua_S,1,0);
+ char a_BlockID = ((char) tolua_tonumber(tolua_S,2,0));
+ unsigned char a_BlockMeta = ((unsigned char) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FillBlocks'", NULL);
+#endif
+ {
+ self->FillBlocks(a_BlockID,a_BlockMeta);
+ }
+ }
+ return 0;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'FillBlocks'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* Open function */
TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
{
@@ -18329,6 +18511,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"OnTakeDamage",tolua_AllToLua_cPlugin_OnTakeDamage00);
tolua_function(tolua_S,"OnKilled",tolua_AllToLua_cPlugin_OnKilled00);
tolua_function(tolua_S,"OnChunkGenerated",tolua_AllToLua_cPlugin_OnChunkGenerated00);
+ tolua_function(tolua_S,"OnChunkGenerating",tolua_AllToLua_cPlugin_OnChunkGenerating00);
tolua_function(tolua_S,"GetName",tolua_AllToLua_cPlugin_GetName00);
tolua_function(tolua_S,"SetName",tolua_AllToLua_cPlugin_SetName00);
tolua_function(tolua_S,"GetVersion",tolua_AllToLua_cPlugin_GetVersion00);
@@ -18362,6 +18545,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"cPlugin__OnTakeDamage",tolua_AllToLua_Lua__cPlugin_cPlugin__OnTakeDamage00);
tolua_function(tolua_S,"cPlugin__OnKilled",tolua_AllToLua_Lua__cPlugin_cPlugin__OnKilled00);
tolua_function(tolua_S,"cPlugin__OnChunkGenerated",tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerated00);
+ tolua_function(tolua_S,"cPlugin__OnChunkGenerating",tolua_AllToLua_Lua__cPlugin_cPlugin__OnChunkGenerating00);
tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cPlugin_new00);
tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cPlugin_new00_local);
tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPlugin_new00_local);
@@ -18793,6 +18977,11 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_variable(tolua_S,"m_Count",tolua_get_cPacket_BlockPlace_m_Count,tolua_set_cPacket_BlockPlace_m_Count);
tolua_variable(tolua_S,"m_Uses",tolua_get_cPacket_BlockPlace_m_Uses,tolua_set_cPacket_BlockPlace_m_Uses);
tolua_endmodule(tolua_S);
+ tolua_cclass(tolua_S,"cLuaChunk","cLuaChunk","",NULL);
+ tolua_beginmodule(tolua_S,"cLuaChunk");
+ tolua_function(tolua_S,"SetBlock",tolua_AllToLua_cLuaChunk_SetBlock00);
+ tolua_function(tolua_S,"FillBlocks",tolua_AllToLua_cLuaChunk_FillBlocks00);
+ tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
return 1;
}
diff --git a/source/Bindings.h b/source/Bindings.h index 3e297c930..436844c7c 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,6 @@ /*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 06/09/12 17:10:20.
+** Generated automatically by tolua++-1.0.92 on 06/10/12 15:55:56.
*/
/* Exported function */
diff --git a/source/cChunkGenerator.cpp b/source/cChunkGenerator.cpp index a5bab2b7e..34bbe4b3a 100644 --- a/source/cChunkGenerator.cpp +++ b/source/cChunkGenerator.cpp @@ -11,6 +11,7 @@ #include "FinishGen.h"
#include "cRoot.h"
#include "cPluginManager.h"
+#include "cLuaChunk.h"
@@ -483,18 +484,28 @@ void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ) cEntityList Entities;
cBlockEntityList BlockEntities;
- // Use the composed generator:
- m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, BiomeMap);
- m_HeightGen->GenHeightMap(a_ChunkX, a_ChunkZ, HeightMap);
- m_CompositionGen->ComposeTerrain(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, BiomeMap, Entities, BlockEntities);
- for (cStructureGenList::iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
+
+ cLuaChunk LuaChunk( BlockTypes, BlockMeta, HeightMap, BiomeMap );
+ if( cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_CHUNK_GENERATING, 3, a_ChunkX, a_ChunkZ, &LuaChunk ) )
{
- (*itr)->GenStructures(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, Entities, BlockEntities);
- } // for itr - m_StructureGens[]
- for (cFinishGenList::iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
+ // A plugin interrupted generation, handle something plugin specific?
+ //LOG("returned true");
+ }
+ else
{
- (*itr)->GenFinish(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, BiomeMap, Entities, BlockEntities);
- } // for itr - m_FinishGens[]
+ // Use the composed generator:
+ m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, BiomeMap);
+ m_HeightGen->GenHeightMap(a_ChunkX, a_ChunkZ, HeightMap);
+ m_CompositionGen->ComposeTerrain(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, BiomeMap, Entities, BlockEntities);
+ for (cStructureGenList::iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
+ {
+ (*itr)->GenStructures(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, Entities, BlockEntities);
+ } // for itr - m_StructureGens[]
+ for (cFinishGenList::iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
+ {
+ (*itr)->GenFinish(a_ChunkX, a_ChunkZ, BlockTypes, BlockMeta, HeightMap, BiomeMap, Entities, BlockEntities);
+ } // for itr - m_FinishGens[]
+ }
m_World->SetChunkData(
a_ChunkX, a_ChunkY, a_ChunkZ,
diff --git a/source/cLuaChunk.cpp b/source/cLuaChunk.cpp new file mode 100644 index 000000000..c97595599 --- /dev/null +++ b/source/cLuaChunk.cpp @@ -0,0 +1,4 @@ +#include "Globals.h"
+
+#include "cLuaChunk.h"
+
diff --git a/source/cLuaChunk.h b/source/cLuaChunk.h new file mode 100644 index 000000000..5e1395a4c --- /dev/null +++ b/source/cLuaChunk.h @@ -0,0 +1,39 @@ +#pragma once
+
+#include "ChunkDef.h"
+
+class cLuaChunk //tolua_export
+{ //tolua_export
+public:
+ cLuaChunk( cChunkDef::BlockTypes & a_BlockTypes
+ , cChunkDef::BlockNibbles & a_BlockNibbles
+ , cChunkDef::HeightMap & a_HeightMap
+ , cChunkDef::BiomeMap & a_BiomeMap
+ )
+ : m_BiomeMap( a_BiomeMap )
+ , m_BlockTypes( a_BlockTypes )
+ , m_BlockMeta( a_BlockNibbles )
+ , m_HeightMap( a_HeightMap )
+ {}
+ ~cLuaChunk()
+ {}
+
+ void SetBlock( const Vector3i & a_Pos, char a_BlockID, unsigned char a_BlockMeta ) //tolua_export
+ { //tolua_export
+ } //tolua_export
+
+ void FillBlocks( char a_BlockID, unsigned char a_BlockMeta ) //tolua_export
+ { //tolua_export
+ const NIBBLETYPE CompressedMeta = a_BlockMeta | a_BlockMeta << 4;
+ memset( m_BlockTypes, a_BlockID, sizeof( cChunkDef::BlockTypes ) );
+ memset( m_BlockMeta, CompressedMeta, sizeof( cChunkDef::BlockNibbles ) );
+
+ memset( m_BiomeMap, 0, sizeof( cChunkDef::BiomeMap ) );
+ memset( m_HeightMap, 0, sizeof( cChunkDef::HeightMap ) );
+ } //tolua_export
+private:
+ EMCSBiome * m_BiomeMap;
+ BLOCKTYPE * m_BlockTypes;
+ NIBBLETYPE * m_BlockMeta;
+ HEIGHTTYPE * m_HeightMap;
+}; //tolua_export
\ No newline at end of file diff --git a/source/cPlugin.h b/source/cPlugin.h index 3b29b604f..737c0c382 100644 --- a/source/cPlugin.h +++ b/source/cPlugin.h @@ -14,6 +14,7 @@ class cItem; class cEntity;
class cPawn;
class cWorld;
+class cLuaChunk;
struct TakeDamageInfo;
@@ -49,6 +50,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; }
// Accessors
const char* GetName() const { return m_Name.c_str(); }
diff --git a/source/cPluginManager.cpp b/source/cPluginManager.cpp index 40e8d2b95..ff2fdfb62 100644 --- a/source/cPluginManager.cpp +++ b/source/cPluginManager.cpp @@ -381,6 +381,26 @@ bool cPluginManager::CallHook( PluginHook a_Hook, unsigned int a_NumArgs, ... ) }
break;
}
+
+ case E_PLUGIN_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:
{
@@ -450,19 +470,22 @@ void cPluginManager::UnloadPluginsNow() void cPluginManager::RemoveHooks( cPlugin* a_Plugin )
{
- m_Hooks[ E_PLUGIN_TICK].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_CHAT].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_COLLECT_ITEM].remove( a_Plugin );
- m_Hooks[ E_PLUGIN_BLOCK_DIG].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_BLOCK_PLACE].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_DISCONNECT].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_HANDSHAKE].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_LOGIN].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_PLAYER_SPAWN].remove( a_Plugin );
- m_Hooks[ E_PLUGIN_PLAYER_JOIN].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_PLAYER_MOVE].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_TAKE_DAMAGE].remove ( a_Plugin );
- m_Hooks[ E_PLUGIN_KILLED].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_TICK].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_CHAT].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_COLLECT_ITEM].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_BLOCK_DIG].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_BLOCK_PLACE].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_DISCONNECT].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_HANDSHAKE].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_LOGIN].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_PLAYER_SPAWN].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_PLAYER_JOIN].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_PLAYER_MOVE].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_TAKE_DAMAGE].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_KILLED].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_CHUNK_GENERATED ].remove ( a_Plugin );
+ m_Hooks[ E_PLUGIN_CHUNK_GENERATING ].remove( a_Plugin );
+ m_Hooks[ E_PLUGIN_BLOCK_TO_DROPS ].remove ( a_Plugin );
}
diff --git a/source/cPlugin_NewLua.cpp b/source/cPlugin_NewLua.cpp index 1b617f1ef..fc07b266e 100644 --- a/source/cPlugin_NewLua.cpp +++ b/source/cPlugin_NewLua.cpp @@ -363,6 +363,27 @@ 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 )
+{
+ cCSLock Lock(m_CriticalSection);
+ if (!PushFunction("OnChunkGenerating"))
+ return false;
+
+ tolua_pushnumber (m_LuaState, a_ChunkX);
+ tolua_pushnumber (m_LuaState, a_ChunkZ);
+ tolua_pushusertype(m_LuaState, a_pLuaChunk, "cLuaChunk");
+
+ if( !CallFunction(3, 1, "OnChunkGenerating") )
+ return false;
+
+ bool bRetVal = (tolua_toboolean( m_LuaState, -1, 0) > 0);
+ return bRetVal;
+}
+
+
+
+
+
cWebPlugin_Lua* cPlugin_NewLua::CreateWebPlugin(lua_State* a_LuaState)
{
cCSLock Lock( m_CriticalSection );
diff --git a/source/cPlugin_NewLua.h b/source/cPlugin_NewLua.h index 8fb2e9dc0..096d5667f 100644 --- a/source/cPlugin_NewLua.h +++ b/source/cPlugin_NewLua.h @@ -38,6 +38,7 @@ public: //tolua_export 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;
lua_State* GetLuaState() { return m_LuaState; }
|