My Project
Static Public Member Functions | List of all members
ParaScripting::ParaWorld Class Reference

world creation functions. More...

#include <ParaScriptingWorld.h>

Static Public Member Functions

static string NewWorld (const char *sWorldName, const char *sBaseWorldName)
 created a new empty world based on a given world. More...
 
static const char * NewWorld_ (const char *sWorldName, const char *sBaseWorldName)
 solely used for exporting
 
static void DeleteWorld (const char *sWorldName)
 delete a given world. More...
 
static string NewEmptyWorld (const char *sWorldName=NULL, float fTileSize=533.3333f, int nTileDimension=64)
 Create an empty world, with flat land. More...
 
static bool CreateRawTerrainFile (const char *sFilename, float fHeight=0.f, int nDimension=129)
 create a raw terrain file
 
static const char * NewEmptyWorld_ (const char *sWorldName=NULL, float fTileSize=533.3333f, int nTileDimension=64)
 solely used for exporting
 
static void SetEnablePathEncoding (bool bEnable)
 set whether we will encode world related files. More...
 
static bool GetEnablePathEncoding ()
 get whether we will encode world related files. More...
 
static ParaDataProvider GetNpcDB ()
 get the current NPC data provider. More...
 
static void GetNpcDB_ (ParaDataProvider *out)
 solely used for exporting
 
static void SetNpcDB (const char *sConnectionstring)
 set the global NPC data base to a new database file. More...
 
static ParaDataProvider GetAttributeProvider ()
 get the current attribute data provider. More...
 
static void GetAttributeProvider_ (ParaDataProvider *out)
 solely used for exporting
 
static void SetAttributeProvider (const char *sConnectionstring)
 set the current attribute data base to a new database file. More...
 
static void SetWorldDB (const char *sConnectionstring)
 set world database. More...
 
static string GetStringbyID (int ID)
 Get string from ID. More...
 
static int InsertString (const char *strEN, const char *strCN)
 Insert the new string table entry to StringTable_DB. More...
 
static void SetServerState (int nState)
 set the current server state. More...
 
static int GetServerState ()
 
static bool SendTerrainUpdate (const char *sDestination, float center_x, float center_y, float center_z, float fRadius, float fResolution)
 Call this function to send a copy of the local terrain to a destination world at a given resolution. More...
 
static string GetWorldName ()
 get current world name
 
static string GetWorldDirectory ()
 get world root path. More...
 
static void SetScriptSandBox (const object &SandboxNeuronFile)
 Paraworld is told to execute in the given sandbox. More...
 
static const char * GetScriptSandBox ()
 please see SetScriptSandBox() More...
 

Detailed Description

world creation functions.

Member Function Documentation

§ DeleteWorld()

void ParaWorld::DeleteWorld ( const char *  sWorldName)
static

delete a given world.

§ GetAttributeProvider()

ParaDataProvider ParaWorld::GetAttributeProvider ( )
static

get the current attribute data provider.

§ GetEnablePathEncoding()

bool ParaScripting::ParaWorld::GetEnablePathEncoding ( )
static

get whether we will encode world related files.

default to true. By enabling path encoding, world related files like "worlddir/worldfile.txt" will be saved as "%WORLD%/worldfile.txt", thus even the entire world directory changes, the world files can still be found using path variables. Path encoding needs to be disabled when you are creating a template world.

§ GetNpcDB()

ParaDataProvider ParaWorld::GetNpcDB ( )
static

get the current NPC data provider.

§ GetScriptSandBox()

const char * ParaScripting::ParaWorld::GetScriptSandBox ( )
static

please see SetScriptSandBox()

Returns
: it may return NULL if the sandbox does not exist.

§ GetStringbyID()

string ParaWorld::GetStringbyID ( int  ID)
static

Get string from ID.

Parameters
IDID in kids db's string table.
Returns
string in the current game language

§ GetWorldDirectory()

string ParaWorld::GetWorldDirectory ( )
static

get world root path.

suppose the given world name is "sample". The generated file name is "sample/"

§ InsertString()

int ParaWorld::InsertString ( const char *  strEN,
const char *  strCN 
)
static

Insert the new string table entry to StringTable_DB.

Parameters
strEntry in the current game language
Returns
ID of the inserted string

§ NewEmptyWorld()

string ParaWorld::NewEmptyWorld ( const char *  sWorldName = NULL,
float  fTileSize = 533.3333f,
int  nTileDimension = 64 
)
static

Create an empty world, with flat land.

Parameters
sWorldNameworld name, if NULL, it defaults to "_emptyworld"
fTileSizeterrain tile size in meters
nTileDimensiondimension of the tile matrix. default is 64, which is has 64*64 tiles

§ NewWorld()

string ParaWorld::NewWorld ( const char *  sWorldName,
const char *  sBaseWorldName 
)
static

created a new empty world based on a given world.

This is like class inheritance in C++ another world could derive from a given world, overriding certain terrain tile contents as it evolves. One can immediately create the new world which is identical to the base world. Every changes made to the new world will be saved in the new world folder and will not affect the base world. in reality, we just copy the base world's world config file to the new world using the new world's name. e.g
local sConfigFileName = ParaWorld.NewWorld("__TmpWorld", "sample/worldconfig.txt");
if(sConfigFileName ~= "") then
ParaScene.CreateWorld("", 32000, sConfigFileName);
end
NOTE: if the sWorldName is the same as sBaseWorldName, the sBaseWorldName itself will be overridden

Parameters
sWorldNameworld name, a directory with the same name will be created containing the world config file.
sBaseWorldNameany valid world config file.
Returns
: return the world config file. if failed, return ""

§ SendTerrainUpdate()

bool ParaWorld::SendTerrainUpdate ( const char *  sDestination,
float  center_x,
float  center_y,
float  center_z,
float  fRadius,
float  fResolution 
)
static

Call this function to send a copy of the local terrain to a destination world at a given resolution.

Parameters
sDestinationa destination namespace, it could be "all@server" or "@server", etc. This will be used to fill the destination address of the packet to be sent.
center_xcenter of the terrain region to send
center_ycenter of the terrain region to send
center_zcenter of the terrain region to send
fRadiusradius of the terrain region to send
fResolutionif this is 1.f, the local world terrain grid resolution is used.
Returns

§ SetAttributeProvider()

void ParaWorld::SetAttributeProvider ( const char *  sConnectionstring)
static

set the current attribute data base to a new database file.

Parameters
sConnectionstring: currently it is the file path of the database file.

§ SetEnablePathEncoding()

void ParaScripting::ParaWorld::SetEnablePathEncoding ( bool  bEnable)
static

set whether we will encode world related files.

default to true. By enabling path encoding, world related files like "worlddir/worldfile.txt" will be saved as "%WORLD%/worldfile.txt", thus even the entire world directory changes, the world files can still be found using path variables. Path encoding needs to be disabled when you are creating a template world.

§ SetNpcDB()

void ParaWorld::SetNpcDB ( const char *  sConnectionstring)
static

set the global NPC data base to a new database file.

Parameters
sConnectionstring: currently it is the file path of the database file.

§ SetScriptSandBox()

void ParaScripting::ParaWorld::SetScriptSandBox ( const object SandboxNeuronFile)
static

Paraworld is told to execute in the given sandbox.

(1) ParaWorld namespace supports a sandbox mode, which can be turned on and off on demand. Once turned on, all scripts from the current game world will be executed in a separate and newly created script runtime environment. (2) Sandbox mode is an isolated mode that does not have any link with the glia file environment. (3) The world scripts protected by the sandbox runtime environment includes: terrain tile onload script, biped event handler scripts, such as character onload, onclick events. (4) The sandbox environment includes the following functions that could be used: ParaScene, ParaUI namespace functions. It also explicitly disabled the following functions: a) Dofile() b) Io, ParaIO, Exec c) Require(),NPL.load, NPL.activate, NPL.download: cut off any way to manually load a file. It adds d) Log e) Download some file to replace local file. f) Changing the Enter sand box function or almost any function to some fake function. (5) The following attack methods should be prevented by the sandbox environment a) Execute or load any external application b) Write to any file, including log file c) Compromise data or functions in the glia file environment. Such as, changing and hooking the string method d) Compromise the sandbox itself and then affect in the next sandbox entity. (6) glia file environment does not have a sandbox mode. Because I found that any global sandbox mode implementation has a way to hack in, and I give up any measure of protecting the glia file environment. Sandbox protection for the world file is enough because that is the only source file that may not be provided by ParaEngine. In order to run any other code not provided by the ParaEngine, the user should have been well informed of the danger. But so far, there is no need to have a world that should inform the user. Because most world functions are supported in the world sandbox.

Parameters
sNeuronFileNamescript file name. Use NPL.CreateNeuronFile() to create a sandbox neuron file if you do not want to use a sandbox, please specify NULL or "".

§ SetServerState()

void ParaWorld::SetServerState ( int  nState)
static

set the current server state.

default value is 0. enum CurrentState { STATE_STAND_ALONE = 0, STATE_SERVER, STATE_CLIENT, };

§ SetWorldDB()

void ParaWorld::SetWorldDB ( const char *  sConnectionstring)
static

set world database.

it sets attribute provider, NPC database, etc to the same database file.

Parameters
sConnectionstring: currently it is the file path of the database file.

The documentation for this class was generated from the following files: