From 93e3555eae2deaeca69ee252cfa9cc9c3e0e49ef Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 14 Nov 2016 18:09:59 +0400 Subject: Adding particle blend, glow and animation (#4705) --- src/script/common/c_content.cpp | 13 +++++++------ src/script/common/c_content.h | 2 +- src/script/common/c_converter.cpp | 22 ++++++++++++++++++++++ src/script/common/c_converter.h | 2 ++ 4 files changed, 32 insertions(+), 7 deletions(-) (limited to 'src/script/common') diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index f20a65903..d4a25b68b 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -35,10 +35,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "noise.h" #include -struct EnumString es_TileAnimationType[] = +struct EnumString es_AnimationType[] = { - {TAT_NONE, "none"}, - {TAT_VERTICAL_FRAMES, "vertical_frames"}, + {AT_NONE, "none"}, + {AT_VERTICAL_FRAMES, "vertical_frames"}, + {AT_2D_ANIMATION_SHEET, "2d_animation_sheet"}, {0, NULL}, }; @@ -335,9 +336,9 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype) lua_getfield(L, index, "animation"); if(lua_istable(L, -1)){ // {type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0} - tiledef.animation.type = (TileAnimationType) - getenumfield(L, -1, "type", es_TileAnimationType, - TAT_NONE); + tiledef.animation.type = (AnimationType) + getenumfield(L, -1, "type", es_AnimationType, + AT_NONE); tiledef.animation.aspect_w = getintfield_default(L, -1, "aspect_w", 16); tiledef.animation.aspect_h = diff --git a/src/script/common/c_content.h b/src/script/common/c_content.h index 2a2228b6d..32fdb4f04 100644 --- a/src/script/common/c_content.h +++ b/src/script/common/c_content.h @@ -159,6 +159,6 @@ bool push_json_value (lua_State *L, void read_json_value (lua_State *L, Json::Value &root, int index, u8 recursion = 0); -extern struct EnumString es_TileAnimationType[]; +extern struct EnumString es_AnimationType[]; #endif /* C_CONTENT_H_ */ diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp index f36298915..cfb5e26db 100644 --- a/src/script/common/c_converter.cpp +++ b/src/script/common/c_converter.cpp @@ -513,6 +513,28 @@ int getintfield_default(lua_State *L, int table, return result; } +int check_material_type_param(lua_State *L, int table, + const char *fieldname, int default_) +{ + int material_type_param = + getintfield_default(L, table, fieldname, default_); + u32 alphaSource = (material_type_param & 0x0000F000) >> 12; + u32 modulo = (material_type_param & 0x00000F00) >> 8; + u32 srcFact = (material_type_param & 0x000000F0) >> 4; + u32 dstFact = material_type_param & 0x0000000F; + if (alphaSource <= 3 && modulo <= 4 && srcFact <= 10 && dstFact <= 10) { + return material_type_param; + } else { + std::ostringstream error_text; + error_text << "Incorrect material_type_param value "; + error_text << "for particle or particle spawner."; + error_text << std::endl; + throw LuaError(error_text.str()); + return 0; + } +} + + float getfloatfield_default(lua_State *L, int table, const char *fieldname, float default_) { diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h index a5fbee765..71ac735c1 100644 --- a/src/script/common/c_converter.h +++ b/src/script/common/c_converter.h @@ -45,6 +45,8 @@ float getfloatfield_default(lua_State *L, int table, const char *fieldname, float default_); int getintfield_default (lua_State *L, int table, const char *fieldname, int default_); +int check_material_type_param(lua_State *L, int table, + const char *fieldname, int default_); bool getstringfield(lua_State *L, int table, const char *fieldname, std::string &result); -- cgit v1.2.3