diff --git a/.gitignore b/.gitignore index 3d527200..8fd07838 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Compile output build/ +lib/libgit2/ *.o zh_CN.qm @@ -34,6 +35,7 @@ QtQuick/ QtQuick.2/ Qt5Compat/ QtQml/ +QtMultimedia/ sqldrivers/ styles/ tls/ diff --git a/.gitmodules b/.gitmodules index d914762f..3b4bdf52 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "fkparse"] path = fkparse url = https://github.com/Notify-ctrl/fkparse +[submodule "include"] + path = include + url = https://github.com/Notify-ctrl/fk_headers diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b252f9f..87746cc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(REQUIRED_QT_VERSION "6.3") include_directories(include/lua) -include_directories(include/sqlite3) +include_directories(include) +include_directories(include/libgit2) include_directories(src) include_directories(src/client) include_directories(src/core) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index e6b638d9..535c1509 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -6,6 +6,7 @@ android:versionName="1.0"> + Build.VERSION_CODES.KITKAT) { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); +} +if (Build.VERSION.SDK_INT > 28) { + WindowManager.LayoutParams lp = getWindow().getAttributes(); + lp.layoutInDisplayCutoutMode = LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; + getWindow().setAttributes(lp); +} +``` + ___ ## WASM下编译 diff --git a/doc/dev/database.md b/doc/dev/database.md index 413226f0..310b16dc 100644 --- a/doc/dev/database.md +++ b/doc/dev/database.md @@ -7,3 +7,9 @@ ___ FreeKill 使用 sqlite3 数据库。 关于数据库的组织,详见server/init.sql。单纯存个用户名和密码而已 + +## 服务端用来管理用户的数据库 + +保存用户名与密码而已。 + +## 包管理用的数据库 diff --git a/doc/dev/index.md b/doc/dev/index.md index 2c0900d0..8ef39e21 100644 --- a/doc/dev/index.md +++ b/doc/dev/index.md @@ -11,3 +11,4 @@ FreeKill采用Qt框架提供底层支持,在上层使用lua语言开发。在U - [游戏逻辑](./gamelogic.md) - [数据库](./database.md) - [UI](./ui.md) +- [包管理](./package.md) diff --git a/doc/dev/package.md b/doc/dev/package.md new file mode 100644 index 00000000..6ae87739 --- /dev/null +++ b/doc/dev/package.md @@ -0,0 +1,51 @@ +# FreeKill 的包管理策略 + +> [dev](./index.md) > 包管理 + +___ + +FreeKill使用git进行包管理,具体而言是使用libgit2库进行管理。 + +## 包的组织 + +所有拓展包都位于packages/目录下。其中,standard(标包)、standard_cards(标包卡牌)和manuvering_cards(军争卡牌, TODO )属于基础拓展,其直接处于FreeKill的项目仓库之下。其他所有的拓展均处于项目之外。 + +每个拓展包都是一个单独的文件夹,内含代码文件(init.lua,以及诸如其他lua文件和fkp文件等等)和音图等资源文件。关于具体如何组织各种文件,请参照已有的拓展包。 + +## 包的管理 + +包管理使用git,以下使用类似git命令行的方式解说。 + +首先,packages中除了基本的三个包之外,其他的包都要从仓库中排除掉。这方面由一个.gitignore文件控制。 + +然后,在packages目录下,有一个名为packages.db的文件统领所有拓展包。这是个sqlite数据库,结构详见[数据库](./database.md)。 + +下面从连接过程中简要分析这个文件的作用: + +1. 当一个客户端尝试对服务端发起连接请求的时候,首先它们之间会先比较MD5值。 +2. 如果MD5通过则无事发生,否则服务端会把自己的packages.db中的关键信息发送给客户端。 +3. 客户端根据文件内容检查自己的拓展包。如果那个文件夹存在,那么就git fetch -> git checkout \。 +4. 如果文件夹不存在,那么先git clone,然后再checkout。 +5. 做完这些后,客户端再次发起请求。若仍不通过,则向用户通知错误信息。 + +在这个过程中,如果出现任何一个文件夹内有未提交的更改(拓展包开发者有时候可能因为疏忽而未通过MD5检查),或者出现根本不是git仓库的文件夹,那么都会直接进入报错环节。 + +有时候客户端会包含服务端所没有的拓展包,这时候比起直接删除之,更加明智的选择是将其标记为禁用。将拓展包文件夹的名字设为xxx.disabled即可将拓展包标记为禁用的拓展包。禁用的拓展包不会被游戏加载,也不会被MD5检测计入。 + +## 包的托管 + +一般来说都是推荐将项目放在github上面的,但由于FreeKill暂且不考虑国际化且必须照顾广大玩家的体验,因此将拓展包托管到github可能不是一个明智的选择。推荐将拓展包托管到gitee平台,或者其他的好办法也行。 + +总之有一点要注意的是,packages.db中的url需要是国内访问比较方便的网站才行。 + +## 包的部署 + +此处不讨论具体如何编写代码,单论在这个管理框架下如何进行开发。 + +一般来说,在对一个仓库进行开发时,由于目前各托管平台都用SSH Key认证而非用户名密码,因此仓库的URL通常为git@gitxxx.com:xxxx/xxxx.git。这样的URL有一个问题就在于只有认证过的用户可以clone,而非所有人。 + +因此在部署的时候,一定要保证所有url都是https://xxxx。这一点FreeKill是不会进行检测的。 + +## 包的下载与更新(TODO) + +客户端使用GUI,服务端使用Fk shell或者直接编辑packages.db。 diff --git a/doc/dev/protocol.md b/doc/dev/protocol.md index 1b8a65b5..151c060d 100644 --- a/doc/dev/protocol.md +++ b/doc/dev/protocol.md @@ -147,3 +147,15 @@ ___ 旁观者的处理方式或许可以像观看录像那样,过滤所有的request事件。这样就确确实实只能看着了。 而不过滤request的旁观就可以理解为操控其他玩家了。hhh + +总而言之,旁观的处理流程基本如下: + +1. 客户端从大厅中发起旁观房间的请求。 +2. 服务器知晓后,进行一些C++的活,把这个玩家加到房间去。 +3. 之后把这个请求丢到请求列表去。等房间让出协程后,进行对旁观玩家的处理流程。 +4. Lua中如同断线重连那样,肯定要让玩家知晓房间内的状况。 +5. 此时由于Lua的Room中并没有这个玩家,因此也要新建一个SPlayer对象。 +6. 但这种Player比较特殊,他与游戏无关,所以肯定不能加到Room的players中。考虑另外弄个数组,但是这样就可能被notify函数啥的过滤掉了。 +7. 这种情况下可以魔改doBroadcastNotify函数,如果是对全员广播消息的话,那么也跟旁观者说一声。 + +考虑到UI中是以fk.Self决定主视角,因此有必要发一条Setup信息改掉旁观者视角?或者修改Room.qml专门适配旁观者。 diff --git a/fkparse b/fkparse index bbf45faf..d150d2ee 160000 --- a/fkparse +++ b/fkparse @@ -1 +1 @@ -Subproject commit bbf45faf7dd67fca4bedf535c14a8037990a7399 +Subproject commit d150d2eec986c49a16f9e84772525a4fb7a84926 diff --git a/image/generals/0.jpg b/image/generals/0.jpg new file mode 100644 index 00000000..5d95d0bb Binary files /dev/null and b/image/generals/0.jpg differ diff --git a/image/logo/git2.png b/image/logo/git2.png new file mode 100644 index 00000000..de9bfbdd Binary files /dev/null and b/image/logo/git2.png differ diff --git a/include b/include new file mode 160000 index 00000000..4fd2070d --- /dev/null +++ b/include @@ -0,0 +1 @@ +Subproject commit 4fd2070d099d1f967d1070d72beb0fae2cb6e4be diff --git a/include/lua/lapi.h b/include/lua/lapi.h deleted file mode 100644 index 72e21cce..00000000 --- a/include/lua/lapi.h +++ /dev/null @@ -1,40 +0,0 @@ -# 1 "./lua/lapi.h" - - - - - - -#ifndef lapi_h -#define lapi_h - - -#include "llimits.h" -#include "lstate.h" - - - -#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ - "stack overflow");} - - - - - - - -#define adjustresults(L,nres) \ - { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } - - - -#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ - "not enough elements in the stack") -# 43 "./lua/lapi.h" -#define hastocloseCfunc(n) ((n) < LUA_MULTRET) - - -#define codeNresults(n) (-(n) - 3) -#define decodeNresults(n) (-(n) - 3) - -#endif diff --git a/include/lua/lauxlib.h b/include/lua/lauxlib.h deleted file mode 100644 index fa177223..00000000 --- a/include/lua/lauxlib.h +++ /dev/null @@ -1,252 +0,0 @@ -# 1 "./lua/lauxlib.h" - - - - - - - -#ifndef lauxlib_h -#define lauxlib_h - - -#include -#include - -#include "luaconf.h" -#include "lua.h" - - - -#define LUA_GNAME "_G" - - -typedef struct luaL_Buffer luaL_Buffer; - - - -#define LUA_ERRFILE (LUA_ERRERR+1) - - - -#define LUA_LOADED_TABLE "_LOADED" - - - -#define LUA_PRELOAD_TABLE "_PRELOAD" - - -typedef struct luaL_Reg { - const char *name; - lua_CFunction func; -} luaL_Reg; - - -#define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number)) - -LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz); -#define luaL_checkversion(L) \ - luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES) - -LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); -LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); -LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); -LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); -LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname); -LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, - size_t *l); -LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, - const char *def, size_t *l); -LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg); -LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def); - -LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); -LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, - lua_Integer def); - -LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); -LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); -LUALIB_API void (luaL_checkany) (lua_State *L, int arg); - -LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); -LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); -LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); -LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); - -LUALIB_API void (luaL_where) (lua_State *L, int lvl); -LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); - -LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, - const char *const lst[]); - -LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); -LUALIB_API int (luaL_execresult) (lua_State *L, int stat); - - - -#define LUA_NOREF (-2) -#define LUA_REFNIL (-1) - -LUALIB_API int (luaL_ref) (lua_State *L, int t); -LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); - -LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, - const char *mode); - -#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) - -LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, - const char *name, const char *mode); -LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); - -LUALIB_API lua_State *(luaL_newstate) (void); - -LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); - -LUALIB_API void (luaL_addgsub) (luaL_Buffer *b, const char *s, - const char *p, const char *r); -LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, - const char *p, const char *r); - -LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); - -LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); - -LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, - const char *msg, int level); - -LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, - lua_CFunction openf, int glb); -# 127 "./lua/lauxlib.h" -#define luaL_newlibtable(L,l) \ - lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) - -#define luaL_newlib(L,l) \ - (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) - -#define luaL_argcheck(L,cond,arg,extramsg) \ - ((void)(luai_likely(cond) || luaL_argerror(L, (arg), (extramsg)))) - -#define luaL_argexpected(L,cond,arg,tname) \ - ((void)(luai_likely(cond) || luaL_typeerror(L, (arg), (tname)))) - -#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) -#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) - -#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) - -#define luaL_dofile(L,fn) \ - (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) - -#define luaL_dostring(L,s) \ - (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) - -#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) - -#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) - -#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) - - - - - - -#define luaL_intop(op,v1,v2) \ - ((lua_Integer)((lua_Unsigned)(v1) op (lua_Unsigned)(v2))) - - - -#define luaL_pushfail(L) lua_pushnil(L) - - - - - -#if !defined(lua_assert) - -#if defined LUAI_ASSERT - #include - #define lua_assert(c) assert(c) -#else - #define lua_assert(c) ((void)0) -#endif - -#endif -# 191 "./lua/lauxlib.h" -struct luaL_Buffer { - char *b; - size_t size; - size_t n; - lua_State *L; - union { - LUAI_MAXALIGN; - char b[LUAL_BUFFERSIZE]; - } init; -}; - - -#define luaL_bufflen(bf) ((bf)->n) -#define luaL_buffaddr(bf) ((bf)->b) - - -#define luaL_addchar(B,c) \ - ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ - ((B)->b[(B)->n++] = (c))) - -#define luaL_addsize(B,s) ((B)->n += (s)) - -#define luaL_buffsub(B,s) ((B)->n -= (s)) - -LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); -LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); -LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); -LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); -LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); -LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); -LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); -LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); - -#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) -# 242 "./lua/lauxlib.h" -#define LUA_FILEHANDLE "FILE*" - - -typedef struct luaL_Stream { - FILE *f; - lua_CFunction closef; -} luaL_Stream; -# 259 "./lua/lauxlib.h" -#if !defined(lua_writestring) -#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) -#endif - - -#if !defined(lua_writeline) -#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout)) -#endif - - -#if !defined(lua_writestringerror) -#define lua_writestringerror(s,p) \ - (fprintf(stderr, (s), (p)), fflush(stderr)) -#endif -# 282 "./lua/lauxlib.h" -#if defined(LUA_COMPAT_APIINTCASTS) - -#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) -#define luaL_optunsigned(L,a,d) \ - ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) - -#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) -#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) - -#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) -#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) - -#endif - - - - -#endif diff --git a/include/lua/lcode.h b/include/lua/lcode.h deleted file mode 100644 index cd882d93..00000000 --- a/include/lua/lcode.h +++ /dev/null @@ -1,105 +0,0 @@ -# 1 "./lua/lcode.h" - - - - - - -#ifndef lcode_h -#define lcode_h - -#include "llex.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" - - - - - - -#define NO_JUMP (-1) - - - - - -typedef enum BinOpr { - - OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, - OPR_DIV, OPR_IDIV, - - OPR_BAND, OPR_BOR, OPR_BXOR, - OPR_SHL, OPR_SHR, - - OPR_CONCAT, - - OPR_EQ, OPR_LT, OPR_LE, - OPR_NE, OPR_GT, OPR_GE, - - OPR_AND, OPR_OR, - OPR_NOBINOPR -} BinOpr; - - - -#define foldbinop(op) ((op) <= OPR_SHR) - - -#define luaK_codeABC(fs,o,a,b,c) luaK_codeABCk(fs,o,a,b,c,0) - - -typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; - - - -#define getinstruction(fs,e) ((fs)->f->code[(e)->u.info]) - - -#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) - -#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) - -LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); -LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); -LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx); -LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, - int B, int C, int k); -LUAI_FUNC int luaK_isKint (expdesc *e); -LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); -LUAI_FUNC void luaK_fixline (FuncState *fs, int line); -LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); -LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); -LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); -LUAI_FUNC void luaK_int (FuncState *fs, int reg, lua_Integer n); -LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); -LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); -LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); -LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); -LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_jump (FuncState *fs); -LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); -LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); -LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); -LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); -LUAI_FUNC int luaK_getlabel (FuncState *fs); -LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); -LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); -LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, - expdesc *v2, int line); -LUAI_FUNC void luaK_settablesize (FuncState *fs, int pc, - int ra, int asize, int hsize); -LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); -LUAI_FUNC void luaK_finish (FuncState *fs); -LUAI_FUNC l_noret luaK_semerror (LexState *ls, const char *msg); - - -#endif diff --git a/include/lua/lctype.h b/include/lua/lctype.h deleted file mode 100644 index c7f7db04..00000000 --- a/include/lua/lctype.h +++ /dev/null @@ -1,87 +0,0 @@ -# 1 "./lua/lctype.h" - - - - - - -#ifndef lctype_h -#define lctype_h - -#include "lua.h" -# 19 "./lua/lctype.h" -#if !defined(LUA_USE_CTYPE) - -#if 'A' == 65 && '0' == 48 - -#define LUA_USE_CTYPE 0 -#else - -#define LUA_USE_CTYPE 1 -#endif - -#endif - - -#if !LUA_USE_CTYPE - -#include - -#include "llimits.h" - - -#define ALPHABIT 0 -#define DIGITBIT 1 -#define PRINTBIT 2 -#define SPACEBIT 3 -#define XDIGITBIT 4 - - -#define MASK(B) (1 << (B)) - - - - - -#define testprop(c,p) (luai_ctype_[(c)+1] & (p)) - - - - -#define lislalpha(c) testprop(c, MASK(ALPHABIT)) -#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) -#define lisdigit(c) testprop(c, MASK(DIGITBIT)) -#define lisspace(c) testprop(c, MASK(SPACEBIT)) -#define lisprint(c) testprop(c, MASK(PRINTBIT)) -#define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) -# 71 "./lua/lctype.h" -#define ltolower(c) \ - check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \ - (c) | ('A' ^ 'a')) - - - -LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];) - - -#else - - - - - -#include - - -#define lislalpha(c) (isalpha(c) || (c) == '_') -#define lislalnum(c) (isalnum(c) || (c) == '_') -#define lisdigit(c) (isdigit(c)) -#define lisspace(c) (isspace(c)) -#define lisprint(c) (isprint(c)) -#define lisxdigit(c) (isxdigit(c)) - -#define ltolower(c) (tolower(c)) - -#endif - -#endif diff --git a/include/lua/ldebug.h b/include/lua/ldebug.h deleted file mode 100644 index f9dfb9fc..00000000 --- a/include/lua/ldebug.h +++ /dev/null @@ -1,64 +0,0 @@ -# 1 "./lua/ldebug.h" - - - - - - -#ifndef ldebug_h -#define ldebug_h - - -#include "lstate.h" - - -#define pcRel(pc,p) (cast_int((pc) - (p)->code) - 1) - - - -#define ci_func(ci) (clLvalue(s2v((ci)->func))) - - -#define resethookcount(L) (L->hookcount = L->basehookcount) - - - - - -#define ABSLINEINFO (-0x80) - - - - - - -#if !defined(MAXIWTHABS) -#define MAXIWTHABS 128 -#endif - - -LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc); -LUAI_FUNC const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, - StkId *pos); -LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, - const char *opname); -LUAI_FUNC l_noret luaG_callerror (lua_State *L, const TValue *o); -LUAI_FUNC l_noret luaG_forerror (lua_State *L, const TValue *o, - const char *what); -LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, - const TValue *p2, - const char *msg); -LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); -LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, - TString *src, int line); -LUAI_FUNC l_noret luaG_errormsg (lua_State *L); -LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc); - - -#endif diff --git a/include/lua/ldo.h b/include/lua/ldo.h deleted file mode 100644 index f313ba47..00000000 --- a/include/lua/ldo.h +++ /dev/null @@ -1,69 +0,0 @@ -# 1 "./lua/ldo.h" - - - - - - -#ifndef ldo_h -#define ldo_h - - -#include "lobject.h" -#include "lstate.h" -#include "lzio.h" -# 25 "./lua/ldo.h" -#define luaD_checkstackaux(L,n,pre,pos) \ - if (l_unlikely(L->stack_last - L->top <= (n))) \ - { pre; luaD_growstack(L, n, 1); pos; } \ - else { condmovestack(L,pre,pos); } - - -#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) - - - -#define savestack(L,p) ((char *)(p) - (char *)L->stack) -#define restorestack(L,n) ((StkId)((char *)L->stack + (n))) - - - -#define checkstackGCp(L,n,p) \ - luaD_checkstackaux(L, n, \ - ptrdiff_t t__ = savestack(L, p); \ - luaC_checkGC(L), \ - p = restorestack(L, t__)) - - - -#define checkstackGC(L,fsize) \ - luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) - - - -typedef void (*Pfunc) (lua_State *L, void *ud); - -LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); -LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, - const char *mode); -LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, - int fTransfer, int nTransfer); -LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); -LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1, int delta); -LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); -LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); -LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); -LUAI_FUNC StkId luaD_tryfuncTM (lua_State *L, StkId func); -LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); -LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, - ptrdiff_t oldtop, ptrdiff_t ef); -LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres); -LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror); -LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror); -LUAI_FUNC void luaD_shrinkstack (lua_State *L); -LUAI_FUNC void luaD_inctop (lua_State *L); - -LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); -LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); - -#endif diff --git a/include/lua/lfunc.h b/include/lua/lfunc.h deleted file mode 100644 index 3073c921..00000000 --- a/include/lua/lfunc.h +++ /dev/null @@ -1,65 +0,0 @@ -# 1 "./lua/lfunc.h" - - - - - - -#ifndef lfunc_h -#define lfunc_h - - -#include "lobject.h" - - -#define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \ - cast_int(sizeof(TValue)) * (n)) - -#define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \ - cast_int(sizeof(TValue *)) * (n)) - - - -#define isintwups(L) (L->twups != L) - - - - - - -#define MAXUPVAL 255 - - -#define upisopen(up) ((up)->v != &(up)->u.value) - - -#define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v)) - - - - - - -#define MAXMISS 10 - - - - -#define CLOSEKTOP (-1) - - -LUAI_FUNC Proto *luaF_newproto (lua_State *L); -LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals); -LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals); -LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); -LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); -LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); -LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level); -LUAI_FUNC void luaF_close (lua_State *L, StkId level, int status, int yy); -LUAI_FUNC void luaF_unlinkupval (UpVal *uv); -LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); -LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, - int pc); - - -#endif diff --git a/include/lua/lgc.h b/include/lua/lgc.h deleted file mode 100644 index 7889944a..00000000 --- a/include/lua/lgc.h +++ /dev/null @@ -1,167 +0,0 @@ -# 1 "./lua/lgc.h" - - - - - - -#ifndef lgc_h -#define lgc_h - - -#include "lobject.h" -#include "lstate.h" -# 31 "./lua/lgc.h" -#define GCSpropagate 0 -#define GCSenteratomic 1 -#define GCSatomic 2 -#define GCSswpallgc 3 -#define GCSswpfinobj 4 -#define GCSswptobefnz 5 -#define GCSswpend 6 -#define GCScallfin 7 -#define GCSpause 8 - - -#define issweepphase(g) \ - (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend) -# 54 "./lua/lgc.h" -#define keepinvariant(g) ((g)->gcstate <= GCSatomic) - - - - - -#define resetbits(x,m) ((x) &= cast_byte(~(m))) -#define setbits(x,m) ((x) |= (m)) -#define testbits(x,m) ((x) & (m)) -#define bitmask(b) (1<<(b)) -#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) -#define l_setbit(x,b) setbits(x, bitmask(b)) -#define resetbit(x,b) resetbits(x, bitmask(b)) -#define testbit(x,b) testbits(x, bitmask(b)) - - - - - - - -#define WHITE0BIT 3 -#define WHITE1BIT 4 -#define BLACKBIT 5 -#define FINALIZEDBIT 6 - -#define TESTBIT 7 - - - -#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) - - -#define iswhite(x) testbits((x)->marked, WHITEBITS) -#define isblack(x) testbit((x)->marked, BLACKBIT) -#define isgray(x) \ - (!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT))) - -#define tofinalize(x) testbit((x)->marked, FINALIZEDBIT) - -#define otherwhite(g) ((g)->currentwhite ^ WHITEBITS) -#define isdeadm(ow,m) ((m) & (ow)) -#define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) - -#define changewhite(x) ((x)->marked ^= WHITEBITS) -#define nw2black(x) \ - check_exp(!iswhite(x), l_setbit((x)->marked, BLACKBIT)) - -#define luaC_white(g) cast_byte((g)->currentwhite & WHITEBITS) - - - -#define G_NEW 0 -#define G_SURVIVAL 1 -#define G_OLD0 2 -#define G_OLD1 3 -#define G_OLD 4 -#define G_TOUCHED1 5 -#define G_TOUCHED2 6 - -#define AGEBITS 7 - -#define getage(o) ((o)->marked & AGEBITS) -#define setage(o,a) ((o)->marked = cast_byte(((o)->marked & (~AGEBITS)) | a)) -#define isold(o) (getage(o) > G_SURVIVAL) - -#define changeage(o,f,t) \ - check_exp(getage(o) == (f), (o)->marked ^= ((f)^(t))) - - - -#define LUAI_GENMAJORMUL 100 -#define LUAI_GENMINORMUL 20 - - -#define LUAI_GCPAUSE 200 - - - - - -#define getgcparam(p) ((p) * 4) -#define setgcparam(p,v) ((p) = (v) / 4) - -#define LUAI_GCMUL 100 - - -#define LUAI_GCSTEPSIZE 13 - - - - - - - -#define isdecGCmodegen(g) (g->gckind == KGC_GEN || g->lastatomic != 0) - - - - - -#define GCSTPUSR 1 -#define GCSTPGC 2 -#define GCSTPCLS 4 -#define gcrunning(g) ((g)->gcstp == 0) -# 167 "./lua/lgc.h" -#define luaC_condGC(L,pre,pos) \ - { if (G(L)->GCdebt > 0) { pre; luaC_step(L); pos;}; \ - condchangemem(L,pre,pos); } - - -#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0) - - -#define luaC_barrier(L,p,v) ( \ - (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \ - luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0)) - -#define luaC_barrierback(L,p,v) ( \ - (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \ - luaC_barrierback_(L,p) : cast_void(0)) - -#define luaC_objbarrier(L,p,o) ( \ - (isblack(p) && iswhite(o)) ? \ - luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0)) - -LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o); -LUAI_FUNC void luaC_freeallobjects (lua_State *L); -LUAI_FUNC void luaC_step (lua_State *L); -LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); -LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); -LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz); -LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); -LUAI_FUNC void luaC_barrierback_ (lua_State *L, GCObject *o); -LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); -LUAI_FUNC void luaC_changemode (lua_State *L, int newmode); - - -#endif diff --git a/include/lua/ljumptab.h b/include/lua/ljumptab.h deleted file mode 100644 index bf1f502f..00000000 --- a/include/lua/ljumptab.h +++ /dev/null @@ -1,113 +0,0 @@ -# 1 "./lua/ljumptab.h" - - - - - - - -#undef vmdispatch -#undef vmcase -#undef vmbreak - -#define vmdispatch(x) goto *disptab[x]; - -#define vmcase(l) L_ ##l: - -#define vmbreak vmfetch(); vmdispatch(GET_OPCODE(i)); - - -static const void *const disptab[NUM_OPCODES] = { - -#if 0 -** you can update the following list with this command: -** -** sed -n '/^OP_/\!d; s/OP_/\&\&L_OP_/ ; s/,.*/,/ ; s/\/.*// ; p' lopcodes.h -** -#endif - -&&L_OP_MOVE, -&&L_OP_LOADI, -&&L_OP_LOADF, -&&L_OP_LOADK, -&&L_OP_LOADKX, -&&L_OP_LOADFALSE, -&&L_OP_LFALSESKIP, -&&L_OP_LOADTRUE, -&&L_OP_LOADNIL, -&&L_OP_GETUPVAL, -&&L_OP_SETUPVAL, -&&L_OP_GETTABUP, -&&L_OP_GETTABLE, -&&L_OP_GETI, -&&L_OP_GETFIELD, -&&L_OP_SETTABUP, -&&L_OP_SETTABLE, -&&L_OP_SETI, -&&L_OP_SETFIELD, -&&L_OP_NEWTABLE, -&&L_OP_SELF, -&&L_OP_ADDI, -&&L_OP_ADDK, -&&L_OP_SUBK, -&&L_OP_MULK, -&&L_OP_MODK, -&&L_OP_POWK, -&&L_OP_DIVK, -&&L_OP_IDIVK, -&&L_OP_BANDK, -&&L_OP_BORK, -&&L_OP_BXORK, -&&L_OP_SHRI, -&&L_OP_SHLI, -&&L_OP_ADD, -&&L_OP_SUB, -&&L_OP_MUL, -&&L_OP_MOD, -&&L_OP_POW, -&&L_OP_DIV, -&&L_OP_IDIV, -&&L_OP_BAND, -&&L_OP_BOR, -&&L_OP_BXOR, -&&L_OP_SHL, -&&L_OP_SHR, -&&L_OP_MMBIN, -&&L_OP_MMBINI, -&&L_OP_MMBINK, -&&L_OP_UNM, -&&L_OP_BNOT, -&&L_OP_NOT, -&&L_OP_LEN, -&&L_OP_CONCAT, -&&L_OP_CLOSE, -&&L_OP_TBC, -&&L_OP_JMP, -&&L_OP_EQ, -&&L_OP_LT, -&&L_OP_LE, -&&L_OP_EQK, -&&L_OP_EQI, -&&L_OP_LTI, -&&L_OP_LEI, -&&L_OP_GTI, -&&L_OP_GEI, -&&L_OP_TEST, -&&L_OP_TESTSET, -&&L_OP_CALL, -&&L_OP_TAILCALL, -&&L_OP_RETURN, -&&L_OP_RETURN0, -&&L_OP_RETURN1, -&&L_OP_FORLOOP, -&&L_OP_FORPREP, -&&L_OP_TFORPREP, -&&L_OP_TFORCALL, -&&L_OP_TFORLOOP, -&&L_OP_SETLIST, -&&L_OP_CLOSURE, -&&L_OP_VARARG, -&&L_OP_VARARGPREP, -&&L_OP_EXTRAARG - -}; diff --git a/include/lua/llex.h b/include/lua/llex.h deleted file mode 100644 index a16dbfe6..00000000 --- a/include/lua/llex.h +++ /dev/null @@ -1,92 +0,0 @@ -# 1 "./lua/llex.h" - - - - - - -#ifndef llex_h -#define llex_h - -#include - -#include "lobject.h" -#include "lzio.h" - - - - - - -#define FIRST_RESERVED (UCHAR_MAX + 1) - - -#if !defined(LUA_ENV) -#define LUA_ENV "_ENV" -#endif - - - - - - -enum RESERVED { - - TK_AND = FIRST_RESERVED, TK_BREAK, - TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, - TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, - TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, - - TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, - TK_SHL, TK_SHR, - TK_DBCOLON, TK_EOS, - TK_FLT, TK_INT, TK_NAME, TK_STRING -}; - - -#define NUM_RESERVED (cast_int(TK_WHILE-FIRST_RESERVED + 1)) - - -typedef union { - lua_Number r; - lua_Integer i; - TString *ts; -} SemInfo; - - -typedef struct Token { - int token; - SemInfo seminfo; -} Token; - - - - -typedef struct LexState { - int current; - int linenumber; - int lastline; - Token t; - Token lookahead; - struct FuncState *fs; - struct lua_State *L; - ZIO *z; - Mbuffer *buff; - Table *h; - struct Dyndata *dyd; - TString *source; - TString *envn; -} LexState; - - -LUAI_FUNC void luaX_init (lua_State *L); -LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, - TString *source, int firstchar); -LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); -LUAI_FUNC void luaX_next (LexState *ls); -LUAI_FUNC int luaX_lookahead (LexState *ls); -LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); -LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); - - -#endif diff --git a/include/lua/llimits.h b/include/lua/llimits.h deleted file mode 100644 index b1b9e475..00000000 --- a/include/lua/llimits.h +++ /dev/null @@ -1,321 +0,0 @@ -# 1 "./lua/llimits.h" - - - - - - -#ifndef llimits_h -#define llimits_h - - -#include -#include - - -#include "lua.h" - - - - - - - -#if defined(LUAI_MEM) -typedef LUAI_UMEM lu_mem; -typedef LUAI_MEM l_mem; -#elif LUAI_IS32INT -typedef size_t lu_mem; -typedef ptrdiff_t l_mem; -#else -typedef unsigned long lu_mem; -typedef long l_mem; -#endif - - - -typedef unsigned char lu_byte; -typedef signed char ls_byte; - - - -#define MAX_SIZET ((size_t)(~(size_t)0)) - - -#define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \ - : (size_t)(LUA_MAXINTEGER)) - - -#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)) - -#define MAX_LMEM ((l_mem)(MAX_LUMEM >> 1)) - - -#define MAX_INT INT_MAX - - - - - - -#define log2maxs(t) (sizeof(t) * 8 - 2) - - - - - -#define ispow2(x) (((x) & ((x) - 1)) == 0) - - - -#define LL(x) (sizeof(x)/sizeof(char) - 1) - - - - - - - -#define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX)) - - - - -typedef LUAI_UACNUMBER l_uacNumber; -typedef LUAI_UACINT l_uacInt; - - - - - -#if defined LUAI_ASSERT -#undef NDEBUG -#include -#define lua_assert(c) assert(c) -#endif - -#if defined(lua_assert) -#define check_exp(c,e) (lua_assert(c), (e)) - -#define lua_longassert(c) ((c) ? (void)0 : lua_assert(0)) -#else -#define lua_assert(c) ((void)0) -#define check_exp(c,e) (e) -#define lua_longassert(c) ((void)0) -#endif - - - - -#if !defined(luai_apicheck) -#define luai_apicheck(l,e) ((void)l, lua_assert(e)) -#endif - -#define api_check(l,e,msg) luai_apicheck(l,(e) && msg) - - - -#if !defined(UNUSED) -#define UNUSED(x) ((void)(x)) -#endif - - - -#define cast(t,exp) ((t)(exp)) - -#define cast_void(i) cast(void, (i)) -#define cast_voidp(i) cast(void *, (i)) -#define cast_num(i) cast(lua_Number, (i)) -#define cast_int(i) cast(int, (i)) -#define cast_uint(i) cast(unsigned int, (i)) -#define cast_byte(i) cast(lu_byte, (i)) -#define cast_uchar(i) cast(unsigned char, (i)) -#define cast_char(i) cast(char, (i)) -#define cast_charp(i) cast(char *, (i)) -#define cast_sizet(i) cast(size_t, (i)) - - - -#if !defined(l_castS2U) -#define l_castS2U(i) ((lua_Unsigned)(i)) -#endif - - - - - - -#if !defined(l_castU2S) -#define l_castU2S(i) ((lua_Integer)(i)) -#endif - - - - - -#if !defined(l_noret) - -#if defined(__GNUC__) -#define l_noret void __attribute__((noreturn)) -#elif defined(_MSC_VER) && _MSC_VER >= 1200 -#define l_noret void __declspec(noreturn) -#else -#define l_noret void -#endif - -#endif - - - - - -#if !defined(LUA_USE_C89) -#define l_inline inline -#elif defined(__GNUC__) -#define l_inline __inline__ -#else -#define l_inline -#endif - -#define l_sinline static l_inline - - - - - - -#if LUAI_IS32INT -typedef unsigned int l_uint32; -#else -typedef unsigned long l_uint32; -#endif - -typedef l_uint32 Instruction; -# 202 "./lua/llimits.h" -#if !defined(LUAI_MAXSHORTLEN) -#define LUAI_MAXSHORTLEN 40 -#endif -# 213 "./lua/llimits.h" -#if !defined(MINSTRTABSIZE) -#define MINSTRTABSIZE 128 -#endif - - - - - - - -#if !defined(STRCACHE_N) -#define STRCACHE_N 53 -#define STRCACHE_M 2 -#endif - - - -#if !defined(LUA_MINBUFFER) -#define LUA_MINBUFFER 32 -#endif -# 241 "./lua/llimits.h" -#if !defined(LUAI_MAXCCALLS) -#define LUAI_MAXCCALLS 200 -#endif - - - - - - -#if !defined(lua_lock) -#define lua_lock(L) ((void) 0) -#define lua_unlock(L) ((void) 0) -#endif - - - - - -#if !defined(luai_threadyield) -#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} -#endif - - - - - - -#if !defined(luai_userstateopen) -#define luai_userstateopen(L) ((void)L) -#endif - -#if !defined(luai_userstateclose) -#define luai_userstateclose(L) ((void)L) -#endif - -#if !defined(luai_userstatethread) -#define luai_userstatethread(L,L1) ((void)L) -#endif - -#if !defined(luai_userstatefree) -#define luai_userstatefree(L,L1) ((void)L) -#endif - -#if !defined(luai_userstateresume) -#define luai_userstateresume(L,n) ((void)L) -#endif - -#if !defined(luai_userstateyield) -#define luai_userstateyield(L,n) ((void)L) -#endif -# 299 "./lua/llimits.h" -#if !defined(luai_numidiv) -#define luai_numidiv(L,a,b) ((void)L, l_floor(luai_numdiv(L,a,b))) -#endif - - -#if !defined(luai_numdiv) -#define luai_numdiv(L,a,b) ((a)/(b)) -#endif -# 319 "./lua/llimits.h" -#if !defined(luai_nummod) -#define luai_nummod(L,a,b,m) \ - { (void)L; (m) = l_mathop(fmod)(a,b); \ - if (((m) > 0) ? (b) < 0 : ((m) < 0 && (b) > 0)) (m) += (b); } -#endif - - -#if !defined(luai_numpow) -#define luai_numpow(L,a,b) \ - ((void)L, (b == 2) ? (a)*(a) : l_mathop(pow)(a,b)) -#endif - - -#if !defined(luai_numadd) -#define luai_numadd(L,a,b) ((a)+(b)) -#define luai_numsub(L,a,b) ((a)-(b)) -#define luai_nummul(L,a,b) ((a)*(b)) -#define luai_numunm(L,a) (-(a)) -#define luai_numeq(a,b) ((a)==(b)) -#define luai_numlt(a,b) ((a)<(b)) -#define luai_numle(a,b) ((a)<=(b)) -#define luai_numgt(a,b) ((a)>(b)) -#define luai_numge(a,b) ((a)>=(b)) -#define luai_numisnan(a) (!luai_numeq((a), (a))) -#endif -# 352 "./lua/llimits.h" -#if !defined(HARDSTACKTESTS) -#define condmovestack(L,pre,pos) ((void)0) -#else - -#define condmovestack(L,pre,pos) \ - { int sz_ = stacksize(L); pre; luaD_reallocstack((L), sz_, 0); pos; } -#endif - -#if !defined(HARDMEMTESTS) -#define condchangemem(L,pre,pos) ((void)0) -#else -#define condchangemem(L,pre,pos) \ - { if (gcrunning(G(L))) { pre; luaC_fullgc(L, 0); pos; } } -#endif - -#endif diff --git a/include/lua/lmem.h b/include/lua/lmem.h deleted file mode 100644 index 295d396f..00000000 --- a/include/lua/lmem.h +++ /dev/null @@ -1,74 +0,0 @@ -# 1 "./lua/lmem.h" - - - - - - -#ifndef lmem_h -#define lmem_h - - -#include - -#include "llimits.h" -#include "lua.h" - - -#define luaM_error(L) luaD_throw(L, LUA_ERRMEM) -# 31 "./lua/lmem.h" -#define luaM_testsize(n,e) \ - (sizeof(n) >= sizeof(size_t) && cast_sizet((n)) + 1 > MAX_SIZET/(e)) - -#define luaM_checksize(L,n,e) \ - (luaM_testsize(n,e) ? luaM_toobig(L) : cast_void(0)) -# 44 "./lua/lmem.h" -#define luaM_limitN(n,t) \ - ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \ - cast_uint((MAX_SIZET/sizeof(t)))) - - - - - -#define luaM_reallocvchar(L,b,on,n) \ - cast_charp(luaM_saferealloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) - -#define luaM_freemem(L,b,s) luaM_free_(L, (b), (s)) -#define luaM_free(L,b) luaM_free_(L, (b), sizeof(*(b))) -#define luaM_freearray(L,b,n) luaM_free_(L, (b), (n)*sizeof(*(b))) - -#define luaM_new(L,t) cast(t*, luaM_malloc_(L, sizeof(t), 0)) -#define luaM_newvector(L,n,t) cast(t*, luaM_malloc_(L, (n)*sizeof(t), 0)) -#define luaM_newvectorchecked(L,n,t) \ - (luaM_checksize(L,n,sizeof(t)), luaM_newvector(L,n,t)) - -#define luaM_newobject(L,tag,s) luaM_malloc_(L, (s), tag) - -#define luaM_growvector(L,v,nelems,size,t,limit,e) \ - ((v)=cast(t *, luaM_growaux_(L,v,nelems,&(size),sizeof(t), \ - luaM_limitN(limit,t),e))) - -#define luaM_reallocvector(L,v,oldn,n,t) \ - (cast(t *, luaM_realloc_(L, v, cast_sizet(oldn) * sizeof(t), \ - cast_sizet(n) * sizeof(t)))) - -#define luaM_shrinkvector(L,v,size,fs,t) \ - ((v)=cast(t *, luaM_shrinkvector_(L, v, &(size), fs, sizeof(t)))) - -LUAI_FUNC l_noret luaM_toobig (lua_State *L); - - -LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, - size_t size); -LUAI_FUNC void *luaM_saferealloc_ (lua_State *L, void *block, size_t oldsize, - size_t size); -LUAI_FUNC void luaM_free_ (lua_State *L, void *block, size_t osize); -LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int nelems, - int *size, int size_elem, int limit, - const char *what); -LUAI_FUNC void *luaM_shrinkvector_ (lua_State *L, void *block, int *nelem, - int final_n, int size_elem); -LUAI_FUNC void *luaM_malloc_ (lua_State *L, size_t size, int tag); - -#endif diff --git a/include/lua/lobject.h b/include/lua/lobject.h deleted file mode 100644 index 7569a421..00000000 --- a/include/lua/lobject.h +++ /dev/null @@ -1,627 +0,0 @@ -# 1 "./lua/lobject.h" - - - - - - - -#ifndef lobject_h -#define lobject_h - - -#include - - -#include "llimits.h" -#include "lua.h" - - - - - -#define LUA_TUPVAL LUA_NUMTYPES -#define LUA_TPROTO (LUA_NUMTYPES+1) -#define LUA_TDEADKEY (LUA_NUMTYPES+2) - - - - - - -#define LUA_TOTALTYPES (LUA_TPROTO + 2) -# 42 "./lua/lobject.h" -#define makevariant(t,v) ((t) | ((v) << 4)) - - - - - - -typedef union Value { - struct GCObject *gc; - void *p; - lua_CFunction f; - lua_Integer i; - lua_Number n; -} Value; - - - - - - - -#define TValuefields Value value_; lu_byte tt_ - -typedef struct TValue { - TValuefields; -} TValue; - - -#define val_(o) ((o)->value_) -#define valraw(o) (val_(o)) - - - -#define rawtt(o) ((o)->tt_) - - -#define novariant(t) ((t) & 0x0F) - - -#define withvariant(t) ((t) & 0x3F) -#define ttypetag(o) withvariant(rawtt(o)) - - -#define ttype(o) (novariant(rawtt(o))) - - - -#define checktag(o,t) (rawtt(o) == (t)) -#define checktype(o,t) (ttype(o) == (t)) - - - - - -#define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt) - - - - - - - -#define checkliveness(L,obj) \ - ((void)L, lua_longassert(!iscollectable(obj) || \ - (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))) - - - - - -#define settt_(o,t) ((o)->tt_=(t)) - - - -#define setobj(L,obj1,obj2) \ - { TValue *io1=(obj1); const TValue *io2=(obj2); \ - io1->value_ = io2->value_; settt_(io1, io2->tt_); \ - checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); } - - - - - - - -#define setobjs2s(L,o1,o2) setobj(L,s2v(o1),s2v(o2)) - -#define setobj2s(L,o1,o2) setobj(L,s2v(o1),o2) - -#define setobjt2t setobj - -#define setobj2n setobj - -#define setobj2t setobj -# 146 "./lua/lobject.h" -typedef union StackValue { - TValue val; - struct { - TValuefields; - unsigned short delta; - } tbclist; -} StackValue; - - - -typedef StackValue *StkId; - - -#define s2v(o) (&(o)->val) -# 170 "./lua/lobject.h" -#define LUA_VNIL makevariant(LUA_TNIL, 0) - - -#define LUA_VEMPTY makevariant(LUA_TNIL, 1) - - -#define LUA_VABSTKEY makevariant(LUA_TNIL, 2) - - - -#define ttisnil(v) checktype((v), LUA_TNIL) - - - -#define ttisstrictnil(o) checktag((o), LUA_VNIL) - - -#define setnilvalue(obj) settt_(obj, LUA_VNIL) - - -#define isabstkey(v) checktag((v), LUA_VABSTKEY) - - - - - -#define isnonstrictnil(v) (ttisnil(v) && !ttisstrictnil(v)) - - - - - - - -#define isempty(v) ttisnil(v) - - - -#define ABSTKEYCONSTANT {NULL}, LUA_VABSTKEY - - - -#define setempty(v) settt_(v, LUA_VEMPTY) -# 226 "./lua/lobject.h" -#define LUA_VFALSE makevariant(LUA_TBOOLEAN, 0) -#define LUA_VTRUE makevariant(LUA_TBOOLEAN, 1) - -#define ttisboolean(o) checktype((o), LUA_TBOOLEAN) -#define ttisfalse(o) checktag((o), LUA_VFALSE) -#define ttistrue(o) checktag((o), LUA_VTRUE) - - -#define l_isfalse(o) (ttisfalse(o) || ttisnil(o)) - - -#define setbfvalue(obj) settt_(obj, LUA_VFALSE) -#define setbtvalue(obj) settt_(obj, LUA_VTRUE) -# 249 "./lua/lobject.h" -#define LUA_VTHREAD makevariant(LUA_TTHREAD, 0) - -#define ttisthread(o) checktag((o), ctb(LUA_VTHREAD)) - -#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) - -#define setthvalue(L,obj,x) \ - { TValue *io = (obj); lua_State *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTHREAD)); \ - checkliveness(L,io); } - -#define setthvalue2s(L,o,t) setthvalue(L,s2v(o),t) -# 275 "./lua/lobject.h" -#define CommonHeader struct GCObject *next; lu_byte tt; lu_byte marked - - - -typedef struct GCObject { - CommonHeader; -} GCObject; - - - -#define BIT_ISCOLLECTABLE (1 << 6) - -#define iscollectable(o) (rawtt(o) & BIT_ISCOLLECTABLE) - - -#define ctb(t) ((t) | BIT_ISCOLLECTABLE) - -#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) - -#define gcvalueraw(v) ((v).gc) - -#define setgcovalue(L,obj,x) \ - { TValue *io = (obj); GCObject *i_g=(x); \ - val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } -# 310 "./lua/lobject.h" -#define LUA_VNUMINT makevariant(LUA_TNUMBER, 0) -#define LUA_VNUMFLT makevariant(LUA_TNUMBER, 1) - -#define ttisnumber(o) checktype((o), LUA_TNUMBER) -#define ttisfloat(o) checktag((o), LUA_VNUMFLT) -#define ttisinteger(o) checktag((o), LUA_VNUMINT) - -#define nvalue(o) check_exp(ttisnumber(o), \ - (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) -#define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) -#define ivalue(o) check_exp(ttisinteger(o), val_(o).i) - -#define fltvalueraw(v) ((v).n) -#define ivalueraw(v) ((v).i) - -#define setfltvalue(obj,x) \ - { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_VNUMFLT); } - -#define chgfltvalue(obj,x) \ - { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } - -#define setivalue(obj,x) \ - { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_VNUMINT); } - -#define chgivalue(obj,x) \ - { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } -# 347 "./lua/lobject.h" -#define LUA_VSHRSTR makevariant(LUA_TSTRING, 0) -#define LUA_VLNGSTR makevariant(LUA_TSTRING, 1) - -#define ttisstring(o) checktype((o), LUA_TSTRING) -#define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR)) -#define ttislngstring(o) checktag((o), ctb(LUA_VLNGSTR)) - -#define tsvalueraw(v) (gco2ts((v).gc)) - -#define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) - -#define setsvalue(L,obj,x) \ - { TValue *io = (obj); TString *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ - checkliveness(L,io); } - - -#define setsvalue2s(L,o,s) setsvalue(L,s2v(o),s) - - -#define setsvalue2n setsvalue - - - - - -typedef struct TString { - CommonHeader; - lu_byte extra; - lu_byte shrlen; - unsigned int hash; - union { - size_t lnglen; - struct TString *hnext; - } u; - char contents[1]; -} TString; - - - - - - -#define getstr(ts) ((ts)->contents) - - - -#define svalue(o) getstr(tsvalue(o)) - - -#define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen) - - -#define vslen(o) tsslen(tsvalue(o)) -# 416 "./lua/lobject.h" -#define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 0) - -#define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 0) - -#define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA) -#define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA)) - -#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) -#define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) - -#define pvalueraw(v) ((v).p) - -#define setpvalue(obj,x) \ - { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_VLIGHTUSERDATA); } - -#define setuvalue(L,obj,x) \ - { TValue *io = (obj); Udata *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VUSERDATA)); \ - checkliveness(L,io); } - - - -typedef union UValue { - TValue uv; - LUAI_MAXALIGN; -} UValue; - - - - - - -typedef struct Udata { - CommonHeader; - unsigned short nuvalue; - size_t len; - struct Table *metatable; - GCObject *gclist; - UValue uv[1]; -} Udata; -# 467 "./lua/lobject.h" -typedef struct Udata0 { - CommonHeader; - unsigned short nuvalue; - size_t len; - struct Table *metatable; - union {LUAI_MAXALIGN;} bindata; -} Udata0; - - - -#define udatamemoffset(nuv) \ - ((nuv) == 0 ? offsetof(Udata0, bindata) \ - : offsetof(Udata, uv) + (sizeof(UValue) * (nuv))) - - -#define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue)) - - -#define sizeudata(nuv,nb) (udatamemoffset(nuv) + (nb)) -# 496 "./lua/lobject.h" -#define LUA_VPROTO makevariant(LUA_TPROTO, 0) - - - - - -typedef struct Upvaldesc { - TString *name; - lu_byte instack; - lu_byte idx; - lu_byte kind; -} Upvaldesc; - - - - - - -typedef struct LocVar { - TString *varname; - int startpc; - int endpc; -} LocVar; -# 531 "./lua/lobject.h" -typedef struct AbsLineInfo { - int pc; - int line; -} AbsLineInfo; - - - - -typedef struct Proto { - CommonHeader; - lu_byte numparams; - lu_byte is_vararg; - lu_byte maxstacksize; - int sizeupvalues; - int sizek; - int sizecode; - int sizelineinfo; - int sizep; - int sizelocvars; - int sizeabslineinfo; - int linedefined; - int lastlinedefined; - TValue *k; - Instruction *code; - struct Proto **p; - Upvaldesc *upvalues; - ls_byte *lineinfo; - AbsLineInfo *abslineinfo; - LocVar *locvars; - TString *source; - GCObject *gclist; -} Proto; -# 573 "./lua/lobject.h" -#define LUA_VUPVAL makevariant(LUA_TUPVAL, 0) - - - -#define LUA_VLCL makevariant(LUA_TFUNCTION, 0) -#define LUA_VLCF makevariant(LUA_TFUNCTION, 1) -#define LUA_VCCL makevariant(LUA_TFUNCTION, 2) - -#define ttisfunction(o) checktype(o, LUA_TFUNCTION) -#define ttisLclosure(o) checktag((o), ctb(LUA_VLCL)) -#define ttislcf(o) checktag((o), LUA_VLCF) -#define ttisCclosure(o) checktag((o), ctb(LUA_VCCL)) -#define ttisclosure(o) (ttisLclosure(o) || ttisCclosure(o)) - - -#define isLfunction(o) ttisLclosure(o) - -#define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) -#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) -#define fvalue(o) check_exp(ttislcf(o), val_(o).f) -#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) - -#define fvalueraw(v) ((v).f) - -#define setclLvalue(L,obj,x) \ - { TValue *io = (obj); LClosure *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VLCL)); \ - checkliveness(L,io); } - -#define setclLvalue2s(L,o,cl) setclLvalue(L,s2v(o),cl) - -#define setfvalue(obj,x) \ - { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_VLCF); } - -#define setclCvalue(L,obj,x) \ - { TValue *io = (obj); CClosure *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VCCL)); \ - checkliveness(L,io); } - - - - - -typedef struct UpVal { - CommonHeader; - lu_byte tbc; - TValue *v; - union { - struct { - struct UpVal *next; - struct UpVal **previous; - } open; - TValue value; - } u; -} UpVal; - - - -#define ClosureHeader \ - CommonHeader; lu_byte nupvalues; GCObject *gclist - -typedef struct CClosure { - ClosureHeader; - lua_CFunction f; - TValue upvalue[1]; -} CClosure; - - -typedef struct LClosure { - ClosureHeader; - struct Proto *p; - UpVal *upvals[1]; -} LClosure; - - -typedef union Closure { - CClosure c; - LClosure l; -} Closure; - - -#define getproto(o) (clLvalue(o)->p) -# 665 "./lua/lobject.h" -#define LUA_VTABLE makevariant(LUA_TTABLE, 0) - -#define ttistable(o) checktag((o), ctb(LUA_VTABLE)) - -#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) - -#define sethvalue(L,obj,x) \ - { TValue *io = (obj); Table *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTABLE)); \ - checkliveness(L,io); } - -#define sethvalue2s(L,o,h) sethvalue(L,s2v(o),h) -# 686 "./lua/lobject.h" -typedef union Node { - struct NodeKey { - TValuefields; - lu_byte key_tt; - int next; - Value key_val; - } u; - TValue i_val; -} Node; - - - -#define setnodekey(L,node,obj) \ - { Node *n_=(node); const TValue *io_=(obj); \ - n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \ - checkliveness(L,io_); } - - - -#define getnodekey(L,obj,node) \ - { TValue *io_=(obj); const Node *n_=(node); \ - io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \ - checkliveness(L,io_); } -# 718 "./lua/lobject.h" -#define BITRAS (1 << 7) -#define isrealasize(t) (!((t)->flags & BITRAS)) -#define setrealasize(t) ((t)->flags &= cast_byte(~BITRAS)) -#define setnorealasize(t) ((t)->flags |= BITRAS) - - -typedef struct Table { - CommonHeader; - lu_byte flags; - lu_byte lsizenode; - unsigned int alimit; - TValue *array; - Node *node; - Node *lastfree; - struct Table *metatable; - GCObject *gclist; -} Table; - - - - - -#define keytt(node) ((node)->u.key_tt) -#define keyval(node) ((node)->u.key_val) - -#define keyisnil(node) (keytt(node) == LUA_TNIL) -#define keyisinteger(node) (keytt(node) == LUA_VNUMINT) -#define keyival(node) (keyval(node).i) -#define keyisshrstr(node) (keytt(node) == ctb(LUA_VSHRSTR)) -#define keystrval(node) (gco2ts(keyval(node).gc)) - -#define setnilkey(node) (keytt(node) = LUA_TNIL) - -#define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE) - -#define gckey(n) (keyval(n).gc) -#define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL) -# 763 "./lua/lobject.h" -#define setdeadkey(node) (keytt(node) = LUA_TDEADKEY) -#define keyisdead(node) (keytt(node) == LUA_TDEADKEY) -# 773 "./lua/lobject.h" -#define lmod(s,size) \ - (check_exp((size&(size-1))==0, (cast_int((s) & ((size)-1))))) - - -#define twoto(x) (1<<(x)) -#define sizenode(t) (twoto((t)->lsizenode)) - - - -#define UTF8BUFFSZ 8 - -LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x); -LUAI_FUNC int luaO_ceillog2 (unsigned int x); -LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1, - const TValue *p2, TValue *res); -LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1, - const TValue *p2, StkId res); -LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o); -LUAI_FUNC int luaO_hexavalue (int c); -LUAI_FUNC void luaO_tostring (lua_State *L, TValue *obj); -LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, - va_list argp); -LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); -LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t srclen); - - -#endif diff --git a/include/lua/lopcodes.h b/include/lua/lopcodes.h deleted file mode 100644 index 57866c66..00000000 --- a/include/lua/lopcodes.h +++ /dev/null @@ -1,299 +0,0 @@ -# 1 "./lua/lopcodes.h" - - - - - - -#ifndef lopcodes_h -#define lopcodes_h - -#include "llimits.h" -# 32 "./lua/lopcodes.h" -enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; - - - - - -#define SIZE_C 8 -#define SIZE_B 8 -#define SIZE_Bx (SIZE_C + SIZE_B + 1) -#define SIZE_A 8 -#define SIZE_Ax (SIZE_Bx + SIZE_A) -#define SIZE_sJ (SIZE_Bx + SIZE_A) - -#define SIZE_OP 7 - -#define POS_OP 0 - -#define POS_A (POS_OP + SIZE_OP) -#define POS_k (POS_A + SIZE_A) -#define POS_B (POS_k + 1) -#define POS_C (POS_B + SIZE_B) - -#define POS_Bx POS_k - -#define POS_Ax POS_A - -#define POS_sJ POS_A -# 68 "./lua/lopcodes.h" -#define L_INTHASBITS(b) ((UINT_MAX >> ((b) - 1)) >= 1) - - -#if L_INTHASBITS(SIZE_Bx) -#define MAXARG_Bx ((1<>1) - - -#if L_INTHASBITS(SIZE_Ax) -#define MAXARG_Ax ((1<> 1) - - -#define MAXARG_A ((1<> 1) - -#define int2sC(i) ((i) + OFFSET_sC) -#define sC2int(i) ((i) - OFFSET_sC) - - - -#define MASK1(n,p) ((~((~(Instruction)0)<<(n)))<<(p)) - - -#define MASK0(n,p) (~MASK1(n,p)) - - - - - -#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0))) -#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ - ((cast(Instruction, o)<>(pos)) & MASK1(size,0))) -#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ - ((cast(Instruction, v)< - - - - -static const char *const opnames[] = { - "MOVE", - "LOADI", - "LOADF", - "LOADK", - "LOADKX", - "LOADFALSE", - "LFALSESKIP", - "LOADTRUE", - "LOADNIL", - "GETUPVAL", - "SETUPVAL", - "GETTABUP", - "GETTABLE", - "GETI", - "GETFIELD", - "SETTABUP", - "SETTABLE", - "SETI", - "SETFIELD", - "NEWTABLE", - "SELF", - "ADDI", - "ADDK", - "SUBK", - "MULK", - "MODK", - "POWK", - "DIVK", - "IDIVK", - "BANDK", - "BORK", - "BXORK", - "SHRI", - "SHLI", - "ADD", - "SUB", - "MUL", - "MOD", - "POW", - "DIV", - "IDIV", - "BAND", - "BOR", - "BXOR", - "SHL", - "SHR", - "MMBIN", - "MMBINI", - "MMBINK", - "UNM", - "BNOT", - "NOT", - "LEN", - "CONCAT", - "CLOSE", - "TBC", - "JMP", - "EQ", - "LT", - "LE", - "EQK", - "EQI", - "LTI", - "LEI", - "GTI", - "GEI", - "TEST", - "TESTSET", - "CALL", - "TAILCALL", - "RETURN", - "RETURN0", - "RETURN1", - "FORLOOP", - "FORPREP", - "TFORPREP", - "TFORCALL", - "TFORLOOP", - "SETLIST", - "CLOSURE", - "VARARG", - "VARARGPREP", - "EXTRAARG", - NULL -}; - -#endif diff --git a/include/lua/lparser.h b/include/lua/lparser.h deleted file mode 100644 index ed1598af..00000000 --- a/include/lua/lparser.h +++ /dev/null @@ -1,161 +0,0 @@ -# 1 "./lua/lparser.h" - - - - - - -#ifndef lparser_h -#define lparser_h - -#include "llimits.h" -#include "lobject.h" -#include "lzio.h" -# 25 "./lua/lparser.h" -typedef enum { - VVOID, - - VNIL, - VTRUE, - VFALSE, - VK, - VKFLT, - VKINT, - VKSTR, - - VNONRELOC, - - VLOCAL, - - VUPVAL, - VCONST, - - VINDEXED, - - - VINDEXUP, - - - VINDEXI, - - - VINDEXSTR, - - - VJMP, - - VRELOC, - - VCALL, - VVARARG -} expkind; - - -#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXSTR) -#define vkisindexed(k) (VINDEXED <= (k) && (k) <= VINDEXSTR) - - -typedef struct expdesc { - expkind k; - union { - lua_Integer ival; - lua_Number nval; - TString *strval; - int info; - struct { - short idx; - lu_byte t; - } ind; - struct { - lu_byte ridx; - unsigned short vidx; - } var; - } u; - int t; - int f; -} expdesc; - - - -#define VDKREG 0 -#define RDKCONST 1 -#define RDKTOCLOSE 2 -#define RDKCTC 3 - - -typedef union Vardesc { - struct { - TValuefields; - lu_byte kind; - lu_byte ridx; - short pidx; - TString *name; - } vd; - TValue k; -} Vardesc; - - - - -typedef struct Labeldesc { - TString *name; - int pc; - int line; - lu_byte nactvar; - lu_byte close; -} Labeldesc; - - - -typedef struct Labellist { - Labeldesc *arr; - int n; - int size; -} Labellist; - - - -typedef struct Dyndata { - struct { - Vardesc *arr; - int n; - int size; - } actvar; - Labellist gt; - Labellist label; -} Dyndata; - - - -struct BlockCnt; - - - -typedef struct FuncState { - Proto *f; - struct FuncState *prev; - struct LexState *ls; - struct BlockCnt *bl; - int pc; - int lasttarget; - int previousline; - int nk; - int np; - int nabslineinfo; - int firstlocal; - int firstlabel; - short ndebugvars; - lu_byte nactvar; - lu_byte nups; - lu_byte freereg; - lu_byte iwthabs; - lu_byte needclose; -} FuncState; - - -LUAI_FUNC int luaY_nvarstack (FuncState *fs); -LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, - Dyndata *dyd, const char *name, int firstchar); - - -#endif diff --git a/include/lua/lprefix.h b/include/lua/lprefix.h deleted file mode 100644 index 325889c3..00000000 --- a/include/lua/lprefix.h +++ /dev/null @@ -1,45 +0,0 @@ -# 1 "./lua/lprefix.h" - - - - - - -#ifndef lprefix_h -#define lprefix_h - - - - - -#if !defined(LUA_USE_C89) - -#if !defined(_XOPEN_SOURCE) -#define _XOPEN_SOURCE 600 -#elif _XOPEN_SOURCE == 0 -#undef _XOPEN_SOURCE -#endif - - - - -#if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) -#define _LARGEFILE_SOURCE 1 -#define _FILE_OFFSET_BITS 64 -#endif - -#endif - - - - - -#if defined(_WIN32) - -#if !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS -#endif - -#endif - -#endif diff --git a/include/lua/lstate.h b/include/lua/lstate.h deleted file mode 100644 index 681a67db..00000000 --- a/include/lua/lstate.h +++ /dev/null @@ -1,280 +0,0 @@ -# 1 "./lua/lstate.h" - - - - - - -#ifndef lstate_h -#define lstate_h - -#include "lua.h" - -#include "lobject.h" -#include "ltm.h" -#include "lzio.h" -# 99 "./lua/lstate.h" -#define yieldable(L) (((L)->nCcalls & 0xffff0000) == 0) - - -#define getCcalls(L) ((L)->nCcalls & 0xffff) - - - -#define incnny(L) ((L)->nCcalls += 0x10000) - - -#define decnny(L) ((L)->nCcalls -= 0x10000) - - -#define nyci (0x10000 | 1) - - - - -struct lua_longjmp; - - - - - - -#if !defined(l_signalT) -#include -#define l_signalT sig_atomic_t -#endif -# 137 "./lua/lstate.h" -#define EXTRA_STACK 5 - - -#define BASIC_STACK_SIZE (2*LUA_MINSTACK) - -#define stacksize(th) cast_int((th)->stack_last - (th)->stack) - - - -#define KGC_INC 0 -#define KGC_GEN 1 - - -typedef struct stringtable { - TString **hash; - int nuse; - int size; -} stringtable; -# 172 "./lua/lstate.h" -typedef struct CallInfo { - StkId func; - StkId top; - struct CallInfo *previous, *next; - union { - struct { - const Instruction *savedpc; - volatile l_signalT trap; - int nextraargs; - } l; - struct { - lua_KFunction k; - ptrdiff_t old_errfunc; - lua_KContext ctx; - } c; - } u; - union { - int funcidx; - int nyield; - int nres; - struct { - unsigned short ftransfer; - unsigned short ntransfer; - } transferinfo; - } u2; - short nresults; - unsigned short callstatus; -} CallInfo; - - - - - -#define CIST_OAH (1<<0) -#define CIST_C (1<<1) -#define CIST_FRESH (1<<2) -#define CIST_HOOKED (1<<3) -#define CIST_YPCALL (1<<4) -#define CIST_TAIL (1<<5) -#define CIST_HOOKYIELD (1<<6) -#define CIST_FIN (1<<7) -#define CIST_TRAN (1<<8) -#define CIST_CLSRET (1<<9) - -#define CIST_RECST 10 -#if defined(LUA_COMPAT_LT_LE) -#define CIST_LEQ (1<<13) -#endif -# 228 "./lua/lstate.h" -#define getcistrecst(ci) (((ci)->callstatus >> CIST_RECST) & 7) -#define setcistrecst(ci,st) \ - check_exp(((st) & 7) == (st), \ - ((ci)->callstatus = ((ci)->callstatus & ~(7 << CIST_RECST)) \ - | ((st) << CIST_RECST))) - - - -#define isLua(ci) (!((ci)->callstatus & CIST_C)) - - -#define isLuacode(ci) (!((ci)->callstatus & (CIST_C | CIST_HOOKED))) - - -#define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) -#define getoah(st) ((st) & CIST_OAH) - - - - - -typedef struct global_State { - lua_Alloc frealloc; - void *ud; - l_mem totalbytes; - l_mem GCdebt; - lu_mem GCestimate; - lu_mem lastatomic; - stringtable strt; - TValue l_registry; - TValue nilvalue; - unsigned int seed; - lu_byte currentwhite; - lu_byte gcstate; - lu_byte gckind; - lu_byte gcstopem; - lu_byte genminormul; - lu_byte genmajormul; - lu_byte gcstp; - lu_byte gcemergency; - lu_byte gcpause; - lu_byte gcstepmul; - lu_byte gcstepsize; - GCObject *allgc; - GCObject **sweepgc; - GCObject *finobj; - GCObject *gray; - GCObject *grayagain; - GCObject *weak; - GCObject *ephemeron; - GCObject *allweak; - GCObject *tobefnz; - GCObject *fixedgc; - - GCObject *survival; - GCObject *old1; - GCObject *reallyold; - GCObject *firstold1; - GCObject *finobjsur; - GCObject *finobjold1; - GCObject *finobjrold; - struct lua_State *twups; - lua_CFunction panic; - struct lua_State *mainthread; - TString *memerrmsg; - TString *tmname[TM_N]; - struct Table *mt[LUA_NUMTAGS]; - TString *strcache[STRCACHE_N][STRCACHE_M]; - lua_WarnFunction warnf; - void *ud_warn; -} global_State; - - - - - -struct lua_State { - CommonHeader; - lu_byte status; - lu_byte allowhook; - unsigned short nci; - StkId top; - global_State *l_G; - CallInfo *ci; - StkId stack_last; - StkId stack; - UpVal *openupval; - StkId tbclist; - GCObject *gclist; - struct lua_State *twups; - struct lua_longjmp *errorJmp; - CallInfo base_ci; - volatile lua_Hook hook; - ptrdiff_t errfunc; - l_uint32 nCcalls; - int oldpc; - int basehookcount; - int hookcount; - volatile l_signalT hookmask; -}; - - -#define G(L) (L->l_G) - - - - - -#define completestate(g) ttisnil(&g->nilvalue) -# 348 "./lua/lstate.h" -union GCUnion { - GCObject gc; - struct TString ts; - struct Udata u; - union Closure cl; - struct Table h; - struct Proto p; - struct lua_State th; - struct UpVal upv; -}; - - - - - - - -#define cast_u(o) cast(union GCUnion *, (o)) - - -#define gco2ts(o) \ - check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts)) -#define gco2u(o) check_exp((o)->tt == LUA_VUSERDATA, &((cast_u(o))->u)) -#define gco2lcl(o) check_exp((o)->tt == LUA_VLCL, &((cast_u(o))->cl.l)) -#define gco2ccl(o) check_exp((o)->tt == LUA_VCCL, &((cast_u(o))->cl.c)) -#define gco2cl(o) \ - check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl)) -#define gco2t(o) check_exp((o)->tt == LUA_VTABLE, &((cast_u(o))->h)) -#define gco2p(o) check_exp((o)->tt == LUA_VPROTO, &((cast_u(o))->p)) -#define gco2th(o) check_exp((o)->tt == LUA_VTHREAD, &((cast_u(o))->th)) -#define gco2upv(o) check_exp((o)->tt == LUA_VUPVAL, &((cast_u(o))->upv)) - - - - - - -#define obj2gco(v) check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc)) - - - -#define gettotalbytes(g) cast(lu_mem, (g)->totalbytes + (g)->GCdebt) - -LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); -LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); -LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); -LUAI_FUNC void luaE_freeCI (lua_State *L); -LUAI_FUNC void luaE_shrinkCI (lua_State *L); -LUAI_FUNC void luaE_checkcstack (lua_State *L); -LUAI_FUNC void luaE_incCstack (lua_State *L); -LUAI_FUNC void luaE_warning (lua_State *L, const char *msg, int tocont); -LUAI_FUNC void luaE_warnerror (lua_State *L, const char *where); -LUAI_FUNC int luaE_resetthread (lua_State *L, int status); - - -#endif diff --git a/include/lua/lstring.h b/include/lua/lstring.h deleted file mode 100644 index 58467238..00000000 --- a/include/lua/lstring.h +++ /dev/null @@ -1,58 +0,0 @@ -# 1 "./lua/lstring.h" - - - - - - -#ifndef lstring_h -#define lstring_h - -#include "lgc.h" -#include "lobject.h" -#include "lstate.h" - - - - - - -#define MEMERRMSG "not enough memory" - - - - - - -#define sizelstring(l) (offsetof(TString, contents) + ((l) + 1) * sizeof(char)) - -#define luaS_newliteral(L,s) (luaS_newlstr(L, "" s, \ - (sizeof(s)/sizeof(char))-1)) - - - - - -#define isreserved(s) ((s)->tt == LUA_VSHRSTR && (s)->extra > 0) - - - - - -#define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) - - -LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); -LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); -LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); -LUAI_FUNC void luaS_resize (lua_State *L, int newsize); -LUAI_FUNC void luaS_clearcache (global_State *g); -LUAI_FUNC void luaS_init (lua_State *L); -LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); -LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue); -LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); -LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); -LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); - - -#endif diff --git a/include/lua/ltable.h b/include/lua/ltable.h deleted file mode 100644 index ab84a746..00000000 --- a/include/lua/ltable.h +++ /dev/null @@ -1,67 +0,0 @@ -# 1 "./lua/ltable.h" - - - - - - -#ifndef ltable_h -#define ltable_h - -#include "lobject.h" - - -#define gnode(t,i) (&(t)->node[i]) -#define gval(n) (&(n)->i_val) -#define gnext(n) ((n)->u.next) - - - - - - - -#define invalidateTMcache(t) ((t)->flags &= ~maskflags) - - - -#define isdummy(t) ((t)->lastfree == NULL) - - - -#define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) - - - -#define nodefromval(v) cast(Node *, (v)) - - -LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); -LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, - TValue *value); -LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); -LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); -LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); -LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key, - TValue *value); -LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, - TValue *value); -LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, - const TValue *slot, TValue *value); -LUAI_FUNC Table *luaH_new (lua_State *L); -LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, - unsigned int nhsize); -LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); -LUAI_FUNC void luaH_free (lua_State *L, Table *t); -LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); -LUAI_FUNC lua_Unsigned luaH_getn (Table *t); -LUAI_FUNC unsigned int luaH_realasize (const Table *t); - - -#if defined(LUA_DEBUG) -LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); -LUAI_FUNC int luaH_isdummy (const Table *t); -#endif - - -#endif diff --git a/include/lua/ltm.h b/include/lua/ltm.h deleted file mode 100644 index e1867e7c..00000000 --- a/include/lua/ltm.h +++ /dev/null @@ -1,97 +0,0 @@ -# 1 "./lua/ltm.h" - - - - - - -#ifndef ltm_h -#define ltm_h - - -#include "lobject.h" - - - - - - -typedef enum { - TM_INDEX, - TM_NEWINDEX, - TM_GC, - TM_MODE, - TM_LEN, - TM_EQ, - TM_ADD, - TM_SUB, - TM_MUL, - TM_MOD, - TM_POW, - TM_DIV, - TM_IDIV, - TM_BAND, - TM_BOR, - TM_BXOR, - TM_SHL, - TM_SHR, - TM_UNM, - TM_BNOT, - TM_LT, - TM_LE, - TM_CONCAT, - TM_CALL, - TM_CLOSE, - TM_N -} TMS; -# 54 "./lua/ltm.h" -#define maskflags (~(~0u << (TM_EQ + 1))) - - - - - - -#define notm(tm) ttisnil(tm) - - -#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ - ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) - -#define fasttm(l,et,e) gfasttm(G(l), et, e) - -#define ttypename(x) luaT_typenames_[(x) + 1] - -LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTYPES];) - - -LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); - -LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); -LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, - TMS event); -LUAI_FUNC void luaT_init (lua_State *L); - -LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, - const TValue *p2, const TValue *p3); -LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f, - const TValue *p1, const TValue *p2, StkId p3); -LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, - StkId res, TMS event); -LUAI_FUNC void luaT_tryconcatTM (lua_State *L); -LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1, - const TValue *p2, int inv, StkId res, TMS event); -LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, - int inv, StkId res, TMS event); -LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, - const TValue *p2, TMS event); -LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, - int inv, int isfloat, TMS event); - -LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams, - struct CallInfo *ci, const Proto *p); -LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci, - StkId where, int wanted); - - -#endif diff --git a/include/lua/lua.h b/include/lua/lua.h deleted file mode 100644 index 7b962b9b..00000000 --- a/include/lua/lua.h +++ /dev/null @@ -1,458 +0,0 @@ -# 1 "./lua/lua.h" -# 9 "./lua/lua.h" -#ifndef lua_h -#define lua_h - -#include -#include - - -#include "luaconf.h" - - -#define LUA_VERSION_MAJOR "5" -#define LUA_VERSION_MINOR "4" -#define LUA_VERSION_RELEASE "4" - -#define LUA_VERSION_NUM 504 -#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 4) - -#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR -#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE -#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2022 Lua.org, PUC-Rio" -#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" - - - -#define LUA_SIGNATURE "\x1bLua" - - -#define LUA_MULTRET (-1) - - - - - - - -#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000) -#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) - - - -#define LUA_OK 0 -#define LUA_YIELD 1 -#define LUA_ERRRUN 2 -#define LUA_ERRSYNTAX 3 -#define LUA_ERRMEM 4 -#define LUA_ERRERR 5 - - -typedef struct lua_State lua_State; - - - - - -#define LUA_TNONE (-1) - -#define LUA_TNIL 0 -#define LUA_TBOOLEAN 1 -#define LUA_TLIGHTUSERDATA 2 -#define LUA_TNUMBER 3 -#define LUA_TSTRING 4 -#define LUA_TTABLE 5 -#define LUA_TFUNCTION 6 -#define LUA_TUSERDATA 7 -#define LUA_TTHREAD 8 - -#define LUA_NUMTYPES 9 - - - - -#define LUA_MINSTACK 20 - - - -#define LUA_RIDX_MAINTHREAD 1 -#define LUA_RIDX_GLOBALS 2 -#define LUA_RIDX_LAST LUA_RIDX_GLOBALS - - - -typedef LUA_NUMBER lua_Number; - - - -typedef LUA_INTEGER lua_Integer; - - -typedef LUA_UNSIGNED lua_Unsigned; - - -typedef LUA_KCONTEXT lua_KContext; - - - - - -typedef int (*lua_CFunction) (lua_State *L); - - - - -typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); - - - - - -typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); - -typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud); - - - - - -typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); - - - - - -typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont); - - - - - - - -#if defined(LUA_USER_H) -#include LUA_USER_H -#endif - - - - - -extern const char lua_ident[]; - - - - - -LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); -LUA_API void (lua_close) (lua_State *L); -LUA_API lua_State *(lua_newthread) (lua_State *L); -LUA_API int (lua_resetthread) (lua_State *L); - -LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); - - -LUA_API lua_Number (lua_version) (lua_State *L); - - - - - -LUA_API int (lua_absindex) (lua_State *L, int idx); -LUA_API int (lua_gettop) (lua_State *L); -LUA_API void (lua_settop) (lua_State *L, int idx); -LUA_API void (lua_pushvalue) (lua_State *L, int idx); -LUA_API void (lua_rotate) (lua_State *L, int idx, int n); -LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); -LUA_API int (lua_checkstack) (lua_State *L, int n); - -LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); - - - - - - -LUA_API int (lua_isnumber) (lua_State *L, int idx); -LUA_API int (lua_isstring) (lua_State *L, int idx); -LUA_API int (lua_iscfunction) (lua_State *L, int idx); -LUA_API int (lua_isinteger) (lua_State *L, int idx); -LUA_API int (lua_isuserdata) (lua_State *L, int idx); -LUA_API int (lua_type) (lua_State *L, int idx); -LUA_API const char *(lua_typename) (lua_State *L, int tp); - -LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); -LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); -LUA_API int (lua_toboolean) (lua_State *L, int idx); -LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); -LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx); -LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); -LUA_API void *(lua_touserdata) (lua_State *L, int idx); -LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); -LUA_API const void *(lua_topointer) (lua_State *L, int idx); - - - - - - -#define LUA_OPADD 0 -#define LUA_OPSUB 1 -#define LUA_OPMUL 2 -#define LUA_OPMOD 3 -#define LUA_OPPOW 4 -#define LUA_OPDIV 5 -#define LUA_OPIDIV 6 -#define LUA_OPBAND 7 -#define LUA_OPBOR 8 -#define LUA_OPBXOR 9 -#define LUA_OPSHL 10 -#define LUA_OPSHR 11 -#define LUA_OPUNM 12 -#define LUA_OPBNOT 13 - -LUA_API void (lua_arith) (lua_State *L, int op); - -#define LUA_OPEQ 0 -#define LUA_OPLT 1 -#define LUA_OPLE 2 - -LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); -LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); - - - - - -LUA_API void (lua_pushnil) (lua_State *L); -LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); -LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); -LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len); -LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); -LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, - va_list argp); -LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); -LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); -LUA_API void (lua_pushboolean) (lua_State *L, int b); -LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); -LUA_API int (lua_pushthread) (lua_State *L); - - - - - -LUA_API int (lua_getglobal) (lua_State *L, const char *name); -LUA_API int (lua_gettable) (lua_State *L, int idx); -LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k); -LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n); -LUA_API int (lua_rawget) (lua_State *L, int idx); -LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n); -LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p); - -LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); -LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue); -LUA_API int (lua_getmetatable) (lua_State *L, int objindex); -LUA_API int (lua_getiuservalue) (lua_State *L, int idx, int n); - - - - - -LUA_API void (lua_setglobal) (lua_State *L, const char *name); -LUA_API void (lua_settable) (lua_State *L, int idx); -LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); -LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n); -LUA_API void (lua_rawset) (lua_State *L, int idx); -LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n); -LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); -LUA_API int (lua_setmetatable) (lua_State *L, int objindex); -LUA_API int (lua_setiuservalue) (lua_State *L, int idx, int n); - - - - - -LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, - lua_KContext ctx, lua_KFunction k); -#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) - -LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, - lua_KContext ctx, lua_KFunction k); -#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) - -LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, - const char *chunkname, const char *mode); - -LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip); - - - - - -LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, - lua_KFunction k); -LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg, - int *nres); -LUA_API int (lua_status) (lua_State *L); -LUA_API int (lua_isyieldable) (lua_State *L); - -#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) - - - - - -LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud); -LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont); - - - - - - -#define LUA_GCSTOP 0 -#define LUA_GCRESTART 1 -#define LUA_GCCOLLECT 2 -#define LUA_GCCOUNT 3 -#define LUA_GCCOUNTB 4 -#define LUA_GCSTEP 5 -#define LUA_GCSETPAUSE 6 -#define LUA_GCSETSTEPMUL 7 -#define LUA_GCISRUNNING 9 -#define LUA_GCGEN 10 -#define LUA_GCINC 11 - -LUA_API int (lua_gc) (lua_State *L, int what, ...); - - - - - - -LUA_API int (lua_error) (lua_State *L); - -LUA_API int (lua_next) (lua_State *L, int idx); - -LUA_API void (lua_concat) (lua_State *L, int n); -LUA_API void (lua_len) (lua_State *L, int idx); - -LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s); - -LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); -LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); - -LUA_API void (lua_toclose) (lua_State *L, int idx); -LUA_API void (lua_closeslot) (lua_State *L, int idx); -# 360 "./lua/lua.h" -#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE)) - -#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) -#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) - -#define lua_pop(L,n) lua_settop(L, -(n)-1) - -#define lua_newtable(L) lua_createtable(L, 0, 0) - -#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) - -#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) - -#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) -#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) -#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) -#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) -#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) -#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) -#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) -#define lua_isnoneornil(L,n) (lua_type(L, (n)) <= 0) - -#define lua_pushliteral(L,s) lua_pushstring(L, "" s) - -#define lua_pushglobaltable(L) \ - ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)) - -#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) - - -#define lua_insert(L,idx) lua_rotate(L, (idx), 1) - -#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) - -#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1)) -# 404 "./lua/lua.h" -#if defined(LUA_COMPAT_APIINTCASTS) - -#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) -#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) -#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) - -#endif - -#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1) -#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1) -#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1) - -#define LUA_NUMTAGS LUA_NUMTYPES -# 430 "./lua/lua.h" -#define LUA_HOOKCALL 0 -#define LUA_HOOKRET 1 -#define LUA_HOOKLINE 2 -#define LUA_HOOKCOUNT 3 -#define LUA_HOOKTAILCALL 4 - - - - - -#define LUA_MASKCALL (1 << LUA_HOOKCALL) -#define LUA_MASKRET (1 << LUA_HOOKRET) -#define LUA_MASKLINE (1 << LUA_HOOKLINE) -#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) - -typedef struct lua_Debug lua_Debug; - - - -typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); - - -LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); -LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); -LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); -LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); -LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); -LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); - -LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); -LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, - int fidx2, int n2); - -LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); -LUA_API lua_Hook (lua_gethook) (lua_State *L); -LUA_API int (lua_gethookmask) (lua_State *L); -LUA_API int (lua_gethookcount) (lua_State *L); - -LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit); - -struct lua_Debug { - int event; - const char *name; - const char *namewhat; - const char *what; - const char *source; - size_t srclen; - int currentline; - int linedefined; - int lastlinedefined; - unsigned char nups; - unsigned char nparams; - char isvararg; - char istailcall; - unsigned short ftransfer; - unsigned short ntransfer; - char short_src[LUA_IDSIZE]; - - struct CallInfo *i_ci; -}; -# 518 "./lua/lua.h" -#endif diff --git a/include/lua/lua.hpp b/include/lua/lua.hpp deleted file mode 100644 index ac0c31d4..00000000 --- a/include/lua/lua.hpp +++ /dev/null @@ -1,6 +0,0 @@ - -extern "C" { -#include "lua.h" -#include "lualib.h" -#include "lauxlib.h" -} diff --git a/include/lua/luaconf.h b/include/lua/luaconf.h deleted file mode 100644 index 2a5bc9d6..00000000 --- a/include/lua/luaconf.h +++ /dev/null @@ -1,474 +0,0 @@ -# 1 "./lua/luaconf.h" - - - - - - - -#ifndef luaconf_h -#define luaconf_h - -#include -#include -# 50 "./lua/luaconf.h" -#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) -#define LUA_USE_WINDOWS -#endif - - -#if defined(LUA_USE_WINDOWS) -#define LUA_DL_DLL -#define LUA_USE_C89 -#endif - - -#if defined(LUA_USE_LINUX) -#define LUA_USE_POSIX -#define LUA_USE_DLOPEN -#endif - - -#if defined(LUA_USE_MACOSX) -#define LUA_USE_POSIX -#define LUA_USE_DLOPEN -#endif - - - - - -#define LUAI_IS32INT ((UINT_MAX >> 30) >= 3) -# 101 "./lua/luaconf.h" -#define LUA_INT_INT 1 -#define LUA_INT_LONG 2 -#define LUA_INT_LONGLONG 3 - - -#define LUA_FLOAT_FLOAT 1 -#define LUA_FLOAT_DOUBLE 2 -#define LUA_FLOAT_LONGDOUBLE 3 - - - -#define LUA_INT_DEFAULT LUA_INT_LONGLONG -#define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE - - - - - -#define LUA_32BITS 0 - - - - - - - -#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) -#define LUA_C89_NUMBERS 1 -#else -#define LUA_C89_NUMBERS 0 -#endif - - -#if LUA_32BITS - - - -#if LUAI_IS32INT -#define LUA_INT_TYPE LUA_INT_INT -#else -#define LUA_INT_TYPE LUA_INT_LONG -#endif -#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT - -#elif LUA_C89_NUMBERS - - - -#define LUA_INT_TYPE LUA_INT_LONG -#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE - -#else - - -#define LUA_INT_TYPE LUA_INT_DEFAULT -#define LUA_FLOAT_TYPE LUA_FLOAT_DEFAULT - -#endif -# 178 "./lua/luaconf.h" -#define LUA_PATH_SEP ";" -#define LUA_PATH_MARK "?" -#define LUA_EXEC_DIR "!" -# 193 "./lua/luaconf.h" -#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR -#if defined(_WIN32) - - - - -#define LUA_LDIR "!\\lua\\" -#define LUA_CDIR "!\\" -#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" - -#if !defined(LUA_PATH_DEFAULT) -#define LUA_PATH_DEFAULT \ - LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ - LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ - LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ - ".\\?.lua;" ".\\?\\init.lua" -#endif - -#if !defined(LUA_CPATH_DEFAULT) -#define LUA_CPATH_DEFAULT \ - LUA_CDIR"?.dll;" \ - LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ - LUA_CDIR"loadall.dll;" ".\\?.dll" -#endif - -#else - -#define LUA_ROOT "/usr/local/" -#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" -#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" - -#if !defined(LUA_PATH_DEFAULT) -#define LUA_PATH_DEFAULT \ - LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ - LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ - "./?.lua;" "./?/init.lua" -#endif - -#if !defined(LUA_CPATH_DEFAULT) -#define LUA_CPATH_DEFAULT \ - LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" -#endif - -#endif - - - - - - - -#if !defined(LUA_DIRSEP) - -#if defined(_WIN32) -#define LUA_DIRSEP "\\" -#else -#define LUA_DIRSEP "/" -#endif - -#endif -# 272 "./lua/luaconf.h" -#if defined(LUA_BUILD_AS_DLL) - -#if defined(LUA_CORE) || defined(LUA_LIB) -#define LUA_API __declspec(dllexport) -#else -#define LUA_API __declspec(dllimport) -#endif - -#else - -#define LUA_API extern - -#endif - - - - - -#define LUALIB_API LUA_API -#define LUAMOD_API LUA_API -# 308 "./lua/luaconf.h" -#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ - defined(__ELF__) -#define LUAI_FUNC __attribute__((visibility("internal"))) extern -#else -#define LUAI_FUNC extern -#endif - -#define LUAI_DDEC(dec) LUAI_FUNC dec -#define LUAI_DDEF -# 332 "./lua/luaconf.h" -#if defined(LUA_COMPAT_5_3) - - - - - - - -#define LUA_COMPAT_MATHLIB -# 349 "./lua/luaconf.h" -#define LUA_COMPAT_APIINTCASTS - - - - - - -#define LUA_COMPAT_LT_LE -# 366 "./lua/luaconf.h" -#define lua_strlen(L,i) lua_rawlen(L, (i)) - -#define lua_objlen(L,i) lua_rawlen(L, (i)) - -#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) -#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) - -#endif -# 403 "./lua/luaconf.h" -#define l_floor(x) (l_mathop(floor)(x)) - -#define lua_number2str(s,sz,n) \ - l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) -# 417 "./lua/luaconf.h" -#define lua_numbertointeger(n,p) \ - ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ - (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ - (*(p) = (LUA_INTEGER)(n), 1)) - - - - -#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT - -#define LUA_NUMBER float - -#define l_floatatt(n) (FLT_ ##n) - -#define LUAI_UACNUMBER double - -#define LUA_NUMBER_FRMLEN "" -#define LUA_NUMBER_FMT "%.7g" - -#define l_mathop(op) op ##f - -#define lua_str2number(s,p) strtof((s), (p)) - - -#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE - -#define LUA_NUMBER long double - -#define l_floatatt(n) (LDBL_ ##n) - -#define LUAI_UACNUMBER long double - -#define LUA_NUMBER_FRMLEN "L" -#define LUA_NUMBER_FMT "%.19Lg" - -#define l_mathop(op) op ##l - -#define lua_str2number(s,p) strtold((s), (p)) - -#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE - -#define LUA_NUMBER double - -#define l_floatatt(n) (DBL_ ##n) - -#define LUAI_UACNUMBER double - -#define LUA_NUMBER_FRMLEN "" -#define LUA_NUMBER_FMT "%.14g" - -#define l_mathop(op) op - -#define lua_str2number(s,p) strtod((s), (p)) - -#else - -#error "numeric float type not defined" - -#endif -# 494 "./lua/luaconf.h" -#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" - -#define LUAI_UACINT LUA_INTEGER - -#define lua_integer2str(s,sz,n) \ - l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) - - - - - -#define LUA_UNSIGNED unsigned LUAI_UACINT - - - - -#if LUA_INT_TYPE == LUA_INT_INT - -#define LUA_INTEGER int -#define LUA_INTEGER_FRMLEN "" - -#define LUA_MAXINTEGER INT_MAX -#define LUA_MININTEGER INT_MIN - -#define LUA_MAXUNSIGNED UINT_MAX - -#elif LUA_INT_TYPE == LUA_INT_LONG - -#define LUA_INTEGER long -#define LUA_INTEGER_FRMLEN "l" - -#define LUA_MAXINTEGER LONG_MAX -#define LUA_MININTEGER LONG_MIN - -#define LUA_MAXUNSIGNED ULONG_MAX - -#elif LUA_INT_TYPE == LUA_INT_LONGLONG - - -#if defined(LLONG_MAX) - - -#define LUA_INTEGER long long -#define LUA_INTEGER_FRMLEN "ll" - -#define LUA_MAXINTEGER LLONG_MAX -#define LUA_MININTEGER LLONG_MIN - -#define LUA_MAXUNSIGNED ULLONG_MAX - -#elif defined(LUA_USE_WINDOWS) - - -#define LUA_INTEGER __int64 -#define LUA_INTEGER_FRMLEN "I64" - -#define LUA_MAXINTEGER _I64_MAX -#define LUA_MININTEGER _I64_MIN - -#define LUA_MAXUNSIGNED _UI64_MAX - -#else - -#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ - or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" - -#endif - -#else - -#error "numeric integer type not defined" - -#endif -# 581 "./lua/luaconf.h" -#if !defined(LUA_USE_C89) -#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) -#else -#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) -#endif -# 594 "./lua/luaconf.h" -#if !defined(LUA_USE_C89) -#define lua_strx2number(s,p) lua_str2number(s,p) -#endif - - - - - - -#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p) -# 612 "./lua/luaconf.h" -#if !defined(LUA_USE_C89) -#define lua_number2strx(L,b,sz,f,n) \ - ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n))) -#endif -# 624 "./lua/luaconf.h" -#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) -#undef l_mathop -#undef lua_str2number -#define l_mathop(op) (lua_Number)op -#define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) -#endif -# 638 "./lua/luaconf.h" -#define LUA_KCONTEXT ptrdiff_t - -#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ - __STDC_VERSION__ >= 199901L -#include -#if defined(INTPTR_MAX) -#undef LUA_KCONTEXT -#define LUA_KCONTEXT intptr_t -#endif -#endif - - - - - - - -#if !defined(lua_getlocaledecpoint) -#define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) -#endif -# 666 "./lua/luaconf.h" -#if !defined(luai_likely) - -#if defined(__GNUC__) && !defined(LUA_NOBUILTIN) -#define luai_likely(x) (__builtin_expect(((x) != 0), 1)) -#define luai_unlikely(x) (__builtin_expect(((x) != 0), 0)) -#else -#define luai_likely(x) (x) -#define luai_unlikely(x) (x) -#endif - -#endif - - -#if defined(LUA_CORE) || defined(LUA_LIB) - -#define l_likely(x) luai_likely(x) -#define l_unlikely(x) luai_unlikely(x) -#endif -# 710 "./lua/luaconf.h" -#if defined(LUA_USE_APICHECK) -#include -#define luai_apicheck(l,e) assert(e) -#endif -# 733 "./lua/luaconf.h" -#if LUAI_IS32INT -#define LUAI_MAXSTACK 1000000 -#else -#define LUAI_MAXSTACK 15000 -#endif - - - - - - - -#define LUA_EXTRASPACE (sizeof(void *)) - - - - - - - -#define LUA_IDSIZE 60 - - - - - -#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number))) - - - - - - -#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l -# 785 "./lua/luaconf.h" -#endif diff --git a/include/lua/lualib.h b/include/lua/lualib.h deleted file mode 100644 index 4b9dc442..00000000 --- a/include/lua/lualib.h +++ /dev/null @@ -1,53 +0,0 @@ -# 1 "./lua/lualib.h" - - - - - - - -#ifndef lualib_h -#define lualib_h - -#include "lua.h" - - - -#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR - - -LUAMOD_API int (luaopen_base) (lua_State *L); - -#define LUA_COLIBNAME "coroutine" -LUAMOD_API int (luaopen_coroutine) (lua_State *L); - -#define LUA_TABLIBNAME "table" -LUAMOD_API int (luaopen_table) (lua_State *L); - -#define LUA_IOLIBNAME "io" -LUAMOD_API int (luaopen_io) (lua_State *L); - -#define LUA_OSLIBNAME "os" -LUAMOD_API int (luaopen_os) (lua_State *L); - -#define LUA_STRLIBNAME "string" -LUAMOD_API int (luaopen_string) (lua_State *L); - -#define LUA_UTF8LIBNAME "utf8" -LUAMOD_API int (luaopen_utf8) (lua_State *L); - -#define LUA_MATHLIBNAME "math" -LUAMOD_API int (luaopen_math) (lua_State *L); - -#define LUA_DBLIBNAME "debug" -LUAMOD_API int (luaopen_debug) (lua_State *L); - -#define LUA_LOADLIBNAME "package" -LUAMOD_API int (luaopen_package) (lua_State *L); - - - -LUALIB_API void (luaL_openlibs) (lua_State *L); - - -#endif diff --git a/include/lua/lundump.h b/include/lua/lundump.h deleted file mode 100644 index 01129e6b..00000000 --- a/include/lua/lundump.h +++ /dev/null @@ -1,37 +0,0 @@ -# 1 "./lua/lundump.h" - - - - - - -#ifndef lundump_h -#define lundump_h - -#include "llimits.h" -#include "lobject.h" -#include "lzio.h" - - - -#define LUAC_DATA "\x19\x93\r\n\x1a\n" - -#define LUAC_INT 0x5678 -#define LUAC_NUM cast_num(370.5) - - - - -#define MYINT(s) (s[0]-'0') -#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) - -#define LUAC_FORMAT 0 - - -LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); - - -LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, - void* data, int strip); - -#endif diff --git a/include/lua/lvm.h b/include/lua/lvm.h deleted file mode 100644 index 54ea9d0f..00000000 --- a/include/lua/lvm.h +++ /dev/null @@ -1,129 +0,0 @@ -# 1 "./lua/lvm.h" - - - - - - -#ifndef lvm_h -#define lvm_h - - -#include "ldo.h" -#include "lobject.h" -#include "ltm.h" - - -#if !defined(LUA_NOCVTN2S) -#define cvt2str(o) ttisnumber(o) -#else -#define cvt2str(o) 0 -#endif - - -#if !defined(LUA_NOCVTS2N) -#define cvt2num(o) ttisstring(o) -#else -#define cvt2num(o) 0 -#endif - - - - - - - -#if !defined(LUA_FLOORN2I) -#define LUA_FLOORN2I F2Ieq -#endif - - - - - -typedef enum { - F2Ieq, - F2Ifloor, - F2Iceil -} F2Imod; - - - -#define tonumber(o,n) \ - (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) - - - -#define tonumberns(o,n) \ - (ttisfloat(o) ? ((n) = fltvalue(o), 1) : \ - (ttisinteger(o) ? ((n) = cast_num(ivalue(o)), 1) : 0)) - - - -#define tointeger(o,i) \ - (l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \ - : luaV_tointeger(o,i,LUA_FLOORN2I)) - - - -#define tointegerns(o,i) \ - (l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \ - : luaV_tointegerns(o,i,LUA_FLOORN2I)) - - -#define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) - -#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) -# 85 "./lua/lvm.h" -#define luaV_fastget(L,t,k,slot,f) \ - (!ttistable(t) \ - ? (slot = NULL, 0) \ - : (slot = f(hvalue(t), k), \ - !isempty(slot))) - - - - - - -#define luaV_fastgeti(L,t,k,slot) \ - (!ttistable(t) \ - ? (slot = NULL, 0) \ - : (slot = (l_castS2U(k) - 1u < hvalue(t)->alimit) \ - ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ - !isempty(slot))) - - - - - - -#define luaV_finishfastset(L,t,slot,v) \ - { setobj2t(L, cast(TValue *,slot), v); \ - luaC_barrierback(L, gcvalue(t), v); } - - - - -LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); -LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); -LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); -LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); -LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode); -LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, - F2Imod mode); -LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); -LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, - StkId val, const TValue *slot); -LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, - TValue *val, const TValue *slot); -LUAI_FUNC void luaV_finishOp (lua_State *L); -LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); -LUAI_FUNC void luaV_concat (lua_State *L, int total); -LUAI_FUNC lua_Integer luaV_idiv (lua_State *L, lua_Integer x, lua_Integer y); -LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); -LUAI_FUNC lua_Number luaV_modf (lua_State *L, lua_Number x, lua_Number y); -LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); -LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); - -#endif diff --git a/include/lua/lzio.h b/include/lua/lzio.h deleted file mode 100644 index be512221..00000000 --- a/include/lua/lzio.h +++ /dev/null @@ -1,67 +0,0 @@ -# 1 "./lua/lzio.h" - - - - - - - -#ifndef lzio_h -#define lzio_h - -#include "lua.h" - -#include "lmem.h" - - -#define EOZ (-1) - -typedef struct Zio ZIO; - -#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) - - -typedef struct Mbuffer { - char *buffer; - size_t n; - size_t buffsize; -} Mbuffer; - -#define luaZ_initbuffer(L,buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) - -#define luaZ_buffer(buff) ((buff)->buffer) -#define luaZ_sizebuffer(buff) ((buff)->buffsize) -#define luaZ_bufflen(buff) ((buff)->n) - -#define luaZ_buffremove(buff,i) ((buff)->n -= (i)) -#define luaZ_resetbuffer(buff) ((buff)->n = 0) - - -#define luaZ_resizebuffer(L,buff,size) \ - ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ - (buff)->buffsize, size), \ - (buff)->buffsize = size) - -#define luaZ_freebuffer(L,buff) luaZ_resizebuffer(L, buff, 0) - - -LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, - void *data); -LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); - - - - - -struct Zio { - size_t n; - const char *p; - lua_Reader reader; - void *data; - lua_State *L; -}; - - -LUAI_FUNC int luaZ_fill (ZIO *z); - -#endif diff --git a/include/sqlite3/sqlite3.h b/include/sqlite3/sqlite3.h deleted file mode 100644 index 88bb88d6..00000000 --- a/include/sqlite3/sqlite3.h +++ /dev/null @@ -1,2152 +0,0 @@ -# 1 "./sqlite3/sqlite3.h" -# 33 "./sqlite3/sqlite3.h" -#ifndef SQLITE3_H -#define SQLITE3_H -#include - - - - -#ifdef __cplusplus -extern "C" { -#endif -# 71 "./sqlite3/sqlite3.h" -#ifndef SQLITE_EXTERN -#define SQLITE_EXTERN extern -#endif -#ifndef SQLITE_API -#define SQLITE_API -#endif -#ifndef SQLITE_CDECL -#define SQLITE_CDECL -#endif -#ifndef SQLITE_APICALL -#define SQLITE_APICALL -#endif -#ifndef SQLITE_STDCALL -#define SQLITE_STDCALL SQLITE_APICALL -#endif -#ifndef SQLITE_CALLBACK -#define SQLITE_CALLBACK -#endif -#ifndef SQLITE_SYSAPI -#define SQLITE_SYSAPI -#endif -# 106 "./sqlite3/sqlite3.h" -#define SQLITE_DEPRECATED -#define SQLITE_EXPERIMENTAL - - - - -#ifdef SQLITE_VERSION -#undef SQLITE_VERSION -#endif -#ifdef SQLITE_VERSION_NUMBER -#undef SQLITE_VERSION_NUMBER -#endif -# 149 "./sqlite3/sqlite3.h" -#define SQLITE_VERSION "3.38.1" -#define SQLITE_VERSION_NUMBER 3038001 -#define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc" -# 185 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; -SQLITE_API const char *sqlite3_libversion(void); -SQLITE_API const char *sqlite3_sourceid(void); -SQLITE_API int sqlite3_libversion_number(void); -# 212 "./sqlite3/sqlite3.h" -#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS -SQLITE_API int sqlite3_compileoption_used(const char *zOptName); -SQLITE_API const char *sqlite3_compileoption_get(int N); -#else -#define sqlite3_compileoption_used(X) 0 -#define sqlite3_compileoption_get(X) ((void*)0) -#endif -# 256 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_threadsafe(void); -# 272 "./sqlite3/sqlite3.h" -typedef struct sqlite3 sqlite3; -# 290 "./sqlite3/sqlite3.h" -#ifdef SQLITE_INT64_TYPE - typedef SQLITE_INT64_TYPE sqlite_int64; -# ifdef SQLITE_UINT64_TYPE - typedef SQLITE_UINT64_TYPE sqlite_uint64; -# else - typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; -# endif -#elif defined(_MSC_VER) || defined(__BORLANDC__) - typedef __int64 sqlite_int64; - typedef unsigned __int64 sqlite_uint64; -#else - typedef long long int sqlite_int64; - typedef unsigned long long int sqlite_uint64; -#endif -typedef sqlite_int64 sqlite3_int64; -typedef sqlite_uint64 sqlite3_uint64; - - - - - -#ifdef SQLITE_OMIT_FLOATING_POINT -#define double sqlite3_int64 -#endif -# 353 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_close(sqlite3*); -SQLITE_API int sqlite3_close_v2(sqlite3*); - - - - - - -typedef int (*sqlite3_callback)(void*,int,char**, char**); -# 425 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_exec( - sqlite3*, - const char *sql, - int (*callback)(void*,int,char**,char**), - void *, - char **errmsg -); -# 444 "./sqlite3/sqlite3.h" -#define SQLITE_OK 0 - -#define SQLITE_ERROR 1 -#define SQLITE_INTERNAL 2 -#define SQLITE_PERM 3 -#define SQLITE_ABORT 4 -#define SQLITE_BUSY 5 -#define SQLITE_LOCKED 6 -#define SQLITE_NOMEM 7 -#define SQLITE_READONLY 8 -#define SQLITE_INTERRUPT 9 -#define SQLITE_IOERR 10 -#define SQLITE_CORRUPT 11 -#define SQLITE_NOTFOUND 12 -#define SQLITE_FULL 13 -#define SQLITE_CANTOPEN 14 -#define SQLITE_PROTOCOL 15 -#define SQLITE_EMPTY 16 -#define SQLITE_SCHEMA 17 -#define SQLITE_TOOBIG 18 -#define SQLITE_CONSTRAINT 19 -#define SQLITE_MISMATCH 20 -#define SQLITE_MISUSE 21 -#define SQLITE_NOLFS 22 -#define SQLITE_AUTH 23 -#define SQLITE_FORMAT 24 -#define SQLITE_RANGE 25 -#define SQLITE_NOTADB 26 -#define SQLITE_NOTICE 27 -#define SQLITE_WARNING 28 -#define SQLITE_ROW 100 -#define SQLITE_DONE 101 -# 495 "./sqlite3/sqlite3.h" -#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8)) -#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8)) -#define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8)) -#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) -#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) -#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) -#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) -#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) -#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) -#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) -#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) -#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) -#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) -#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) -#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) -#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) -#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) -#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) -#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) -#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) -#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) -#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) -#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) -#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) -#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) -#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) -#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) -#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) -#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) -#define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8)) -#define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8)) -#define SQLITE_IOERR_BEGIN_ATOMIC (SQLITE_IOERR | (29<<8)) -#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8)) -#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) -#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8)) -#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8)) -#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) -#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8)) -#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) -#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) -#define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8)) -#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) -#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) -#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) -#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) -#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) -#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8)) -#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) -#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8)) -#define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8)) -#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) -#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) -#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8)) -#define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8)) -#define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8)) -#define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6<<8)) -#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8)) -#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8)) -#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8)) -#define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8)) -#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8)) -#define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8)) -#define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8)) -#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) -#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) -#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) -#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) -#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8)) -#define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8)) -#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) -#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) -#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) -#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) -#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) -#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) -# 591 "./sqlite3/sqlite3.h" -#define SQLITE_OPEN_READONLY 0x00000001 -#define SQLITE_OPEN_READWRITE 0x00000002 -#define SQLITE_OPEN_CREATE 0x00000004 -#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 -#define SQLITE_OPEN_EXCLUSIVE 0x00000010 -#define SQLITE_OPEN_AUTOPROXY 0x00000020 -#define SQLITE_OPEN_URI 0x00000040 -#define SQLITE_OPEN_MEMORY 0x00000080 -#define SQLITE_OPEN_MAIN_DB 0x00000100 -#define SQLITE_OPEN_TEMP_DB 0x00000200 -#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 -#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 -#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 -#define SQLITE_OPEN_SUBJOURNAL 0x00002000 -#define SQLITE_OPEN_SUPER_JOURNAL 0x00004000 -#define SQLITE_OPEN_NOMUTEX 0x00008000 -#define SQLITE_OPEN_FULLMUTEX 0x00010000 -#define SQLITE_OPEN_SHAREDCACHE 0x00020000 -#define SQLITE_OPEN_PRIVATECACHE 0x00040000 -#define SQLITE_OPEN_WAL 0x00080000 -#define SQLITE_OPEN_NOFOLLOW 0x01000000 -#define SQLITE_OPEN_EXRESCODE 0x02000000 - - - -#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 -# 652 "./sqlite3/sqlite3.h" -#define SQLITE_IOCAP_ATOMIC 0x00000001 -#define SQLITE_IOCAP_ATOMIC512 0x00000002 -#define SQLITE_IOCAP_ATOMIC1K 0x00000004 -#define SQLITE_IOCAP_ATOMIC2K 0x00000008 -#define SQLITE_IOCAP_ATOMIC4K 0x00000010 -#define SQLITE_IOCAP_ATOMIC8K 0x00000020 -#define SQLITE_IOCAP_ATOMIC16K 0x00000040 -#define SQLITE_IOCAP_ATOMIC32K 0x00000080 -#define SQLITE_IOCAP_ATOMIC64K 0x00000100 -#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 -#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 -#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 -#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 -#define SQLITE_IOCAP_IMMUTABLE 0x00002000 -#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 -# 675 "./sqlite3/sqlite3.h" -#define SQLITE_LOCK_NONE 0 -#define SQLITE_LOCK_SHARED 1 -#define SQLITE_LOCK_RESERVED 2 -#define SQLITE_LOCK_PENDING 3 -#define SQLITE_LOCK_EXCLUSIVE 4 -# 707 "./sqlite3/sqlite3.h" -#define SQLITE_SYNC_NORMAL 0x00002 -#define SQLITE_SYNC_FULL 0x00003 -#define SQLITE_SYNC_DATAONLY 0x00010 -# 722 "./sqlite3/sqlite3.h" -typedef struct sqlite3_file sqlite3_file; -struct sqlite3_file { - const struct sqlite3_io_methods *pMethods; -}; -# 821 "./sqlite3/sqlite3.h" -typedef struct sqlite3_io_methods sqlite3_io_methods; -struct sqlite3_io_methods { - int iVersion; - int (*xClose)(sqlite3_file*); - int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); - int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); - int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); - int (*xSync)(sqlite3_file*, int flags); - int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); - int (*xLock)(sqlite3_file*, int); - int (*xUnlock)(sqlite3_file*, int); - int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); - int (*xFileControl)(sqlite3_file*, int op, void *pArg); - int (*xSectorSize)(sqlite3_file*); - int (*xDeviceCharacteristics)(sqlite3_file*); - - int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**); - int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); - void (*xShmBarrier)(sqlite3_file*); - int (*xShmUnmap)(sqlite3_file*, int deleteFlag); - - int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); - int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p); - - -}; -# 1187 "./sqlite3/sqlite3.h" -#define SQLITE_FCNTL_LOCKSTATE 1 -#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 -#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 -#define SQLITE_FCNTL_LAST_ERRNO 4 -#define SQLITE_FCNTL_SIZE_HINT 5 -#define SQLITE_FCNTL_CHUNK_SIZE 6 -#define SQLITE_FCNTL_FILE_POINTER 7 -#define SQLITE_FCNTL_SYNC_OMITTED 8 -#define SQLITE_FCNTL_WIN32_AV_RETRY 9 -#define SQLITE_FCNTL_PERSIST_WAL 10 -#define SQLITE_FCNTL_OVERWRITE 11 -#define SQLITE_FCNTL_VFSNAME 12 -#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13 -#define SQLITE_FCNTL_PRAGMA 14 -#define SQLITE_FCNTL_BUSYHANDLER 15 -#define SQLITE_FCNTL_TEMPFILENAME 16 -#define SQLITE_FCNTL_MMAP_SIZE 18 -#define SQLITE_FCNTL_TRACE 19 -#define SQLITE_FCNTL_HAS_MOVED 20 -#define SQLITE_FCNTL_SYNC 21 -#define SQLITE_FCNTL_COMMIT_PHASETWO 22 -#define SQLITE_FCNTL_WIN32_SET_HANDLE 23 -#define SQLITE_FCNTL_WAL_BLOCK 24 -#define SQLITE_FCNTL_ZIPVFS 25 -#define SQLITE_FCNTL_RBU 26 -#define SQLITE_FCNTL_VFS_POINTER 27 -#define SQLITE_FCNTL_JOURNAL_POINTER 28 -#define SQLITE_FCNTL_WIN32_GET_HANDLE 29 -#define SQLITE_FCNTL_PDB 30 -#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 -#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 -#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 -#define SQLITE_FCNTL_LOCK_TIMEOUT 34 -#define SQLITE_FCNTL_DATA_VERSION 35 -#define SQLITE_FCNTL_SIZE_LIMIT 36 -#define SQLITE_FCNTL_CKPT_DONE 37 -#define SQLITE_FCNTL_RESERVE_BYTES 38 -#define SQLITE_FCNTL_CKPT_START 39 -#define SQLITE_FCNTL_EXTERNAL_READER 40 -#define SQLITE_FCNTL_CKSM_FILE 41 - - -#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE -#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE -#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO -# 1244 "./sqlite3/sqlite3.h" -typedef struct sqlite3_mutex sqlite3_mutex; -# 1254 "./sqlite3/sqlite3.h" -typedef struct sqlite3_api_routines sqlite3_api_routines; -# 1425 "./sqlite3/sqlite3.h" -typedef struct sqlite3_vfs sqlite3_vfs; -typedef void (*sqlite3_syscall_ptr)(void); -struct sqlite3_vfs { - int iVersion; - int szOsFile; - int mxPathname; - sqlite3_vfs *pNext; - const char *zName; - void *pAppData; - int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, - int flags, int *pOutFlags); - int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); - int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); - int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); - void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); - void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); - void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); - void (*xDlClose)(sqlite3_vfs*, void*); - int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); - int (*xSleep)(sqlite3_vfs*, int microseconds); - int (*xCurrentTime)(sqlite3_vfs*, double*); - int (*xGetLastError)(sqlite3_vfs*, int, char *); - - - - - int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*); - - - - - int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr); - sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName); - const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName); - - - - - -}; -# 1486 "./sqlite3/sqlite3.h" -#define SQLITE_ACCESS_EXISTS 0 -#define SQLITE_ACCESS_READWRITE 1 -#define SQLITE_ACCESS_READ 2 -# 1512 "./sqlite3/sqlite3.h" -#define SQLITE_SHM_UNLOCK 1 -#define SQLITE_SHM_LOCK 2 -#define SQLITE_SHM_SHARED 4 -#define SQLITE_SHM_EXCLUSIVE 8 -# 1525 "./sqlite3/sqlite3.h" -#define SQLITE_SHM_NLOCK 8 -# 1603 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_initialize(void); -SQLITE_API int sqlite3_shutdown(void); -SQLITE_API int sqlite3_os_init(void); -SQLITE_API int sqlite3_os_end(void); -# 1639 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_config(int, ...); -# 1658 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); -# 1723 "./sqlite3/sqlite3.h" -typedef struct sqlite3_mem_methods sqlite3_mem_methods; -struct sqlite3_mem_methods { - void *(*xMalloc)(int); - void (*xFree)(void*); - void *(*xRealloc)(void*,int); - int (*xSize)(void*); - int (*xRoundup)(int); - int (*xInit)(void*); - void (*xShutdown)(void*); - void *pAppData; -}; -# 2088 "./sqlite3/sqlite3.h" -#define SQLITE_CONFIG_SINGLETHREAD 1 -#define SQLITE_CONFIG_MULTITHREAD 2 -#define SQLITE_CONFIG_SERIALIZED 3 -#define SQLITE_CONFIG_MALLOC 4 -#define SQLITE_CONFIG_GETMALLOC 5 -#define SQLITE_CONFIG_SCRATCH 6 -#define SQLITE_CONFIG_PAGECACHE 7 -#define SQLITE_CONFIG_HEAP 8 -#define SQLITE_CONFIG_MEMSTATUS 9 -#define SQLITE_CONFIG_MUTEX 10 -#define SQLITE_CONFIG_GETMUTEX 11 - -#define SQLITE_CONFIG_LOOKASIDE 13 -#define SQLITE_CONFIG_PCACHE 14 -#define SQLITE_CONFIG_GETPCACHE 15 -#define SQLITE_CONFIG_LOG 16 -#define SQLITE_CONFIG_URI 17 -#define SQLITE_CONFIG_PCACHE2 18 -#define SQLITE_CONFIG_GETPCACHE2 19 -#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 -#define SQLITE_CONFIG_SQLLOG 21 -#define SQLITE_CONFIG_MMAP_SIZE 22 -#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 -#define SQLITE_CONFIG_PCACHE_HDRSZ 24 -#define SQLITE_CONFIG_PMASZ 25 -#define SQLITE_CONFIG_STMTJRNL_SPILL 26 -#define SQLITE_CONFIG_SMALL_MALLOC 27 -#define SQLITE_CONFIG_SORTERREF_SIZE 28 -#define SQLITE_CONFIG_MEMDB_MAXSIZE 29 -# 2399 "./sqlite3/sqlite3.h" -#define SQLITE_DBCONFIG_MAINDBNAME 1000 -#define SQLITE_DBCONFIG_LOOKASIDE 1001 -#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 -#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 -#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 -#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 -#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 -#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 -#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 -#define SQLITE_DBCONFIG_RESET_DATABASE 1009 -#define SQLITE_DBCONFIG_DEFENSIVE 1010 -#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 -#define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 -#define SQLITE_DBCONFIG_DQS_DML 1013 -#define SQLITE_DBCONFIG_DQS_DDL 1014 -#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 -#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 -#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 -#define SQLITE_DBCONFIG_MAX 1017 -# 2427 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); -# 2489 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); -# 2499 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64); -# 2560 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_changes(sqlite3*); -SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*); -# 2602 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_total_changes(sqlite3*); -SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*); -# 2640 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_interrupt(sqlite3*); -# 2675 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_complete(const char *sql); -SQLITE_API int sqlite3_complete16(const void *sql); -# 2737 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*); -# 2760 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); -# 2835 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_get_table( - sqlite3 *db, - const char *zSql, - char ***pazResult, - int *pnRow, - int *pnColumn, - char **pzErrmsg -); -SQLITE_API void sqlite3_free_table(char **result); -# 2885 "./sqlite3/sqlite3.h" -SQLITE_API char *sqlite3_mprintf(const char*,...); -SQLITE_API char *sqlite3_vmprintf(const char*, va_list); -SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); -SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); -# 2965 "./sqlite3/sqlite3.h" -SQLITE_API void *sqlite3_malloc(int); -SQLITE_API void *sqlite3_malloc64(sqlite3_uint64); -SQLITE_API void *sqlite3_realloc(void*, int); -SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64); -SQLITE_API void sqlite3_free(void*); -SQLITE_API sqlite3_uint64 sqlite3_msize(void*); -# 2995 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_int64 sqlite3_memory_used(void); -SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); -# 3019 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_randomness(int N, void *P); -# 3110 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_set_authorizer( - sqlite3*, - int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), - void *pUserData -); -# 3128 "./sqlite3/sqlite3.h" -#define SQLITE_DENY 1 -#define SQLITE_IGNORE 2 -# 3151 "./sqlite3/sqlite3.h" -#define SQLITE_CREATE_INDEX 1 -#define SQLITE_CREATE_TABLE 2 -#define SQLITE_CREATE_TEMP_INDEX 3 -#define SQLITE_CREATE_TEMP_TABLE 4 -#define SQLITE_CREATE_TEMP_TRIGGER 5 -#define SQLITE_CREATE_TEMP_VIEW 6 -#define SQLITE_CREATE_TRIGGER 7 -#define SQLITE_CREATE_VIEW 8 -#define SQLITE_DELETE 9 -#define SQLITE_DROP_INDEX 10 -#define SQLITE_DROP_TABLE 11 -#define SQLITE_DROP_TEMP_INDEX 12 -#define SQLITE_DROP_TEMP_TABLE 13 -#define SQLITE_DROP_TEMP_TRIGGER 14 -#define SQLITE_DROP_TEMP_VIEW 15 -#define SQLITE_DROP_TRIGGER 16 -#define SQLITE_DROP_VIEW 17 -#define SQLITE_INSERT 18 -#define SQLITE_PRAGMA 19 -#define SQLITE_READ 20 -#define SQLITE_SELECT 21 -#define SQLITE_TRANSACTION 22 -#define SQLITE_UPDATE 23 -#define SQLITE_ATTACH 24 -#define SQLITE_DETACH 25 -#define SQLITE_ALTER_TABLE 26 -#define SQLITE_REINDEX 27 -#define SQLITE_ANALYZE 28 -#define SQLITE_CREATE_VTABLE 29 -#define SQLITE_DROP_VTABLE 30 -#define SQLITE_FUNCTION 31 -#define SQLITE_SAVEPOINT 32 -#define SQLITE_COPY 0 -#define SQLITE_RECURSIVE 33 -# 3218 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*, - void(*xTrace)(void*,const char*), void*); -SQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, - void(*xProfile)(void*,const char*,sqlite3_uint64), void*); -# 3275 "./sqlite3/sqlite3.h" -#define SQLITE_TRACE_STMT 0x01 -#define SQLITE_TRACE_PROFILE 0x02 -#define SQLITE_TRACE_ROW 0x04 -#define SQLITE_TRACE_CLOSE 0x08 -# 3309 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_trace_v2( - sqlite3*, - unsigned uMask, - int(*xCallback)(unsigned,void*,void*,void*), - void *pCtx -); -# 3348 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); -# 3620 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_open( - const char *filename, - sqlite3 **ppDb -); -SQLITE_API int sqlite3_open16( - const void *filename, - sqlite3 **ppDb -); -SQLITE_API int sqlite3_open_v2( - const char *filename, - sqlite3 **ppDb, - int flags, - const char *zVfs -); -# 3701 "./sqlite3/sqlite3.h" -SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); -SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); -SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); -SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N); -# 3733 "./sqlite3/sqlite3.h" -SQLITE_API const char *sqlite3_filename_database(const char*); -SQLITE_API const char *sqlite3_filename_journal(const char*); -SQLITE_API const char *sqlite3_filename_wal(const char*); -# 3754 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*); -# 3801 "./sqlite3/sqlite3.h" -SQLITE_API char *sqlite3_create_filename( - const char *zDatabase, - const char *zJournal, - const char *zWal, - int nParam, - const char **azParam -); -SQLITE_API void sqlite3_free_filename(char*); -# 3870 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_errcode(sqlite3 *db); -SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); -SQLITE_API const char *sqlite3_errmsg(sqlite3*); -SQLITE_API const void *sqlite3_errmsg16(sqlite3*); -SQLITE_API const char *sqlite3_errstr(int); -SQLITE_API int sqlite3_error_offset(sqlite3 *db); -# 3901 "./sqlite3/sqlite3.h" -typedef struct sqlite3_stmt sqlite3_stmt; -# 3943 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); -# 4001 "./sqlite3/sqlite3.h" -#define SQLITE_LIMIT_LENGTH 0 -#define SQLITE_LIMIT_SQL_LENGTH 1 -#define SQLITE_LIMIT_COLUMN 2 -#define SQLITE_LIMIT_EXPR_DEPTH 3 -#define SQLITE_LIMIT_COMPOUND_SELECT 4 -#define SQLITE_LIMIT_VDBE_OP 5 -#define SQLITE_LIMIT_FUNCTION_ARG 6 -#define SQLITE_LIMIT_ATTACHED 7 -#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 -#define SQLITE_LIMIT_VARIABLE_NUMBER 9 -#define SQLITE_LIMIT_TRIGGER_DEPTH 10 -#define SQLITE_LIMIT_WORKER_THREADS 11 -# 4049 "./sqlite3/sqlite3.h" -#define SQLITE_PREPARE_PERSISTENT 0x01 -#define SQLITE_PREPARE_NORMALIZE 0x02 -#define SQLITE_PREPARE_NO_VTAB 0x04 -# 4153 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_prepare( - sqlite3 *db, - const char *zSql, - int nByte, - sqlite3_stmt **ppStmt, - const char **pzTail -); -SQLITE_API int sqlite3_prepare_v2( - sqlite3 *db, - const char *zSql, - int nByte, - sqlite3_stmt **ppStmt, - const char **pzTail -); -SQLITE_API int sqlite3_prepare_v3( - sqlite3 *db, - const char *zSql, - int nByte, - unsigned int prepFlags, - sqlite3_stmt **ppStmt, - const char **pzTail -); -SQLITE_API int sqlite3_prepare16( - sqlite3 *db, - const void *zSql, - int nByte, - sqlite3_stmt **ppStmt, - const void **pzTail -); -SQLITE_API int sqlite3_prepare16_v2( - sqlite3 *db, - const void *zSql, - int nByte, - sqlite3_stmt **ppStmt, - const void **pzTail -); -SQLITE_API int sqlite3_prepare16_v3( - sqlite3 *db, - const void *zSql, - int nByte, - unsigned int prepFlags, - sqlite3_stmt **ppStmt, - const void **pzTail -); -# 4239 "./sqlite3/sqlite3.h" -SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); -SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt); -#ifdef SQLITE_ENABLE_NORMALIZE -SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt); -#endif -# 4292 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); -# 4304 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt); -# 4325 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*); -# 4369 "./sqlite3/sqlite3.h" -typedef struct sqlite3_value sqlite3_value; -# 4383 "./sqlite3/sqlite3.h" -typedef struct sqlite3_context sqlite3_context; -# 4525 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); -SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, - void(*)(void*)); -SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); -SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); -SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); -SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); -SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); -SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); -SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, - void(*)(void*), unsigned char encoding); -SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); -SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*)); -SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); -SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64); -# 4560 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); -# 4588 "./sqlite3/sqlite3.h" -SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); -# 4606 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); -# 4616 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); -# 4632 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); -# 4661 "./sqlite3/sqlite3.h" -SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); -SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); -# 4706 "./sqlite3/sqlite3.h" -SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int); -SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); -SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int); -SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); -SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); -SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); -# 4743 "./sqlite3/sqlite3.h" -SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); -SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); -# 4828 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_step(sqlite3_stmt*); -# 4849 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); -# 4872 "./sqlite3/sqlite3.h" -#define SQLITE_INTEGER 1 -#define SQLITE_FLOAT 2 -#define SQLITE_BLOB 4 -#define SQLITE_NULL 5 -#ifdef SQLITE_TEXT -#undef SQLITE_TEXT -#else -#define SQLITE_TEXT 3 -#endif -#define SQLITE3_TEXT 3 -# 5096 "./sqlite3/sqlite3.h" -SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); -SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); -SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); -SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); -SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); -SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); -SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); -SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); -SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); -SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); -# 5133 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); -# 5160 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); -# 5285 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_create_function( - sqlite3 *db, - const char *zFunctionName, - int nArg, - int eTextRep, - void *pApp, - void (*xFunc)(sqlite3_context*,int,sqlite3_value**), - void (*xStep)(sqlite3_context*,int,sqlite3_value**), - void (*xFinal)(sqlite3_context*) -); -SQLITE_API int sqlite3_create_function16( - sqlite3 *db, - const void *zFunctionName, - int nArg, - int eTextRep, - void *pApp, - void (*xFunc)(sqlite3_context*,int,sqlite3_value**), - void (*xStep)(sqlite3_context*,int,sqlite3_value**), - void (*xFinal)(sqlite3_context*) -); -SQLITE_API int sqlite3_create_function_v2( - sqlite3 *db, - const char *zFunctionName, - int nArg, - int eTextRep, - void *pApp, - void (*xFunc)(sqlite3_context*,int,sqlite3_value**), - void (*xStep)(sqlite3_context*,int,sqlite3_value**), - void (*xFinal)(sqlite3_context*), - void(*xDestroy)(void*) -); -SQLITE_API int sqlite3_create_window_function( - sqlite3 *db, - const char *zFunctionName, - int nArg, - int eTextRep, - void *pApp, - void (*xStep)(sqlite3_context*,int,sqlite3_value**), - void (*xFinal)(sqlite3_context*), - void (*xValue)(sqlite3_context*), - void (*xInverse)(sqlite3_context*,int,sqlite3_value**), - void(*xDestroy)(void*) -); - - - - - - - -#define SQLITE_UTF8 1 -#define SQLITE_UTF16LE 2 -#define SQLITE_UTF16BE 3 -#define SQLITE_UTF16 4 -#define SQLITE_ANY 5 -#define SQLITE_UTF16_ALIGNED 8 -# 5407 "./sqlite3/sqlite3.h" -#define SQLITE_DETERMINISTIC 0x000000800 -#define SQLITE_DIRECTONLY 0x000080000 -#define SQLITE_SUBTYPE 0x000100000 -#define SQLITE_INNOCUOUS 0x000200000 -# 5422 "./sqlite3/sqlite3.h" -#ifndef SQLITE_OMIT_DEPRECATED -SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); -SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); -SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); -SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); -SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); -SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), - void*,sqlite3_int64); -#endif -# 5560 "./sqlite3/sqlite3.h" -SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); -SQLITE_API double sqlite3_value_double(sqlite3_value*); -SQLITE_API int sqlite3_value_int(sqlite3_value*); -SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); -SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*); -SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); -SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); -SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); -SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); -SQLITE_API int sqlite3_value_bytes(sqlite3_value*); -SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); -SQLITE_API int sqlite3_value_type(sqlite3_value*); -SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); -SQLITE_API int sqlite3_value_nochange(sqlite3_value*); -SQLITE_API int sqlite3_value_frombind(sqlite3_value*); -# 5586 "./sqlite3/sqlite3.h" -SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*); -# 5602 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value*); -SQLITE_API void sqlite3_value_free(sqlite3_value*); -# 5648 "./sqlite3/sqlite3.h" -SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); -# 5663 "./sqlite3/sqlite3.h" -SQLITE_API void *sqlite3_user_data(sqlite3_context*); -# 5675 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); -# 5734 "./sqlite3/sqlite3.h" -SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); -SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); -# 5752 "./sqlite3/sqlite3.h" -typedef void (*sqlite3_destructor_type)(void*); -#define SQLITE_STATIC ((sqlite3_destructor_type)0) -#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) -# 5902 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); -SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*, - sqlite3_uint64,void(*)(void*)); -SQLITE_API void sqlite3_result_double(sqlite3_context*, double); -SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); -SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); -SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); -SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); -SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); -SQLITE_API void sqlite3_result_int(sqlite3_context*, int); -SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); -SQLITE_API void sqlite3_result_null(sqlite3_context*); -SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); -SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64, - void(*)(void*), unsigned char encoding); -SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); -SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); -SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); -SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); -SQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*)); -SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); -SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); -# 5938 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); -# 6021 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_create_collation( - sqlite3*, - const char *zName, - int eTextRep, - void *pArg, - int(*xCompare)(void*,int,const void*,int,const void*) -); -SQLITE_API int sqlite3_create_collation_v2( - sqlite3*, - const char *zName, - int eTextRep, - void *pArg, - int(*xCompare)(void*,int,const void*,int,const void*), - void(*xDestroy)(void*) -); -SQLITE_API int sqlite3_create_collation16( - sqlite3*, - const void *zName, - int eTextRep, - void *pArg, - int(*xCompare)(void*,int,const void*,int,const void*) -); -# 6071 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_collation_needed( - sqlite3*, - void*, - void(*)(void*,sqlite3*,int eTextRep,const char*) -); -SQLITE_API int sqlite3_collation_needed16( - sqlite3*, - void*, - void(*)(void*,sqlite3*,int eTextRep,const void*) -); - -#ifdef SQLITE_ENABLE_CEROD - - - - -SQLITE_API void sqlite3_activate_cerod( - const char *zPassPhrase -); -#endif -# 6109 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_sleep(int); -# 6167 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; -# 6204 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory; -# 6225 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_win32_set_directory( - unsigned long type, - void *zValue -); -SQLITE_API int sqlite3_win32_set_directory8(unsigned long type, const char *zValue); -SQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zValue); - - - - - - - -#define SQLITE_WIN32_DATA_DIRECTORY_TYPE 1 -#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE 2 -# 6263 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_get_autocommit(sqlite3*); -# 6276 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); -# 6308 "./sqlite3/sqlite3.h" -SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); -# 6318 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); -# 6336 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema); -# 6367 "./sqlite3/sqlite3.h" -#define SQLITE_TXN_NONE 0 -#define SQLITE_TXN_READ 1 -#define SQLITE_TXN_WRITE 2 -# 6385 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); -# 6434 "./sqlite3/sqlite3.h" -SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); -SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); -# 6495 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_autovacuum_pages( - sqlite3 *db, - unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), - void*, - void(*)(void*) -); -# 6552 "./sqlite3/sqlite3.h" -SQLITE_API void *sqlite3_update_hook( - sqlite3*, - void(*)(void *,int ,char const *,char const *,sqlite3_int64), - void* -); -# 6597 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_enable_shared_cache(int); -# 6613 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_release_memory(int); -# 6627 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_db_release_memory(sqlite3*); -# 6693 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); -SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N); -# 6705 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); -# 6777 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_table_column_metadata( - sqlite3 *db, - const char *zDbName, - const char *zTableName, - const char *zColumnName, - char const **pzDataType, - char const **pzCollSeq, - int *pNotNull, - int *pPrimaryKey, - int *pAutoinc -); -# 6833 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_load_extension( - sqlite3 *db, - const char *zFile, - const char *zProc, - char **pzErrMsg -); -# 6865 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); -# 6903 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_auto_extension(void(*xEntryPoint)(void)); -# 6915 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void)); - - - - - - - -SQLITE_API void sqlite3_reset_auto_extension(void); -# 6937 "./sqlite3/sqlite3.h" -typedef struct sqlite3_vtab sqlite3_vtab; -typedef struct sqlite3_index_info sqlite3_index_info; -typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; -typedef struct sqlite3_module sqlite3_module; -# 6958 "./sqlite3/sqlite3.h" -struct sqlite3_module { - int iVersion; - int (*xCreate)(sqlite3*, void *pAux, - int argc, const char *const*argv, - sqlite3_vtab **ppVTab, char**); - int (*xConnect)(sqlite3*, void *pAux, - int argc, const char *const*argv, - sqlite3_vtab **ppVTab, char**); - int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); - int (*xDisconnect)(sqlite3_vtab *pVTab); - int (*xDestroy)(sqlite3_vtab *pVTab); - int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); - int (*xClose)(sqlite3_vtab_cursor*); - int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, - int argc, sqlite3_value **argv); - int (*xNext)(sqlite3_vtab_cursor*); - int (*xEof)(sqlite3_vtab_cursor*); - int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); - int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); - int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); - int (*xBegin)(sqlite3_vtab *pVTab); - int (*xSync)(sqlite3_vtab *pVTab); - int (*xCommit)(sqlite3_vtab *pVTab); - int (*xRollback)(sqlite3_vtab *pVTab); - int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, - void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), - void **ppArg); - int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); - - - int (*xSavepoint)(sqlite3_vtab *pVTab, int); - int (*xRelease)(sqlite3_vtab *pVTab, int); - int (*xRollbackTo)(sqlite3_vtab *pVTab, int); - - - int (*xShadowName)(const char*); -}; -# 7098 "./sqlite3/sqlite3.h" -struct sqlite3_index_info { - - int nConstraint; - struct sqlite3_index_constraint { - int iColumn; - unsigned char op; - unsigned char usable; - int iTermOffset; - } *aConstraint; - int nOrderBy; - struct sqlite3_index_orderby { - int iColumn; - unsigned char desc; - } *aOrderBy; - - struct sqlite3_index_constraint_usage { - int argvIndex; - unsigned char omit; - } *aConstraintUsage; - int idxNum; - char *idxStr; - int needToFreeIdxStr; - int orderByConsumed; - double estimatedCost; - - sqlite3_int64 estimatedRows; - - int idxFlags; - - sqlite3_uint64 colUsed; -}; -# 7137 "./sqlite3/sqlite3.h" -#define SQLITE_INDEX_SCAN_UNIQUE 1 -# 7177 "./sqlite3/sqlite3.h" -#define SQLITE_INDEX_CONSTRAINT_EQ 2 -#define SQLITE_INDEX_CONSTRAINT_GT 4 -#define SQLITE_INDEX_CONSTRAINT_LE 8 -#define SQLITE_INDEX_CONSTRAINT_LT 16 -#define SQLITE_INDEX_CONSTRAINT_GE 32 -#define SQLITE_INDEX_CONSTRAINT_MATCH 64 -#define SQLITE_INDEX_CONSTRAINT_LIKE 65 -#define SQLITE_INDEX_CONSTRAINT_GLOB 66 -#define SQLITE_INDEX_CONSTRAINT_REGEXP 67 -#define SQLITE_INDEX_CONSTRAINT_NE 68 -#define SQLITE_INDEX_CONSTRAINT_ISNOT 69 -#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70 -#define SQLITE_INDEX_CONSTRAINT_ISNULL 71 -#define SQLITE_INDEX_CONSTRAINT_IS 72 -#define SQLITE_INDEX_CONSTRAINT_LIMIT 73 -#define SQLITE_INDEX_CONSTRAINT_OFFSET 74 -#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150 -# 7227 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_create_module( - sqlite3 *db, - const char *zName, - const sqlite3_module *p, - void *pClientData -); -SQLITE_API int sqlite3_create_module_v2( - sqlite3 *db, - const char *zName, - const sqlite3_module *p, - void *pClientData, - void(*xDestroy)(void*) -); -# 7253 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_drop_modules( - sqlite3 *db, - const char **azKeep -); -# 7276 "./sqlite3/sqlite3.h" -struct sqlite3_vtab { - const sqlite3_module *pModule; - int nRef; - char *zErrMsg; - -}; -# 7300 "./sqlite3/sqlite3.h" -struct sqlite3_vtab_cursor { - sqlite3_vtab *pVtab; - -}; -# 7313 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL); -# 7332 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); -# 7356 "./sqlite3/sqlite3.h" -typedef struct sqlite3_blob sqlite3_blob; -# 7441 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_blob_open( - sqlite3*, - const char *zDb, - const char *zTable, - const char *zColumn, - sqlite3_int64 iRow, - int flags, - sqlite3_blob **ppBlob -); -# 7474 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); -# 7497 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_blob_close(sqlite3_blob *); -# 7513 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); -# 7542 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); -# 7584 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); -# 7615 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); -SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); -SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); -# 7733 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); -SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); -SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); -SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); -SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); -# 7804 "./sqlite3/sqlite3.h" -typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; -struct sqlite3_mutex_methods { - int (*xMutexInit)(void); - int (*xMutexEnd)(void); - sqlite3_mutex *(*xMutexAlloc)(int); - void (*xMutexFree)(sqlite3_mutex *); - void (*xMutexEnter)(sqlite3_mutex *); - int (*xMutexTry)(sqlite3_mutex *); - void (*xMutexLeave)(sqlite3_mutex *); - int (*xMutexHeld)(sqlite3_mutex *); - int (*xMutexNotheld)(sqlite3_mutex *); -}; -# 7846 "./sqlite3/sqlite3.h" -#ifndef NDEBUG -SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); -SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); -#endif -# 7861 "./sqlite3/sqlite3.h" -#define SQLITE_MUTEX_FAST 0 -#define SQLITE_MUTEX_RECURSIVE 1 -#define SQLITE_MUTEX_STATIC_MAIN 2 -#define SQLITE_MUTEX_STATIC_MEM 3 -#define SQLITE_MUTEX_STATIC_MEM2 4 -#define SQLITE_MUTEX_STATIC_OPEN 4 -#define SQLITE_MUTEX_STATIC_PRNG 5 -#define SQLITE_MUTEX_STATIC_LRU 6 -#define SQLITE_MUTEX_STATIC_LRU2 7 -#define SQLITE_MUTEX_STATIC_PMEM 7 -#define SQLITE_MUTEX_STATIC_APP1 8 -#define SQLITE_MUTEX_STATIC_APP2 9 -#define SQLITE_MUTEX_STATIC_APP3 10 -#define SQLITE_MUTEX_STATIC_VFS1 11 -#define SQLITE_MUTEX_STATIC_VFS2 12 -#define SQLITE_MUTEX_STATIC_VFS3 13 - - -#define SQLITE_MUTEX_STATIC_MASTER 2 -# 7892 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); -# 7935 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); -# 7954 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_test_control(int op, ...); -# 7967 "./sqlite3/sqlite3.h" -#define SQLITE_TESTCTRL_FIRST 5 -#define SQLITE_TESTCTRL_PRNG_SAVE 5 -#define SQLITE_TESTCTRL_PRNG_RESTORE 6 -#define SQLITE_TESTCTRL_PRNG_RESET 7 -#define SQLITE_TESTCTRL_BITVEC_TEST 8 -#define SQLITE_TESTCTRL_FAULT_INSTALL 9 -#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 -#define SQLITE_TESTCTRL_PENDING_BYTE 11 -#define SQLITE_TESTCTRL_ASSERT 12 -#define SQLITE_TESTCTRL_ALWAYS 13 -#define SQLITE_TESTCTRL_RESERVE 14 -#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 -#define SQLITE_TESTCTRL_ISKEYWORD 16 -#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 -#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17 -#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 -#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 -#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 19 -#define SQLITE_TESTCTRL_NEVER_CORRUPT 20 -#define SQLITE_TESTCTRL_VDBE_COVERAGE 21 -#define SQLITE_TESTCTRL_BYTEORDER 22 -#define SQLITE_TESTCTRL_ISINIT 23 -#define SQLITE_TESTCTRL_SORTER_MMAP 24 -#define SQLITE_TESTCTRL_IMPOSTER 25 -#define SQLITE_TESTCTRL_PARSER_COVERAGE 26 -#define SQLITE_TESTCTRL_RESULT_INTREAL 27 -#define SQLITE_TESTCTRL_PRNG_SEED 28 -#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 -#define SQLITE_TESTCTRL_SEEK_COUNT 30 -#define SQLITE_TESTCTRL_TRACEFLAGS 31 -#define SQLITE_TESTCTRL_TUNE 32 -#define SQLITE_TESTCTRL_LOGEST 33 -#define SQLITE_TESTCTRL_LAST 33 -# 8048 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_keyword_count(void); -SQLITE_API int sqlite3_keyword_name(int,const char**,int*); -SQLITE_API int sqlite3_keyword_check(const char*,int); -# 8068 "./sqlite3/sqlite3.h" -typedef struct sqlite3_str sqlite3_str; -# 8095 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*); -# 8110 "./sqlite3/sqlite3.h" -SQLITE_API char *sqlite3_str_finish(sqlite3_str*); -# 8144 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...); -SQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list); -SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N); -SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn); -SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C); -SQLITE_API void sqlite3_str_reset(sqlite3_str*); -# 8180 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_str_errcode(sqlite3_str*); -SQLITE_API int sqlite3_str_length(sqlite3_str*); -SQLITE_API char *sqlite3_str_value(sqlite3_str*); -# 8210 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); -SQLITE_API int sqlite3_status64( - int op, - sqlite3_int64 *pCurrent, - sqlite3_int64 *pHighwater, - int resetFlag -); -# 8286 "./sqlite3/sqlite3.h" -#define SQLITE_STATUS_MEMORY_USED 0 -#define SQLITE_STATUS_PAGECACHE_USED 1 -#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 -#define SQLITE_STATUS_SCRATCH_USED 3 -#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 -#define SQLITE_STATUS_MALLOC_SIZE 5 -#define SQLITE_STATUS_PARSER_STACK 6 -#define SQLITE_STATUS_PAGECACHE_SIZE 7 -#define SQLITE_STATUS_SCRATCH_SIZE 8 -#define SQLITE_STATUS_MALLOC_COUNT 9 -# 8320 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); -# 8433 "./sqlite3/sqlite3.h" -#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 -#define SQLITE_DBSTATUS_CACHE_USED 1 -#define SQLITE_DBSTATUS_SCHEMA_USED 2 -#define SQLITE_DBSTATUS_STMT_USED 3 -#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 -#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 -#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 -#define SQLITE_DBSTATUS_CACHE_HIT 7 -#define SQLITE_DBSTATUS_CACHE_MISS 8 -#define SQLITE_DBSTATUS_CACHE_WRITE 9 -#define SQLITE_DBSTATUS_DEFERRED_FKS 10 -#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11 -#define SQLITE_DBSTATUS_CACHE_SPILL 12 -#define SQLITE_DBSTATUS_MAX 12 -# 8473 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); -# 8540 "./sqlite3/sqlite3.h" -#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 -#define SQLITE_STMTSTATUS_SORT 2 -#define SQLITE_STMTSTATUS_AUTOINDEX 3 -#define SQLITE_STMTSTATUS_VM_STEP 4 -#define SQLITE_STMTSTATUS_REPREPARE 5 -#define SQLITE_STMTSTATUS_RUN 6 -#define SQLITE_STMTSTATUS_FILTER_MISS 7 -#define SQLITE_STMTSTATUS_FILTER_HIT 8 -#define SQLITE_STMTSTATUS_MEMUSED 99 -# 8561 "./sqlite3/sqlite3.h" -typedef struct sqlite3_pcache sqlite3_pcache; -# 8573 "./sqlite3/sqlite3.h" -typedef struct sqlite3_pcache_page sqlite3_pcache_page; -struct sqlite3_pcache_page { - void *pBuf; - void *pExtra; -}; -# 8738 "./sqlite3/sqlite3.h" -typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2; -struct sqlite3_pcache_methods2 { - int iVersion; - void *pArg; - int (*xInit)(void*); - void (*xShutdown)(void*); - sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable); - void (*xCachesize)(sqlite3_pcache*, int nCachesize); - int (*xPagecount)(sqlite3_pcache*); - sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); - void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard); - void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, - unsigned oldKey, unsigned newKey); - void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); - void (*xDestroy)(sqlite3_pcache*); - void (*xShrink)(sqlite3_pcache*); -}; - - - - - - -typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; -struct sqlite3_pcache_methods { - void *pArg; - int (*xInit)(void*); - void (*xShutdown)(void*); - sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); - void (*xCachesize)(sqlite3_pcache*, int nCachesize); - int (*xPagecount)(sqlite3_pcache*); - void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); - void (*xUnpin)(sqlite3_pcache*, void*, int discard); - void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); - void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); - void (*xDestroy)(sqlite3_pcache*); -}; -# 8787 "./sqlite3/sqlite3.h" -typedef struct sqlite3_backup sqlite3_backup; -# 8975 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_backup *sqlite3_backup_init( - sqlite3 *pDest, - const char *zDestName, - sqlite3 *pSource, - const char *zSourceName -); -SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); -SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); -SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); -SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); -# 9101 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_unlock_notify( - sqlite3 *pBlocked, - void (*xNotify)(void **apArg, int nArg), - void *pNotifyArg -); -# 9116 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_stricmp(const char *, const char *); -SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); -# 9134 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr); -# 9157 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc); -# 9180 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...); -# 9217 "./sqlite3/sqlite3.h" -SQLITE_API void *sqlite3_wal_hook( - sqlite3*, - int(*)(void *,sqlite3*,const char*,int), - void* -); -# 9252 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); -# 9274 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); -# 9368 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_wal_checkpoint_v2( - sqlite3 *db, - const char *zDb, - int eMode, - int *pnLog, - int *pnCkpt -); -# 9385 "./sqlite3/sqlite3.h" -#define SQLITE_CHECKPOINT_PASSIVE 0 -#define SQLITE_CHECKPOINT_FULL 1 -#define SQLITE_CHECKPOINT_RESTART 2 -#define SQLITE_CHECKPOINT_TRUNCATE 3 -# 9408 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); -# 9472 "./sqlite3/sqlite3.h" -#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 -#define SQLITE_VTAB_INNOCUOUS 2 -#define SQLITE_VTAB_DIRECTONLY 3 -# 9486 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *); -# 9512 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*); -# 9547 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int); -# 9613 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*); -# 9686 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle); -# 9734 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut); -SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut); -# 9777 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal); -# 9791 "./sqlite3/sqlite3.h" -#define SQLITE_ROLLBACK 1 - -#define SQLITE_FAIL 3 - -#define SQLITE_REPLACE 5 -# 9844 "./sqlite3/sqlite3.h" -#define SQLITE_SCANSTAT_NLOOP 0 -#define SQLITE_SCANSTAT_NVISIT 1 -#define SQLITE_SCANSTAT_EST 2 -#define SQLITE_SCANSTAT_NAME 3 -#define SQLITE_SCANSTAT_EXPLAIN 4 -#define SQLITE_SCANSTAT_SELECTID 5 -# 9882 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_stmt_scanstatus( - sqlite3_stmt *pStmt, - int idx, - int iScanStatusOp, - void *pOut -); -# 9898 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*); -# 9931 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_db_cacheflush(sqlite3*); -# 10025 "./sqlite3/sqlite3.h" -#if defined(SQLITE_ENABLE_PREUPDATE_HOOK) -SQLITE_API void *sqlite3_preupdate_hook( - sqlite3 *db, - void(*xPreUpdate)( - void *pCtx, - sqlite3 *db, - int op, - char const *zDb, - char const *zName, - sqlite3_int64 iKey1, - sqlite3_int64 iKey2 - ), - void* -); -SQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **); -SQLITE_API int sqlite3_preupdate_count(sqlite3 *); -SQLITE_API int sqlite3_preupdate_depth(sqlite3 *); -SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **); -SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *); -#endif -# 10057 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_system_errno(sqlite3*); -# 10079 "./sqlite3/sqlite3.h" -typedef struct sqlite3_snapshot { - unsigned char hidden[48]; -} sqlite3_snapshot; -# 10126 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get( - sqlite3 *db, - const char *zSchema, - sqlite3_snapshot **ppSnapshot -); -# 10175 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open( - sqlite3 *db, - const char *zSchema, - sqlite3_snapshot *pSnapshot -); -# 10192 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*); -# 10219 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp( - sqlite3_snapshot *p1, - sqlite3_snapshot *p2 -); -# 10247 "./sqlite3/sqlite3.h" -SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb); -# 10285 "./sqlite3/sqlite3.h" -SQLITE_API unsigned char *sqlite3_serialize( - sqlite3 *db, - const char *zSchema, - sqlite3_int64 *piSize, - unsigned int mFlags -); -# 10306 "./sqlite3/sqlite3.h" -#define SQLITE_SERIALIZE_NOCOPY 0x001 -# 10341 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3_deserialize( - sqlite3 *db, - const char *zSchema, - unsigned char *pData, - sqlite3_int64 szDb, - sqlite3_int64 szBuf, - unsigned mFlags -); -# 10371 "./sqlite3/sqlite3.h" -#define SQLITE_DESERIALIZE_FREEONCLOSE 1 -#define SQLITE_DESERIALIZE_RESIZEABLE 2 -#define SQLITE_DESERIALIZE_READONLY 4 - - - - - -#ifdef SQLITE_OMIT_FLOATING_POINT -#undef double -#endif - -#ifdef __cplusplus -} -#endif -#endif -# 10402 "./sqlite3/sqlite3.h" -#ifndef _SQLITE3RTREE_H_ -#define _SQLITE3RTREE_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; -typedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info; - - - - -#ifdef SQLITE_RTREE_INT_ONLY - typedef sqlite3_int64 sqlite3_rtree_dbl; -#else - typedef double sqlite3_rtree_dbl; -#endif - - - - - - - -SQLITE_API int sqlite3_rtree_geometry_callback( - sqlite3 *db, - const char *zGeom, - int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*), - void *pContext -); - - - - - - -struct sqlite3_rtree_geometry { - void *pContext; - int nParam; - sqlite3_rtree_dbl *aParam; - void *pUser; - void (*xDelUser)(void *); -}; - - - - - - - -SQLITE_API int sqlite3_rtree_query_callback( - sqlite3 *db, - const char *zQueryFunc, - int (*xQueryFunc)(sqlite3_rtree_query_info*), - void *pContext, - void (*xDestructor)(void*) -); -# 10472 "./sqlite3/sqlite3.h" -struct sqlite3_rtree_query_info { - void *pContext; - int nParam; - sqlite3_rtree_dbl *aParam; - void *pUser; - void (*xDelUser)(void*); - sqlite3_rtree_dbl *aCoord; - unsigned int *anQueue; - int nCoord; - int iLevel; - int mxLevel; - sqlite3_int64 iRowid; - sqlite3_rtree_dbl rParentScore; - int eParentWithin; - int eWithin; - sqlite3_rtree_dbl rScore; - - sqlite3_value **apSqlParam; -}; - - - - -#define NOT_WITHIN 0 -#define PARTLY_WITHIN 1 -#define FULLY_WITHIN 2 - - -#ifdef __cplusplus -} -#endif - -#endif - - - - -#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) -#define __SQLITESESSION_H_ 1 - - - - -#ifdef __cplusplus -extern "C" { -#endif -# 10526 "./sqlite3/sqlite3.h" -typedef struct sqlite3_session sqlite3_session; - - - - - - - -typedef struct sqlite3_changeset_iter sqlite3_changeset_iter; -# 10567 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_create( - sqlite3 *db, - const char *zDb, - sqlite3_session **ppSession -); -# 10586 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); -# 10615 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_object_config(sqlite3_session*, int op, void *pArg); - - - -#define SQLITE_SESSION_OBJCONFIG_SIZE 1 -# 10639 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable); -# 10669 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect); -# 10729 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_attach( - sqlite3_session *pSession, - const char *zTab -); -# 10744 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3session_table_filter( - sqlite3_session *pSession, - int(*xFilter)( - void *pCtx, - const char *zTab - ), - void *pCtx -); -# 10858 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_changeset( - sqlite3_session *pSession, - int *pnChangeset, - void **ppChangeset -); -# 10878 "./sqlite3/sqlite3.h" -SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession); -# 10937 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_diff( - sqlite3_session *pSession, - const char *zFromDb, - const char *zTbl, - char **pzErrMsg -); -# 10974 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_patchset( - sqlite3_session *pSession, - int *pnPatchset, - void **ppPatchset -); -# 10995 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); - - - - - - - -SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession); -# 11046 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_start( - sqlite3_changeset_iter **pp, - int nChangeset, - void *pChangeset -); -SQLITE_API int sqlite3changeset_start_v2( - sqlite3_changeset_iter **pp, - int nChangeset, - void *pChangeset, - int flags -); -# 11069 "./sqlite3/sqlite3.h" -#define SQLITE_CHANGESETSTART_INVERT 0x0002 -# 11095 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter); -# 11129 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_op( - sqlite3_changeset_iter *pIter, - const char **pzTab, - int *pnCol, - int *pOp, - int *pbIndirect -); -# 11163 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_pk( - sqlite3_changeset_iter *pIter, - unsigned char **pabPK, - int *pnCol -); -# 11194 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_old( - sqlite3_changeset_iter *pIter, - int iVal, - sqlite3_value **ppValue -); -# 11228 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_new( - sqlite3_changeset_iter *pIter, - int iVal, - sqlite3_value **ppValue -); -# 11256 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_conflict( - sqlite3_changeset_iter *pIter, - int iVal, - sqlite3_value **ppValue -); -# 11273 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_fk_conflicts( - sqlite3_changeset_iter *pIter, - int *pnOut -); -# 11309 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter); -# 11339 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_invert( - int nIn, const void *pIn, - int *pnOut, void **ppOut -); -# 11370 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_concat( - int nA, - void *pA, - int nB, - void *pB, - int *pnOut, - void **ppOut -); -# 11386 "./sqlite3/sqlite3.h" -typedef struct sqlite3_changegroup sqlite3_changegroup; -# 11424 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); -# 11502 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); -# 11529 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changegroup_output( - sqlite3_changegroup*, - int *pnData, - void **ppData -); - - - - - -SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); -# 11699 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_apply( - sqlite3 *db, - int nChangeset, - void *pChangeset, - int(*xFilter)( - void *pCtx, - const char *zTab - ), - int(*xConflict)( - void *pCtx, - int eConflict, - sqlite3_changeset_iter *p - ), - void *pCtx -); -SQLITE_API int sqlite3changeset_apply_v2( - sqlite3 *db, - int nChangeset, - void *pChangeset, - int(*xFilter)( - void *pCtx, - const char *zTab - ), - int(*xConflict)( - void *pCtx, - int eConflict, - sqlite3_changeset_iter *p - ), - void *pCtx, - void **ppRebase, int *pnRebase, - int flags -); -# 11753 "./sqlite3/sqlite3.h" -#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 -#define SQLITE_CHANGESETAPPLY_INVERT 0x0002 -# 11811 "./sqlite3/sqlite3.h" -#define SQLITE_CHANGESET_DATA 1 -#define SQLITE_CHANGESET_NOTFOUND 2 -#define SQLITE_CHANGESET_CONFLICT 3 -#define SQLITE_CHANGESET_CONSTRAINT 4 -#define SQLITE_CHANGESET_FOREIGN_KEY 5 -# 11848 "./sqlite3/sqlite3.h" -#define SQLITE_CHANGESET_OMIT 0 -#define SQLITE_CHANGESET_REPLACE 1 -#define SQLITE_CHANGESET_ABORT 2 -# 11950 "./sqlite3/sqlite3.h" -typedef struct sqlite3_rebaser sqlite3_rebaser; -# 11961 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew); -# 11972 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3rebaser_configure( - sqlite3_rebaser*, - int nRebase, const void *pRebase -); -# 11991 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3rebaser_rebase( - sqlite3_rebaser*, - int nIn, const void *pIn, - int *pnOut, void **ppOut -); -# 12005 "./sqlite3/sqlite3.h" -SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p); -# 12097 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3changeset_apply_strm( - sqlite3 *db, - int (*xInput)(void *pIn, void *pData, int *pnData), - void *pIn, - int(*xFilter)( - void *pCtx, - const char *zTab - ), - int(*xConflict)( - void *pCtx, - int eConflict, - sqlite3_changeset_iter *p - ), - void *pCtx -); -SQLITE_API int sqlite3changeset_apply_v2_strm( - sqlite3 *db, - int (*xInput)(void *pIn, void *pData, int *pnData), - void *pIn, - int(*xFilter)( - void *pCtx, - const char *zTab - ), - int(*xConflict)( - void *pCtx, - int eConflict, - sqlite3_changeset_iter *p - ), - void *pCtx, - void **ppRebase, int *pnRebase, - int flags -); -SQLITE_API int sqlite3changeset_concat_strm( - int (*xInputA)(void *pIn, void *pData, int *pnData), - void *pInA, - int (*xInputB)(void *pIn, void *pData, int *pnData), - void *pInB, - int (*xOutput)(void *pOut, const void *pData, int nData), - void *pOut -); -SQLITE_API int sqlite3changeset_invert_strm( - int (*xInput)(void *pIn, void *pData, int *pnData), - void *pIn, - int (*xOutput)(void *pOut, const void *pData, int nData), - void *pOut -); -SQLITE_API int sqlite3changeset_start_strm( - sqlite3_changeset_iter **pp, - int (*xInput)(void *pIn, void *pData, int *pnData), - void *pIn -); -SQLITE_API int sqlite3changeset_start_v2_strm( - sqlite3_changeset_iter **pp, - int (*xInput)(void *pIn, void *pData, int *pnData), - void *pIn, - int flags -); -SQLITE_API int sqlite3session_changeset_strm( - sqlite3_session *pSession, - int (*xOutput)(void *pOut, const void *pData, int nData), - void *pOut -); -SQLITE_API int sqlite3session_patchset_strm( - sqlite3_session *pSession, - int (*xOutput)(void *pOut, const void *pData, int nData), - void *pOut -); -SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, - int (*xInput)(void *pIn, void *pData, int *pnData), - void *pIn -); -SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*, - int (*xOutput)(void *pOut, const void *pData, int nData), - void *pOut -); -SQLITE_API int sqlite3rebaser_rebase_strm( - sqlite3_rebaser *pRebaser, - int (*xInput)(void *pIn, void *pData, int *pnData), - void *pIn, - int (*xOutput)(void *pOut, const void *pData, int nData), - void *pOut -); -# 12213 "./sqlite3/sqlite3.h" -SQLITE_API int sqlite3session_config(int op, void *pArg); - - - - -#define SQLITE_SESSION_CONFIG_STRMSIZE 1 - - - - -#ifdef __cplusplus -} -#endif - -#endif -# 12251 "./sqlite3/sqlite3.h" -#ifndef _FTS5_H -#define _FTS5_H - - -#ifdef __cplusplus -extern "C" { -#endif -# 12266 "./sqlite3/sqlite3.h" -typedef struct Fts5ExtensionApi Fts5ExtensionApi; -typedef struct Fts5Context Fts5Context; -typedef struct Fts5PhraseIter Fts5PhraseIter; - -typedef void (*fts5_extension_function)( - const Fts5ExtensionApi *pApi, - Fts5Context *pFts, - sqlite3_context *pCtx, - int nVal, - sqlite3_value **apVal -); - -struct Fts5PhraseIter { - const unsigned char *a; - const unsigned char *b; -}; -# 12494 "./sqlite3/sqlite3.h" -struct Fts5ExtensionApi { - int iVersion; - - void *(*xUserData)(Fts5Context*); - - int (*xColumnCount)(Fts5Context*); - int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow); - int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken); - - int (*xTokenize)(Fts5Context*, - const char *pText, int nText, - void *pCtx, - int (*xToken)(void*, int, const char*, int, int, int) - ); - - int (*xPhraseCount)(Fts5Context*); - int (*xPhraseSize)(Fts5Context*, int iPhrase); - - int (*xInstCount)(Fts5Context*, int *pnInst); - int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff); - - sqlite3_int64 (*xRowid)(Fts5Context*); - int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn); - int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken); - - int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData, - int(*)(const Fts5ExtensionApi*,Fts5Context*,void*) - ); - int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*)); - void *(*xGetAuxdata)(Fts5Context*, int bClear); - - int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*); - void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff); - - int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); - void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); -}; -# 12728 "./sqlite3/sqlite3.h" -typedef struct Fts5Tokenizer Fts5Tokenizer; -typedef struct fts5_tokenizer fts5_tokenizer; -struct fts5_tokenizer { - int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); - void (*xDelete)(Fts5Tokenizer*); - int (*xTokenize)(Fts5Tokenizer*, - void *pCtx, - int flags, - const char *pText, int nText, - int (*xToken)( - void *pCtx, - int tflags, - const char *pToken, - int nToken, - int iStart, - int iEnd - ) - ); -}; - - -#define FTS5_TOKENIZE_QUERY 0x0001 -#define FTS5_TOKENIZE_PREFIX 0x0002 -#define FTS5_TOKENIZE_DOCUMENT 0x0004 -#define FTS5_TOKENIZE_AUX 0x0008 - - - -#define FTS5_TOKEN_COLOCATED 0x0001 -# 12765 "./sqlite3/sqlite3.h" -typedef struct fts5_api fts5_api; -struct fts5_api { - int iVersion; - - - int (*xCreateTokenizer)( - fts5_api *pApi, - const char *zName, - void *pContext, - fts5_tokenizer *pTokenizer, - void (*xDestroy)(void*) - ); - - - int (*xFindTokenizer)( - fts5_api *pApi, - const char *zName, - void **ppContext, - fts5_tokenizer *pTokenizer - ); - - - int (*xCreateFunction)( - fts5_api *pApi, - const char *zName, - void *pContext, - fts5_extension_function xFunction, - void (*xDestroy)(void*) - ); -}; - - - - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lang/zh_CN.ts b/lang/zh_CN.ts index 9d1361fc..a6478086 100644 --- a/lang/zh_CN.ts +++ b/lang/zh_CN.ts @@ -47,6 +47,10 @@ Console start 单机启动 + + PackageManage + 管理拓展包 + @@ -68,4 +72,56 @@ 用户名或密码错误 + + + PackageManage + + Quit + 退出 + + + Install From URL + 从URL安装 + + + Enable + 启用 + + + Disable + 禁用 + + + Enabled + 已启用 + + + Disabled + 已禁用 + + + Remove + 删除 + + + Upgrade + 更新 + + + Name + 名称 + + + Version + 版本 + + + Copy URL + 复制URL + + + Copied. + 已复制。 + + diff --git a/lib/android/libcrypto.so b/lib/android/libcrypto.so new file mode 100755 index 00000000..597890c1 Binary files /dev/null and b/lib/android/libcrypto.so differ diff --git a/lib/android/libcrypto_1_1.so b/lib/android/libcrypto_1_1.so deleted file mode 100644 index 09d584fa..00000000 Binary files a/lib/android/libcrypto_1_1.so and /dev/null differ diff --git a/lib/android/libgit2.so b/lib/android/libgit2.so new file mode 100644 index 00000000..1f2e4f40 Binary files /dev/null and b/lib/android/libgit2.so differ diff --git a/lib/android/libssl.so b/lib/android/libssl.so new file mode 100755 index 00000000..33fcaf4c Binary files /dev/null and b/lib/android/libssl.so differ diff --git a/lib/win/libgit2.dll b/lib/win/libgit2.dll new file mode 100755 index 00000000..7ee2fdf1 Binary files /dev/null and b/lib/win/libgit2.dll differ diff --git a/lua/client/client.lua b/lua/client/client.lua index 28d2ca15..f850ab04 100644 --- a/lua/client/client.lua +++ b/lua/client/client.lua @@ -2,6 +2,7 @@ ---@field client fk.Client ---@field players ClientPlayer[] ---@field alive_players ClientPlayer[] +---@field observers ClientPlayer[] ---@field current ClientPlayer ---@field discard_pile integer[] ---@field status_skills Skill[] @@ -28,6 +29,7 @@ function Client:initialize() self.players = {} -- ClientPlayer[] self.alive_players = {} + self.observers = {} self.discard_pile = {} self.status_skills = {} for class, skills in pairs(Fk.global_status_skill) do @@ -80,6 +82,8 @@ function Client:moveCards(moves) elseif move.toArea == Card.DiscardPile then table.insert(self.discard_pile, move.ids[1]) end + + Fk:filterCard(move.ids[1], move.to == Self.id and Self or nil) end end @@ -122,7 +126,7 @@ function Client:appendLog(msg) else local card_str = {} for _, id in ipairs(card) do - table.insert(card_str, Fk:getCardById(id):toLogString()) + table.insert(card_str, Fk:getCardById(id, true):toLogString()) end if unknownCount > 0 then table.insert(card_str, Fk:translate("unknown_card") @@ -200,6 +204,31 @@ fk.client_callback["RemovePlayer"] = function(jsonData) end end +fk.client_callback["AddObserver"] = function(jsonData) + -- jsonData: [ int id, string screenName, string avatar ] + -- when observer enter the room, we create lua clientplayer for them + local data = json.decode(jsonData) + local id, name, avatar = data[1], data[2], data[3] + local player = { + getId = function() return id end, + getScreenName = function() return name end, + getAvatar = function() return avatar end, + } + local p = ClientPlayer:new(player) + table.insert(ClientInstance.observers, p) +end + +fk.client_callback["RemoveObserver"] = function(jsonData) + local data = json.decode(jsonData) + local id = data[1] + for _, p in ipairs(ClientInstance.observers) do + if p.player:getId() == id then + table.removeOne(ClientInstance.observers, p) + break + end + end +end + fk.client_callback["ArrangeSeats"] = function(jsonData) local data = json.decode(jsonData) local n = #ClientInstance.players @@ -365,15 +394,28 @@ fk.client_callback["SetPlayerMark"] = function(jsonData) local player, mark, value = data[1], data[2], data[3] ClientInstance:getPlayerById(player):setMark(mark, value) - -- TODO: if mark is visible, update the UI. + if string.sub(mark, 1, 1) == "@" then + ClientInstance:notifyUI("SetPlayerMark", jsonData) + end end fk.client_callback["Chat"] = function(jsonData) -- jsonData: { int type, string msg } local data = json.decode(jsonData) local p = ClientInstance:getPlayerById(data.type) + -- TODO: observer chatting + if not p then + for _, pl in ipairs(ClientInstance.observers) do + if pl.id == data.type then + p = pl; break + end + end + if not p then return end + data.general = "" + else + data.general = p.general + end data.userName = p.player:getScreenName() - data.general = p.general data.time = os.date("%H:%M:%S") ClientInstance:notifyUI("Chat", json.encode(data)) end diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua index 5d35eeec..ffbcf4ed 100644 --- a/lua/client/client_util.lua +++ b/lua/client/client_util.lua @@ -8,12 +8,40 @@ function GetGeneralData(name) local general = Fk.generals[name] if general == nil then general = Fk.generals["diaochan"] end return json.encode { + package = general.package.name, + extension = general.package.extensionName, kingdom = general.kingdom, hp = general.hp, maxHp = general.maxHp } end +function GetGeneralDetail(name) + local general = Fk.generals[name] + if general == nil then general = Fk.generals["diaochan"] end + local ret = { + package = general.package.name, + extension = general.package.extensionName, + kingdom = general.kingdom, + hp = general.hp, + maxHp = general.maxHp, + skill = {} + } + for _, s in ipairs(general.skills) do + table.insert(ret.skill, { + name = s.name, + description = Fk:getDescription(s.name) + }) + end + for _, s in ipairs(general.other_skills) do + table.insert(ret.skill, { + name = s, + description = Fk:getDescription(s) + }) + end + return json.encode(ret) +end + local cardSubtypeStrings = { [Card.SubtypeNone] = "none", [Card.SubtypeDelayedTrick] = "delayed_trick", @@ -25,7 +53,7 @@ local cardSubtypeStrings = { } function GetCardData(id) - local card = Fk.cards[id] + local card = Fk:getCardById(id) if card == nil then return json.encode{ cid = id, known = false @@ -33,11 +61,17 @@ function GetCardData(id) local ret = { cid = id, name = card.name, + extension = card.package.extensionName, number = card.number, suit = card:getSuitString(), color = card.color, subtype = cardSubtypeStrings[card.sub_type] } + if card.skillName ~= "" then + local orig = Fk:getCardById(id, true) + ret.name = orig.name + ret.virt_name = card.name + end return json.encode(ret) end @@ -187,6 +221,7 @@ function GetSkillData(skill_name) return json.encode{ skill = Fk:translate(skill_name), orig_skill = skill_name, + extension = skill.package.extensionName, freq = freq } end @@ -332,6 +367,7 @@ Fk:loadTranslationTable{ -- Lobby ["Room List"] = "房间列表", ["Enter"] = "进入", + ["Observe"] = "旁观", ["Edit Profile"] = "编辑个人信息", ["Username"] = "用户名", @@ -340,11 +376,15 @@ Fk:loadTranslationTable{ ["New Password"] = "新密码", ["Update Avatar"] = "更新头像", ["Update Password"] = "更新密码", + ["Lobby BG"] = "大厅壁纸", + ["Room BG"] = "房间背景", + ["Game BGM"] = "游戏BGM", ["Create Room"] = "创建房间", ["Room Name"] = "房间名字", ["$RoomName"] = "%1的房间", ["Player num"] = "玩家数目", + ["Enable free assign"] = "自由选将", ["Generals Overview"] = "武将一览", ["Cards Overview"] = "卡牌一览", @@ -374,6 +414,10 @@ Fk:loadTranslationTable{ "SQLite是一个轻量级的数据库,具有占用资源低、运行效率快、嵌入性好等优点。
" .. "
FreeKill使用sqlite3在服务端保存用户的各种信息。
" .. "
官网: https://www.sqlite.org", + ["about_git2_description"] = "关于Libgit2
" .. + "Libgit2是一个轻量级的、跨平台的、纯C实现的库,支持Git的大部分核心操作,并且支持几乎任何能与C语言交互的编程语言。
" .. + "
FreeKill使用的是libgit2的C API,与此同时使用Git完成拓展包的下载、更新、管理等等功能。
" .. + "
官网: https://libgit2.org", ["Exit Lobby"] = "退出大厅", @@ -421,6 +465,8 @@ Fk:loadTranslationTable{ ["Sort Cards"] = "牌序", ["Chat"] = "聊天", ["Log"] = "战报", + ["Trusting ..."] = "托管中 ...", + ["Observing ..."] = "旁观中 ...", ["$GameOver"] = "游戏结束", ["$Winner"] = "%1 获胜", @@ -457,17 +503,6 @@ Fk:loadTranslationTable{ ["#LoseSkill"] = "%from 失去了技能“%arg”", -- moveCards (they are sent by notifyMoveCards) - ["unknown_card"] = '未知牌', - ["log_spade"] = "♠", - ["log_heart"] = '', - ["log_club"] = "♣", - ["log_diamond"] = '', - ["log_nosuit"] = "无花色", - ["nosuit"] = "无花色", - ["spade"] = "黑桃", - ["heart"] = "红桃", - ["club"] = "梅花", - ["diamond"] = "方块", ["$DrawCards"] = "%from 摸了 %arg 张牌 %card", ["$DiscardCards"] = "%from 弃置了 %arg 张牌 %card", @@ -491,6 +526,8 @@ Fk:loadTranslationTable{ ["#UseV0CardToCard"] = "%from 使用了 %arg2,目标是 %arg", ["#ResponsePlayV0Card"] = "%from 打出了 %arg", + ["#FilterCard"] = "由于 %arg 的效果,与 %from 相关的 %arg2 被视为了 %arg3", + -- skill ["#InvokeSkill"] = "%from 发动了 “%arg”", diff --git a/lua/core/card.lua b/lua/core/card.lua index b4e1a958..65ba0204 100644 --- a/lua/core/card.lua +++ b/lua/core/card.lua @@ -10,6 +10,7 @@ ---@field sub_type CardSubtype ---@field area CardArea ---@field subcards integer[] +---@field skillName string @ for virtual cards local Card = class("Card") ---@alias Suit integer @@ -76,6 +77,7 @@ function Card:initialize(name, suit, number, color) self.sub_type = Card.SubTypeNone self.skill = nil self.subcards = {} + self.skillName = "" end ---@param suit Suit @@ -174,6 +176,18 @@ function Card:getColorString() return "nocolor" end +function Card:getTypeString() + local t = self.type + if t == Card.TypeBasic then + return "basic" + elseif t == Card.TypeTrick then + return "trick" + elseif t == Card.TypeEquip then + return "equip" + end + return "nocolor" +end + local function getNumberStr(num) if num == 1 then return "A" diff --git a/lua/core/engine.lua b/lua/core/engine.lua index 127a09fa..4b77c946 100644 --- a/lua/core/engine.lua +++ b/lua/core/engine.lua @@ -63,7 +63,8 @@ function Engine:loadPackages() table.removeOne(directories, "standard_cards") for _, dir in ipairs(directories) do - if FileIO.isDir("packages/" .. dir) then + if (not string.find(dir, ".disabled")) and FileIO.isDir("packages/" .. dir) + and FileIO.exists("packages/" .. dir .. "/init.lua") then local pack = require(string.format("packages.%s", dir)) -- Note that instance of Package is a table too -- so dont use type(pack) == "table" here @@ -148,7 +149,9 @@ function Engine:addCard(card) card.id = cardId cardId = cardId + 1 table.insert(self.cards, card) - _card_name_table[card.name] = card + if _card_name_table[card.name] == nil then + _card_name_table[card.name] = card + end end ---@param cards Card[] @@ -165,7 +168,9 @@ end function Engine:cloneCard(name, suit, number) local cd = _card_name_table[name] assert(cd, "Attempt to clone a card that not added to engine") - return cd:clone(suit, number) + local ret = cd:clone(suit, number) + ret.package = cd.package + return ret end ---@param num integer @@ -232,10 +237,81 @@ function Engine:getAllCardIds(except) return result end +local filtered_cards = {} + ---@param id integer +---@param ignoreFilter boolean ---@return Card -function Engine:getCardById(id) - return self.cards[id] +function Engine:getCardById(id, ignoreFilter) + local ret = self.cards[id] + if not ignoreFilter then + ret = filtered_cards[id] or self.cards[id] + end + return ret +end + +---@param id integer +---@param player Player +---@param data any @ may be JudgeStruct +function Engine:filterCard(id, player, data) + local card = self:getCardById(id, true) + if player == nil then + filtered_cards[id] = nil + return + end + local skills = player:getAllSkills() + local filters = {} + for _, s in ipairs(skills) do + if s:isInstanceOf(FilterSkill) then + table.insert(filters, s) + end + end + if #filters == 0 then + filtered_cards[id] = nil + return + end + + local modify = false + if data and type(data) == "table" and data.card + and type(data.card) == "table" and data.card:isInstanceOf(Card) then + modify = true + end + + for _, f in ipairs(filters) do + if f:cardFilter(card) then + local _card = f:viewAs(card) + _card.id = id + _card.skillName = f.name + if modify and RoomInstance then + if not f.mute then + RoomInstance:broadcastSkillInvoke(f.name) + end + RoomInstance:doAnimate("InvokeSkill", { + name = f.name, + player = player.id, + skill_type = f.anim_type, + }) + RoomInstance:sendLog{ + type = "#FilterCard", + arg = f.name, + from = player.id, + arg2 = card:toLogString(), + arg3 = _card:toLogString(), + } + end + card = _card + end + if card == nil then + card = self:getCardById(id) + end + filtered_cards[id] = card + end + + if modify then + filtered_cards[id] = nil + data.card = card + return + end end function Engine:currentRoom() @@ -245,4 +321,8 @@ function Engine:currentRoom() return RoomInstance end +function Engine:getDescription(name) + return self:translate(":" .. name) +end + return Engine diff --git a/lua/core/general.lua b/lua/core/general.lua index 3d5db293..364a70b7 100644 --- a/lua/core/general.lua +++ b/lua/core/general.lua @@ -34,6 +34,7 @@ function General:addSkill(skill) table.insert(self.other_skills, skill) elseif (skill.class and skill.class:isSubclassOf(Skill)) then table.insert(self.skills, skill) + skill.package = self.package end end diff --git a/lua/core/package.lua b/lua/core/package.lua index b9a54dd8..edb8c066 100644 --- a/lua/core/package.lua +++ b/lua/core/package.lua @@ -1,5 +1,6 @@ ---@class Package : Object ---@field name string +---@field extensionName string ---@field type PackageType ---@field generals General[] ---@field extra_skills Skill[] @@ -17,6 +18,7 @@ function Package:initialize(name, _type) assert(type(name) == "string") assert(type(_type) == "nil" or type(_type) == "number") self.name = name + self.extensionName = name -- used for get assets self.type = _type or Package.GeneralPack self.generals = {} diff --git a/lua/core/player.lua b/lua/core/player.lua index 14d48b30..3a10f6ae 100644 --- a/lua/core/player.lua +++ b/lua/core/player.lua @@ -127,6 +127,10 @@ function Player:clearFlags() self.flag = {} end +-- mark name and UI: +-- 'xxx': invisible mark +-- '@mark': mark with extra data (maybe string or number) +-- '@@mark': mark without data function Player:addMark(mark, count) count = count or 1 local num = self.mark[mark] @@ -255,6 +259,11 @@ function Player:getCardIds(playerAreas, specialName) return cardIds end +-- for fkp only +function Player:getHandcardNum() + return #self:getCardIds(Player.Hand) +end + ---@param cardSubtype CardSubtype ---@return integer|null function Player:getEquipment(cardSubtype) @@ -560,4 +569,15 @@ function Player:loseSkill(skill, source_skill) return ret end +-- return all skills that xxx:hasSkill() == true +function Player:getAllSkills() + local ret = {table.unpack(self.player_skills)} + for _, t in pairs(self.derivative_skills) do + for _, s in ipairs(t) do + table.insertIfNeed(ret, s) + end + end + return ret +end + return Player diff --git a/lua/core/skill.lua b/lua/core/skill.lua index 861cd970..3e8120d4 100644 --- a/lua/core/skill.lua +++ b/lua/core/skill.lua @@ -1,5 +1,6 @@ ---@class Skill : Object ---@field name string +---@field package Package ---@field frequency Frequency ---@field visible boolean ---@field mute boolean @@ -18,6 +19,10 @@ Skill.Wake = 5 function Skill:initialize(name, frequency) -- TODO: visible, lord, etc self.name = name + -- skill's package is assigned when calling General:addSkill + -- if you need skills that not belongs to any general (like 'jixi') + -- then you should assign skill.package explicitly + self.package = { extensionName = "standard" } self.frequency = frequency self.visible = true self.mute = false diff --git a/lua/core/skill_type/active.lua b/lua/core/skill_type/active.lua index 8236ccc9..2f9e3824 100644 --- a/lua/core/skill_type/active.lua +++ b/lua/core/skill_type/active.lua @@ -48,6 +48,10 @@ end ---@param cardUseEvent CardUseStruct function ActiveSkill:onUse(room, cardUseEvent) end +---@param room Room +---@param cardEffectEvent CardEffectEvent | SkillEffectEvent +function ActiveSkill:aboutToEffect(room, cardEffectEvent) end + ---@param room Room ---@param cardEffectEvent CardEffectEvent | SkillEffectEvent function ActiveSkill:onEffect(room, cardEffectEvent) end diff --git a/lua/core/skill_type/filter.lua b/lua/core/skill_type/filter.lua new file mode 100644 index 00000000..8e39b3fc --- /dev/null +++ b/lua/core/skill_type/filter.lua @@ -0,0 +1,15 @@ +---@class FilterSkill: StatusSkill +local FilterSkill = StatusSkill:subclass("FilterSkill") + +---@param card Card +function FilterSkill:cardFilter(card) + return false +end + +---@param card Card +---@return Card +function FilterSkill:viewAs(card) + return nil +end + +return FilterSkill diff --git a/lua/fk_ex.lua b/lua/fk_ex.lua index de1c85fc..3cf12c00 100644 --- a/lua/fk_ex.lua +++ b/lua/fk_ex.lua @@ -10,6 +10,7 @@ ProhibitSkill = require "core.skill_type.prohibit" AttackRangeSkill = require "core.skill_type.attack_range" MaxCardsSkill = require "core.skill_type.max_cards" TargetModSkill = require "core.skill_type.target_mod" +FilterSkill = require "core.skill_type.filter" BasicCard = require "core.card_type.basic" local Trick = require "core.card_type.trick" @@ -116,6 +117,7 @@ end ---@field target_filter fun(self: ActiveSkill, to_select: integer, selected: integer[], selected_cards: integer[]): boolean ---@field feasible fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): boolean ---@field on_use fun(self: ActiveSkill, room: Room, cardUseEvent: CardUseStruct): boolean +---@field about_to_effect fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): boolean ---@field on_effect fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): boolean ---@field on_nullified fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): boolean @@ -140,6 +142,7 @@ function fk.CreateActiveSkill(spec) if spec.target_filter then skill.targetFilter = spec.target_filter end if spec.feasible then skill.feasible = spec.feasible end if spec.on_use then skill.onUse = spec.on_use end + if spec.about_to_effect then skill.aboutToEffect = spec.about_to_effect end if spec.on_effect then skill.onEffect = spec.on_effect end if spec.on_nullified then skill.onNullified = spec.on_nullified end return skill @@ -292,6 +295,27 @@ function fk.CreateTargetModSkill(spec) return skill end +---@class FilterSpec: StatusSkillSpec +---@field card_filter fun(self: FilterSkill, card: Card) +---@field view_as fun(self: FilterSkill, card: Card) + +---@param spec FilterSpec +---@return FilterSkill +function fk.CreateFilterSkill(spec) + assert(type(spec.name) == "string") + + local skill = FilterSkill:new(spec.name) + skill.mute = spec.mute + skill.anim_type = spec.anim_type + skill.cardFilter = spec.card_filter + skill.viewAs = spec.view_as + if spec.global then + skill.global = spec.global + end + + return skill +end + ---@class CardSpec: Card ---@field skill Skill diff --git a/lua/freekill.lua b/lua/freekill.lua index f470d281..6d1be6b5 100644 --- a/lua/freekill.lua +++ b/lua/freekill.lua @@ -4,6 +4,13 @@ package.path = package.path .. ";./lua/lib/?.lua" .. ";./lua/?.lua" +-- disable dangerous functions +os.remove = nil +os.execute = nil +os.exit = nil +os.rename = nil +io = nil + -- load libraries class = require "middleclass" diff --git a/lua/lib/fkparser.lua b/lua/lib/fkparser.lua index 047d3f3d..6edb49fa 100644 --- a/lua/lib/fkparser.lua +++ b/lua/lib/fkparser.lua @@ -5,64 +5,299 @@ -- In most cases, fk's basic modules are loaded before extension calls -- "require 'fkparser'", so we needn't to import lua modules here. -fkp = { - functions = {}, - newlist = function(t) - t.length = function(self) - return #self - end, - - t.prepend = function(self, element) - if #self > 0 and type(self[1]) ~= type(element) then return end - for i = #self, 1, -1 do - self[i + 1] = self[i] - end - self[1] = element - end, - - t.append = function(self, element) - if #self > 0 and type(self[1]) ~= type(element) then return end - table.insert(self, element) - end, - - t.removeOne = function(self, element) - if #self == 0 or type(self[1]) ~= type(element) then return false end - - for i = 1, #self do - if self[i] == element then - table.remove(self, i) - return true - end - end - return false - end, - - t.at = function(self, index) - return self[index + 1] - end, - - t.replace = function(self, index, value) - self[index + 1] = value - end, - return t - end, +local string2suit = { + spade = Card.Spade, + club = Card.Club, + heart = Card.Heart, + diamond = Card.Diamond, + no_suit = Card.NoSuit, + no_suit_black = Card.NoSuitBlack, + no_suit_red = Card.NoSuitRed, } -fkp.functions.prepend = function(arr, e) - if arr:length() == 0 then - arr = fkp.newlist{e} - else - arr:prepend(e) - end - return arr -end, +local fkp = { functions = {} } -fkp.functions.append = function(arr, e) - if arr:length() == 0 then - arr = fkp.newlist{e} - else - arr:append(e) - end - return arr -end, +fkp.functions.prepend = function(arr, e) table.insert(arr, 1, e) end +fkp.functions.append = function(arr, e) table.insert(arr, e) end +fkp.functions.drawCards = function(p, n) p:drawCards(n) end +fkp.functions.loseHp = function(p, n) p.room:loseHp(p, n) end +fkp.functions.loseMaxHp = function(p, n) p.room:changeMaxHp(p, -n) end +fkp.functions.damage = function(from, to, n, nature, card, reason) + local damage = {} + damage.from = from + damage.to = to + damage.damage = n + damage.damageType = nature + damage.card = card + damage.skillName = reason + to.room:damage(damage) +end +fkp.functions.recover = function(player, int, who, card) + local recover = {} + recover.who = player + recover.num = int + recover.recoverBy = who + recover.card = card + player.room:recover(recover) +end + +fkp.functions.recoverMaxHp = function(p, n) p.room:changeMaxHp(p, n) end +fkp.functions.acquireSkill = function(player, skill) + player.room:handleAddLoseSkills(player, skill) +end + +fkp.functions.loseSkill = function(player, skill) + player.room:handleAddLoseSkills(player, "-" .. skill) +end + +fkp.functions.addMark = function(player, mark, count, hidden) + local room = player.room + if hidden then + mark = string.gsub(mark, "@", "_") + end + + room:addPlayerMark(player, mark, count) +end + +fkp.functions.loseMark = function(player, mark, count, hidden) + local room = player.room + if hidden then + mark = string.gsub(mark, "@", "_") + end + + room:removePlayerMark(player, mark, count) +end + +fkp.functions.getMark = function(player, mark, hidden) + if hidden then + mark = string.gsub(mark, "@", "_") + end + + return player:getMark(mark) +end + +fkp.functions.judge = function(player, reason, pattern, good, play_animation) + local judge = {} + judge.who = player + judge.reason = reason + judge.pattern = pattern + -- judge.good = good + -- judge.play_animation = play_animation + player.room:judge(judge) + return judge.card +end + +fkp.functions.retrial = function(card, player, judge, skill_name, exchange) + local room = player.room + return room:retrial(card, player, judge, skill_name, exchange) +end + +fkp.functions.hasSkill = function(p, s) return p:hasSkill(s) end +fkp.functions.turnOver = function(p) p:turnOver() end +fkp.functions.distanceTo = function(p1, p2) return p1:distanceTo(p2) end + +-- skill prototypes +-------------------------------------------- + +fkp.CreateTriggerSkill = function(spec) + local eve = {} + local refresh_eve = {} + local specs = spec.specs + local re_specs = spec.refresh_specs + for event, _ in pairs(specs) do + table.insert(eve, event) + end + for event, _ in pairs(re_specs) do + table.insert(refresh_eve, event) + end + return fk.CreateTriggerSkill{ + name = spec.name, + frequency = spec.frequency or Skill.NotFrequent, + events = eve, + can_trigger = function(self, event, target, player, data) + local func = specs[event] and specs[event][1] or nil + if not func then + return TriggerSkill.triggerable(self, event, target, player, data) + end + return func(self, target, player, data) + end, + on_trigger = function(self, event, target, player, data) + local func = specs[event] and specs[event][4] or nil + if not func then + return TriggerSkill.trigger(self, event, target, player, data) + end + return func(self, target, player, data) + end, + on_cost = function(self, event, target, player, data) + local func = specs[event] and specs[event][3] or nil + if not func then + return TriggerSkill.cost(self, event, target, player, data) + end + return func(self, target, player, data) + end, + on_use = function(self, event, target, player, data) + local func = specs[event] and specs[event][2] or nil + if not func then + return TriggerSkill.use(self, event, target, player, data) + end + return func(self, target, player, data) + end, + + refresh_events = refresh_eve, + can_refresh = function(self, event, target, player, data) + local func = re_specs[event] and re_specs[event][1] or nil + if not func then + return TriggerSkill.canRefresh(self, event, target, player, data) + end + return func(self, target, player, data) + end, + on_refresh = function(self, event, target, player, data) + local func = re_specs[event] and re_specs[event][2] or nil + if not func then + return TriggerSkill.refresh(self, event, target, player, data) + end + return func(self, target, player, data) + end, + } +end + +fkp.CreateActiveSkill = function(spec) + return fk.CreateActiveSkill{ + name = spec.name, + can_use = spec.can_use, + card_filter = function(self, to_select, selected) + local card = Fk:getCardById(to_select) + local clist = {} + for _, id in ipairs(selected) do + table.insert(clist, Fk:getCardById(id)) + end + return spec.card_filter(self, clist, card) + end, + target_filter = function(self, to_select, selected, cards) + local room = Fk:currentRoom() + local target = room:getPlayerById(to_select) + local plist = {} + for _, id in ipairs(selected) do + table.insert(plist, room:getPlayerById(id)) + end + local clist = {} + for _, id in ipairs(cards) do + table.insert(clist, Fk:getCardById(id)) + end + return spec.target_filter(self, plist, target, clist) + end, + feasible = function(self, targets, cards) + local room = Fk:currentRoom() + local plist = {} + for _, id in ipairs(targets) do + table.insert(plist, room:getPlayerById(id)) + end + local clist = {} + for _, id in ipairs(cards) do + table.insert(clist, Fk:getCardById(id)) + end + return spec.feasible(self, plist, clist) + end, + on_use = function(self, room, use) + local cards = use.cards + local from = use.from + local targets = use.tos + local source = room:getPlayerById(from) + local plist = {} + for _, id in ipairs(targets) do + table.insert(plist, room:getPlayerById(id)) + end + local clist = {} + for _, id in ipairs(cards) do + table.insert(clist, Fk:getCardById(id)) + end + return spec.on_use(self, source, plist, clist) + end, + on_effect = function(self, room, effect) + -- TODO: active skill for card! + end, + } +end + +fkp.functions.newVirtualCard = function(number, suit, name, subcards, skill) + subcards = subcards or {} + local ret = Fk:cloneCard(name, string2suit[suit], number) + if not ret then + ret = Fk:cloneCard("slash", string2suit[suit], number) + end + ret.skillName = skill + ret:addSubcards(subcards) + return ret +end + +fkp.functions.buildPattern = function(names, suits, numbers) + if not names then names = {"."} end + if not suits then suits = {"."} end + if not numbers then numbers = {"."} end + + names = table.concat(names, ",") + suits = table.concat(suits, ",") + numbers = table.concat(numbers, ",") + return string.format("%s|%s|%s", names, numbers, suits) +end + +fkp.CreateViewAsSkill = function(spec) + return fk.CreateViewAsSkill{ + name = spec.name, + card_filter = function(self, to_select, selected) + local card = Fk:getCardById(to_select) + local clist = {} + for _, id in ipairs(selected) do + table.insert(clist, Fk:getCardById(id)) + end + return spec.card_filter(self, clist, card) + end, + view_as = function(self, cards) + local clist = {} + for _, c in ipairs(cards) do + table.insert(clist, Fk:getCardById(c)) + end + if spec.feasible(self, clist) then + return spec.view_as(self, clist) + end + return nil + end, + enabled_at_play = spec.can_use, + enabled_at_response = spec.can_response, + pattern = table.concat(spec.response_patterns, ";"), + } +end + +fkp.CreateTargetModSkill = function(_spec) + local spec = { name = _spec.name } + local function getVCardFromActiveSkill(skill) + if not string.find(skill.name, "_skill") then return 0 end + local str = string.gsub(skill.name, "_skill", "") + return Fk:cloneCard(str) + end + if _spec.residue_func then + spec.residue_func = function(self, target, skill, scope) + return _spec.residue_func(self, target, getVCardFromActiveSkill(skill)) + end + end + if _spec.distance_limit_func then + spec.distance_limit_func = function(self, target, skill) + return _spec.distance_limit_func(self, target, getVCardFromActiveSkill(skill)) + end + end + if _spec.extra_target_func then + spec.extra_target_func = function(self, target, skill) + return _spec.extra_target_func(self, target, getVCardFromActiveSkill(skill)) + end + end + return fk.CreateTargetModSkill(spec) +end + +fkp.CreateFilterSkill = fk.CreateFilterSkill +fkp.CreateProhibitSkill = fk.CreateProhibitSkill +fkp.CreateDistanceSkill = fk.CreateDistanceSkill +fkp.CreateMaxCardsSkill = fk.CreateMaxCardsSkill +fkp.CreateAttackRangeSkill = fk.CreateAttackRangeSkill + +return fkp diff --git a/lua/server/gamelogic.lua b/lua/server/gamelogic.lua index c7551efd..9aaa106b 100644 --- a/lua/server/gamelogic.lua +++ b/lua/server/gamelogic.lua @@ -142,6 +142,9 @@ function GameLogic:prepareForStart() for _, s in ipairs(skills) do room:handleAddLoseSkills(p, s.name, nil, false) end + for _, sname in ipairs(Fk.generals[p.general].other_skills) do + room:handleAddLoseSkills(p, sname, nil, false) + end end self:addTriggerSkill(GameRule) @@ -219,15 +222,11 @@ function GameLogic:trigger(event, target, data) local broken = false local skills = self.skill_table[event] or {} local skills_to_refresh = self.refresh_skill_table[event] or {} - local player = target + local _target = target or room.current -- for iteration + local player = _target self.event_stack:push({event, target, data}) - if target == nil then - target = room.current - player = target - end - repeat do -- refresh skills. This should not be broken for _, skill in ipairs(skills_to_refresh) do @@ -236,7 +235,7 @@ function GameLogic:trigger(event, target, data) end end player = player.next - end until player == target + end until player == _target ---@param a TriggerSkill ---@param b TriggerSkill @@ -281,7 +280,7 @@ function GameLogic:trigger(event, target, data) if broken then break end player = player.next - end until player == target + end until player == _target self.event_stack:pop() return broken diff --git a/lua/server/room.lua b/lua/server/room.lua index a84be31c..b5e81dcf 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -2,6 +2,7 @@ ---@field room fk.Room ---@field players ServerPlayer[] ---@field alive_players ServerPlayer[] +---@field observers fk.ServerPlayer[] ---@field current ServerPlayer ---@field game_finished boolean ---@field timeout integer @@ -77,6 +78,7 @@ function Room:initialize(_room) self.players = {} self.alive_players = {} + self.observers = {} self.current = nil self.game_finished = false self.timeout = _room:getTimeout() @@ -127,6 +129,16 @@ function Room:getCardArea(cardId) return self.card_place[cardId] or Card.Unknown end +---@param cardId integer | card +---@return ServerPlayer +function Room:getCardOwner(cardId) + if type(cardId) ~= "number" then + assert(cardId and cardId:isInstanceOf(Card)) + cardId = cardId:getEffectiveId() + end + return self.owner_map[cardId] and self:getPlayerById(self.owner_map[cardId]) or nil +end + ---@param id integer ---@return ServerPlayer function Room:getPlayerById(id) @@ -139,7 +151,7 @@ function Room:getPlayerById(id) end end - error("cannot find player by " .. id) + return nil end ---@param playerIds integer[] @@ -309,11 +321,9 @@ end ---@param players ServerPlayer[] | nil @ default all players function Room:doBroadcastNotify(command, jsonData, players) players = players or self.players - local tolist = fk.SPlayerList() for _, p in ipairs(players) do - tolist:append(p.serverplayer) + p:doNotify(command, jsonData) end - self.room:doBroadcastNotify(tolist, command, jsonData) end ---@param player ServerPlayer @@ -391,6 +401,71 @@ end -- main loop for the request handling coroutine function Room:requestLoop() + local function tellRoomToObserver(player) + local observee = self.players[1] + player:doNotify("Setup", json.encode{ + observee.id, + player:getScreenName(), + player:getAvatar(), + }) + player:doNotify("EnterRoom", json.encode{ + #self.players, self.timeout, + -- FIXME: use real room settings here + { enableFreeAssign = false } + }) + + -- send player data + for _, p in ipairs(self:getOtherPlayers(observee, true, true)) do + player:doNotify("AddPlayer", json.encode{ + p.id, + p.serverplayer:getScreenName(), + p.serverplayer:getAvatar(), + }) + end + + local player_circle = {} + for i = 1, #self.players do + table.insert(player_circle, self.players[i].id) + end + player:doNotify("ArrangeSeats", json.encode(player_circle)) + + for _, p in ipairs(self.players) do + self:notifyProperty(player, p, "general") + p:marshal(player) + end + + -- TODO: tell drawPile + table.insert(self.observers, {observee.id, player}) + end + + local function addObserver(id) + local all_observers = self.room:getObservers() + for _, p in fk.qlist(all_observers) do + if p:getId() == id then + tellRoomToObserver(p) + self:doBroadcastNotify("AddObserver", json.encode{ + p:getId(), + p:getScreenName(), + p:getAvatar() + }) + break + end + end + end + + local function removeObserver(id) + for _, t in ipairs(self.observers) do + local __, p = table.unpack(t) + if p:getId() == id then + table.removeOne(self.observers, t) + self:doBroadcastNotify("RemoveObserver", json.encode{ + p:getId(), + }) + break + end + end + end + while true do local request = self.room:fetchRequest() if request ~= "" then @@ -398,6 +473,10 @@ function Room:requestLoop() id = tonumber(id) if command == "reconnect" then self:getPlayerById(id):reconnect() + elseif command == "observe" then + addObserver(id) + elseif command == "leave" then + removeObserver(id) end end coroutine.yield() @@ -589,7 +668,7 @@ function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra local card_data = json.decode(card) local selected_cards = card_data.subcards self:doIndicate(player.id, targets) - skill:onEffect(self, { + skill:onUse(self, { from = player.id, cards = selected_cards, tos = targets, @@ -606,10 +685,11 @@ end ---@param maxNum integer ---@param includeEquip boolean ---@param skillName string -function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName) +function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, cancelable) if minNum < 1 then return nil end + cancelable = cancelable or false local toDiscard = {} local data = { @@ -619,11 +699,15 @@ function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName) reason = skillName } local prompt = "#AskForDiscard:::" .. maxNum .. ":" .. minNum - local _, ret = self:askForUseActiveSkill(player, "discard_skill", prompt, true, data) + local _, ret = self:askForUseActiveSkill(player, "discard_skill", prompt, cancelable, data) if ret then toDiscard = ret.cards else + if cancelable then return {} end local hands = player:getCardIds(Player.Hand) + if includeEquip then + table.insertTable(hands, player:getCardIds(Player.Equip)) + end for i = 1, minNum do local randomId = hands[math.random(1, #hands)] table.insert(toDiscard, randomId) @@ -793,7 +877,7 @@ function Room:handleUseCardReply(player, data) self:notifySkillInvoked(player, skill.name) player:addSkillUseHistory(skill.name) self:doIndicate(player.id, targets) - skill:onEffect(self, { + skill:onUse(self, { from = player.id, cards = selected_cards, tos = targets, @@ -914,7 +998,17 @@ end ---@param cardUseEvent CardUseStruct local sendCardEmotionAndLog = function(room, cardUseEvent) local from = cardUseEvent.from - local card = cardUseEvent.card + local _card = cardUseEvent.card + + -- when this function is called, card is already in PlaceTable and no filter skill is applied. + -- So filter this card manually here to get 'real' use.card + local card = _card + if not _card:isVirtual() then + local temp = { card = _card } + Fk:filterCard(_card.id, room:getPlayerById(from), temp) + card = temp.card + end + room:setEmotion(room:getPlayerById(from), card.name) local soundName @@ -928,11 +1022,12 @@ local sendCardEmotionAndLog = function(room, cardUseEvent) subTypeStr = "armor" end - soundName = "common/" .. subTypeStr + soundName = "./audio/card/common/" .. subTypeStr else - soundName = (room:getPlayerById(from).gender == General.Male and "male/" or "female/") .. card.name + soundName = "./packages/" .. card.package.extensionName .. "/audio/card/" + .. (room:getPlayerById(from).gender == General.Male and "male/" or "female/") .. card.name end - room:broadcastPlaySound("./audio/card/" .. soundName) + room:broadcastPlaySound(soundName) room:doAnimate("Indicate", { from = from, @@ -946,7 +1041,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent) table.insert(to, t[1]) end - if card:isVirtual() then + if card:isVirtual() or (card ~= _card) then if #useCardIds == 0 then room:sendLog{ type = "#UseV0CardToTargets", @@ -985,7 +1080,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent) end end elseif cardUseEvent.toCard then - if card:isVirtual() then + if card:isVirtual() or (card ~= _card) then if #useCardIds == 0 then room:sendLog{ type = "#UseV0CardToCard", @@ -1011,7 +1106,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent) } end else - if card:isVirtual() then + if card:isVirtual() or (card ~= _card) then if #useCardIds == 0 then room:sendLog{ type = "#UseV0Card", @@ -1362,6 +1457,7 @@ function Room:doCardEffect(cardEffectEvent) end if event == fk.PreCardEffect then + if cardEffectEvent.card.skill:aboutToEffect(self, cardEffectEvent) then return end if cardEffectEvent.card.name == 'slash' and not ( cardEffectEvent.disresponsive or @@ -1563,6 +1659,7 @@ function Room:moveCards(...) table.insert(toAreaIds, toAreaIds == Card.DrawPile and 1 or #toAreaIds + 1, info.cardId) end self:setCardArea(info.cardId, data.toArea, data.to) + Fk:filterCard(info.cardId, self:getPlayerById(data.to)) end end end @@ -1692,7 +1789,7 @@ function Room:changeHp(player, num, reason, skillName, damageStruct) if damageStruct.from then self:sendLog{ type = "#Damage", - to = {damageStruct.from}, + to = {damageStruct.from.id}, from = player.id, arg = 0 - num, arg2 = damage_nature_table[damageStruct.damageType], @@ -1810,11 +1907,11 @@ function Room:damage(damageStruct) return false end - if damageStruct.from and not self:getPlayerById(damageStruct.from):isAlive() then + if damageStruct.from and not damageStruct.from:isAlive() then damageStruct.from = nil end - assert(type(damageStruct.to) == "number") + assert(damageStruct.to:isInstanceOf(ServerPlayer)) local stages = { {fk.PreDamage, damageStruct.from}, @@ -1823,22 +1920,19 @@ function Room:damage(damageStruct) } for _, struct in ipairs(stages) do - local event, playerId = table.unpack(struct) - local player = playerId and self:getPlayerById(playerId) or nil + local event, player = table.unpack(struct) if self.logic:trigger(event, player, damageStruct) or damageStruct.damage < 1 then return false end - assert(type(damageStruct.to) == "number") + assert(damageStruct.to:isInstanceOf(ServerPlayer)) end - assert(self:getPlayerById(damageStruct.to)) - local victim = self:getPlayerById(damageStruct.to) - if not victim:isAlive() then + if not damageStruct.to:isAlive() then return false end - if not self:changeHp(victim, -damageStruct.damage, "damage", damageStruct.skillName, damageStruct) then + if not self:changeHp(damageStruct.to, -damageStruct.damage, "damage", damageStruct.skillName, damageStruct) then return false end @@ -1849,8 +1943,7 @@ function Room:damage(damageStruct) } for _, struct in ipairs(stages) do - local event, playerId = table.unpack(struct) - local player = playerId and self:getPlayerById(playerId) or nil + local event, player = table.unpack(struct) self.logic:trigger(event, player, damageStruct) end @@ -1864,7 +1957,7 @@ function Room:recover(recoverStruct) return false end - local who = self:getPlayerById(recoverStruct.who) + local who = recoverStruct.who if self.logic:trigger(fk.PreHpRecover, who, recoverStruct) or recoverStruct.num < 1 then return false end @@ -1914,7 +2007,7 @@ function Room:killPlayer(deathStruct) if killer then self:sendLog{ type = "#KillPlayer", - to = {killer}, + to = {killer.id}, from = victim.id, arg = victim.role, } @@ -2035,6 +2128,7 @@ function Room:judge(data) self.logic:trigger(fk.AskForRetrial, who, data) self.logic:trigger(fk.FinishRetrial, who, data) + Fk:filterCard(data.card.id, who, data) self:sendLog{ type = "#JudgeResult", from = who.id, diff --git a/lua/server/serverplayer.lua b/lua/server/serverplayer.lua index 1040635b..02a085e9 100644 --- a/lua/server/serverplayer.lua +++ b/lua/server/serverplayer.lua @@ -35,6 +35,13 @@ end ---@param jsonData string function ServerPlayer:doNotify(command, jsonData) self.serverplayer:doNotify(command, jsonData) + local room = self.room + for _, t in ipairs(room.observers) do + local id, p = table.unpack(t) + if id == self.id then + p:doNotify(command, jsonData) + end + end end --- Send a request to client, and allow client to reply within *timeout* seconds. @@ -178,11 +185,13 @@ function ServerPlayer:reconnect() self:doNotify("EnterLobby", "") self:doNotify("EnterRoom", json.encode{ #room.players, room.timeout, + -- FIXME: use real room settings here + { enableFreeAssign = false } }) room:notifyProperty(self, self, "role") -- send player data - for _, p in ipairs(room:getOtherPlayers(self)) do + for _, p in ipairs(room:getOtherPlayers(self, true, true)) do self:doNotify("AddPlayer", json.encode{ p.id, p.serverplayer:getScreenName(), diff --git a/lua/server/system_enum.lua b/lua/server/system_enum.lua index a1374518..6c66209e 100644 --- a/lua/server/system_enum.lua +++ b/lua/server/system_enum.lua @@ -1,22 +1,133 @@ ----@alias CardsMoveInfo {ids: integer[], from: integer|null, to: integer|null, toArea: CardArea, moveReason: CardMoveReason, proposer: integer, skillName: string|null, moveVisible: boolean|null, specialName: string|null, specialVisible: boolean|null } ----@alias MoveInfo {cardId: integer, fromArea: CardArea} ----@alias CardsMoveStruct {moveInfo: MoveInfo[], from: integer|null, to: integer|null, toArea: CardArea, moveReason: CardMoveReason, proposer: integer|null, skillName: string|null, moveVisible: boolean|null, specialName: string|null, specialVisible: boolean|null, fromSpecialName: string|null } +---@class CardsMoveInfo +---@field ids integer[] +---@field from integer|null +---@field to integer|null +---@field toArea CardArea +---@field moveReason CardMoveReason +---@field proposer integer +---@field skillName string|null +---@field moveVisible boolean|null +---@field specialName string|null +---@field specialVisible boolean|null ----@alias HpChangedData { num: integer, reason: string, skillName: string } ----@alias HpLostData { num: integer, skillName: string } ----@alias DamageStruct { from: integer|null, to: integer, damage: integer, card: Card, damageType: DamageType, skillName: string } ----@alias RecoverStruct { who: integer, num: integer, recoverBy: integer|null, skillName: string|null } +---@class MoveInfo +---@field cardId integer +---@field fromArea CardArea ----@alias DyingStruct { who: integer, damage: DamageStruct } ----@alias DeathStruct { who: integer, damage: DamageStruct } +---@class CardsMoveStruct +---@field moveInfo MoveInfo[] +---@field from integer|null +---@field to integer|null +---@field toArea CardArea +---@field moveReason CardMoveReason +---@field proposer integer|null +---@field skillName string|null +---@field moveVisible boolean|null +---@field specialName string|null +---@field specialVisible boolean|null +---@field fromSpecialName string|null ----@alias CardUseStruct { from: integer, tos: TargetGroup, card: Card, toCard: Card|null, responseToEvent: CardUseStruct|null, nullifiedTargets: interger[]|null, extraUse: boolean|null, disresponsiveList: integer[]|null, unoffsetableList: integer[]|null, addtionalDamage: integer|null, customFrom: integer|null, cardsResponded: Card[]|null } ----@alias AimStruct { from: integer, card: Card, tos: AimGroup, to: integer, subTargets: integer[]|null, targetGroup: TargetGroup|null, nullifiedTargets: integer[]|null, firstTarget: boolean, additionalDamage: integer|null, disresponsive: boolean|null, unoffsetableList: boolean|null } ----@alias CardEffectEvent { from: integer, to: integer, subTargets: integer[]|null, tos: TargetGroup, card: Card, toCard: Card|null, responseToEvent: CardUseStruct|null, nullifiedTargets: interger[]|null, extraUse: boolean|null, disresponsiveList: integer[]|null, unoffsetableList: integer[]|null, addtionalDamage: integer|null, customFrom: integer|null, cardsResponded: Card[]|null, disresponsive: boolean|null, unoffsetable: boolean|null } ----@alias SkillEffectEvent { from: integer, tos: integer[], cards: integer[] } +---@class HpChangedData +---@field num integer +---@field reason string +---@field skillName string ----@alias JudgeStruct { who: ServerPlayer, card: Card, reason: string, pattern: string } ----@alias CardResponseEvent { from: integer, card: Card, responseToEvent: CardEffectEvent|null, skipDrop: boolean|null, customFrom: integer|null } +---@class HpLostData +---@field num integer +---@field skillName string + +---@alias DamageType integer + +fk.NormalDamage = 1 +fk.ThunderDamage = 2 +fk.FireDamage = 3 + +---@class DamageStruct +---@field from ServerPlayer|null +---@field to ServerPlayer +---@field damage integer +---@field card Card +---@field damageType DamageType +---@field skillName string + +---@class RecoverStruct +---@field who ServerPlayer +---@field num integer +---@field recoverBy ServerPlayer|null +---@field skillName string|null +---@field card Card|null + +---@class DyingStruct +---@field who integer +---@field damage DamageStruct + +---@class DeathStruct +---@field who integer +---@field damage DamageStruct + +---@class CardUseStruct +---@field from integer +---@field tos TargetGroup +---@field card Card +---@field toCard Card|null +---@field responseToEvent CardUseStruct|null +---@field nullifiedTargets interger[]|null +---@field extraUse boolean|null +---@field disresponsiveList integer[]|null +---@field unoffsetableList integer[]|null +---@field addtionalDamage integer|null +---@field customFrom integer|null +---@field cardsResponded Card[]|null + +---@class AimStruct +---@field from integer +---@field card Card +---@field tos AimGroup +---@field to integer +---@field subTargets integer[]|null +---@field targetGroup TargetGroup|null +---@field nullifiedTargets integer[]|null +---@field firstTarget boolean +---@field additionalDamage integer|null +---@field disresponsive boolean|null +---@field unoffsetableList boolean|null + +---@class CardEffectEvent +---@field from integer +---@field to integer +---@field subTargets integer[]|null +---@field tos TargetGroup +---@field card Card +---@field toCard Card|null +---@field responseToEvent CardEffectStruct|null +---@field nullifiedTargets interger[]|null +---@field extraUse boolean|null +---@field disresponsiveList integer[]|null +---@field unoffsetableList integer[]|null +---@field addtionalDamage integer|null +---@field customFrom integer|null +---@field cardsResponded Card[]|null +---@field disresponsive boolean|null +---@field unoffsetable boolean|null +---@field isCancellOut boolean|null + +---@class SkillEffectEvent +---@field from integer +---@field tos integer[] +---@field cards integer[] + +---@class JudgeStruct +---@field who ServerPlayer +---@field card Card +---@field reason string +---@field pattern string + +---@class CardResponseEvent +---@field from integer +---@field card Card +---@field responseToEvent CardEffectEvent|null +---@field skipDrop boolean|null +---@field customFrom integer|null ---@alias CardMoveReason integer @@ -31,10 +142,11 @@ fk.ReasonExchange = 8 fk.ReasonUse = 9 fk.ReasonResonpse = 10 ----@alias DamageType integer - -fk.NormalDamage = 1 -fk.ThunderDamage = 2 -fk.FireDamage = 3 - ----@alias LogMessage {type: string, from: integer, to: integer[], card: integer[], arg: any, arg2: any, arg3: any} +---@class LogMessage +---@field type string +---@field from integer +---@field to integer[] +---@field card integer[] +---@field arg any +---@field arg2 any +---@field arg3 any diff --git a/packages/.gitignore b/packages/.gitignore new file mode 100644 index 00000000..fd123c66 --- /dev/null +++ b/packages/.gitignore @@ -0,0 +1,7 @@ +/* +!standard/ +!standard_cards/ +!test/ +!manuvering/ +!.gitignore +!init.sql \ No newline at end of file diff --git a/packages/init.sql b/packages/init.sql new file mode 100644 index 00000000..7c045542 --- /dev/null +++ b/packages/init.sql @@ -0,0 +1,6 @@ +CREATE TABLE packages ( + name VARCHAR(128), + url VARCHAR(255), + hash CHAR(40), + enabled BOOLEAN +); diff --git a/audio/death/caocao.mp3 b/packages/standard/audio/death/caocao.mp3 similarity index 100% rename from audio/death/caocao.mp3 rename to packages/standard/audio/death/caocao.mp3 diff --git a/audio/death/daqiao.mp3 b/packages/standard/audio/death/daqiao.mp3 similarity index 100% rename from audio/death/daqiao.mp3 rename to packages/standard/audio/death/daqiao.mp3 diff --git a/audio/death/diaochan.mp3 b/packages/standard/audio/death/diaochan.mp3 similarity index 100% rename from audio/death/diaochan.mp3 rename to packages/standard/audio/death/diaochan.mp3 diff --git a/audio/death/ganning.mp3 b/packages/standard/audio/death/ganning.mp3 similarity index 100% rename from audio/death/ganning.mp3 rename to packages/standard/audio/death/ganning.mp3 diff --git a/audio/death/guanyu.mp3 b/packages/standard/audio/death/guanyu.mp3 similarity index 100% rename from audio/death/guanyu.mp3 rename to packages/standard/audio/death/guanyu.mp3 diff --git a/audio/death/guojia.mp3 b/packages/standard/audio/death/guojia.mp3 similarity index 100% rename from audio/death/guojia.mp3 rename to packages/standard/audio/death/guojia.mp3 diff --git a/audio/death/huanggai.mp3 b/packages/standard/audio/death/huanggai.mp3 similarity index 100% rename from audio/death/huanggai.mp3 rename to packages/standard/audio/death/huanggai.mp3 diff --git a/audio/death/huangyueying.mp3 b/packages/standard/audio/death/huangyueying.mp3 similarity index 100% rename from audio/death/huangyueying.mp3 rename to packages/standard/audio/death/huangyueying.mp3 diff --git a/audio/death/huatuo.mp3 b/packages/standard/audio/death/huatuo.mp3 similarity index 100% rename from audio/death/huatuo.mp3 rename to packages/standard/audio/death/huatuo.mp3 diff --git a/audio/death/liubei.mp3 b/packages/standard/audio/death/liubei.mp3 similarity index 100% rename from audio/death/liubei.mp3 rename to packages/standard/audio/death/liubei.mp3 diff --git a/audio/death/luxun.mp3 b/packages/standard/audio/death/luxun.mp3 similarity index 100% rename from audio/death/luxun.mp3 rename to packages/standard/audio/death/luxun.mp3 diff --git a/audio/death/lvbu.mp3 b/packages/standard/audio/death/lvbu.mp3 similarity index 100% rename from audio/death/lvbu.mp3 rename to packages/standard/audio/death/lvbu.mp3 diff --git a/audio/death/lvmeng.mp3 b/packages/standard/audio/death/lvmeng.mp3 similarity index 100% rename from audio/death/lvmeng.mp3 rename to packages/standard/audio/death/lvmeng.mp3 diff --git a/audio/death/machao.mp3 b/packages/standard/audio/death/machao.mp3 similarity index 100% rename from audio/death/machao.mp3 rename to packages/standard/audio/death/machao.mp3 diff --git a/audio/death/simayi.mp3 b/packages/standard/audio/death/simayi.mp3 similarity index 100% rename from audio/death/simayi.mp3 rename to packages/standard/audio/death/simayi.mp3 diff --git a/audio/death/sunquan.mp3 b/packages/standard/audio/death/sunquan.mp3 similarity index 100% rename from audio/death/sunquan.mp3 rename to packages/standard/audio/death/sunquan.mp3 diff --git a/audio/death/sunshangxiang.mp3 b/packages/standard/audio/death/sunshangxiang.mp3 similarity index 100% rename from audio/death/sunshangxiang.mp3 rename to packages/standard/audio/death/sunshangxiang.mp3 diff --git a/audio/death/xiahoudun.mp3 b/packages/standard/audio/death/xiahoudun.mp3 similarity index 100% rename from audio/death/xiahoudun.mp3 rename to packages/standard/audio/death/xiahoudun.mp3 diff --git a/audio/death/xuchu.mp3 b/packages/standard/audio/death/xuchu.mp3 similarity index 100% rename from audio/death/xuchu.mp3 rename to packages/standard/audio/death/xuchu.mp3 diff --git a/audio/death/zhangfei.mp3 b/packages/standard/audio/death/zhangfei.mp3 similarity index 100% rename from audio/death/zhangfei.mp3 rename to packages/standard/audio/death/zhangfei.mp3 diff --git a/audio/death/zhangliao.mp3 b/packages/standard/audio/death/zhangliao.mp3 similarity index 100% rename from audio/death/zhangliao.mp3 rename to packages/standard/audio/death/zhangliao.mp3 diff --git a/audio/death/zhaoyun.mp3 b/packages/standard/audio/death/zhaoyun.mp3 similarity index 100% rename from audio/death/zhaoyun.mp3 rename to packages/standard/audio/death/zhaoyun.mp3 diff --git a/audio/death/zhenji.mp3 b/packages/standard/audio/death/zhenji.mp3 similarity index 100% rename from audio/death/zhenji.mp3 rename to packages/standard/audio/death/zhenji.mp3 diff --git a/audio/death/zhouyu.mp3 b/packages/standard/audio/death/zhouyu.mp3 similarity index 100% rename from audio/death/zhouyu.mp3 rename to packages/standard/audio/death/zhouyu.mp3 diff --git a/audio/death/zhugeliang.mp3 b/packages/standard/audio/death/zhugeliang.mp3 similarity index 100% rename from audio/death/zhugeliang.mp3 rename to packages/standard/audio/death/zhugeliang.mp3 diff --git a/audio/skill/biyue1.mp3 b/packages/standard/audio/skill/biyue1.mp3 similarity index 100% rename from audio/skill/biyue1.mp3 rename to packages/standard/audio/skill/biyue1.mp3 diff --git a/audio/skill/biyue2.mp3 b/packages/standard/audio/skill/biyue2.mp3 similarity index 100% rename from audio/skill/biyue2.mp3 rename to packages/standard/audio/skill/biyue2.mp3 diff --git a/audio/skill/fanjian1.mp3 b/packages/standard/audio/skill/fanjian1.mp3 similarity index 100% rename from audio/skill/fanjian1.mp3 rename to packages/standard/audio/skill/fanjian1.mp3 diff --git a/audio/skill/fanjian2.mp3 b/packages/standard/audio/skill/fanjian2.mp3 similarity index 100% rename from audio/skill/fanjian2.mp3 rename to packages/standard/audio/skill/fanjian2.mp3 diff --git a/audio/skill/fankui1.mp3 b/packages/standard/audio/skill/fankui1.mp3 similarity index 100% rename from audio/skill/fankui1.mp3 rename to packages/standard/audio/skill/fankui1.mp3 diff --git a/audio/skill/fankui2.mp3 b/packages/standard/audio/skill/fankui2.mp3 similarity index 100% rename from audio/skill/fankui2.mp3 rename to packages/standard/audio/skill/fankui2.mp3 diff --git a/audio/skill/ganglie1.mp3 b/packages/standard/audio/skill/ganglie1.mp3 similarity index 100% rename from audio/skill/ganglie1.mp3 rename to packages/standard/audio/skill/ganglie1.mp3 diff --git a/audio/skill/ganglie2.mp3 b/packages/standard/audio/skill/ganglie2.mp3 similarity index 100% rename from audio/skill/ganglie2.mp3 rename to packages/standard/audio/skill/ganglie2.mp3 diff --git a/audio/skill/guanxing1.mp3 b/packages/standard/audio/skill/guanxing1.mp3 similarity index 100% rename from audio/skill/guanxing1.mp3 rename to packages/standard/audio/skill/guanxing1.mp3 diff --git a/audio/skill/guanxing2.mp3 b/packages/standard/audio/skill/guanxing2.mp3 similarity index 100% rename from audio/skill/guanxing2.mp3 rename to packages/standard/audio/skill/guanxing2.mp3 diff --git a/audio/skill/guicai1.mp3 b/packages/standard/audio/skill/guicai1.mp3 similarity index 100% rename from audio/skill/guicai1.mp3 rename to packages/standard/audio/skill/guicai1.mp3 diff --git a/audio/skill/guicai2.mp3 b/packages/standard/audio/skill/guicai2.mp3 similarity index 100% rename from audio/skill/guicai2.mp3 rename to packages/standard/audio/skill/guicai2.mp3 diff --git a/audio/skill/guose1.mp3 b/packages/standard/audio/skill/guose1.mp3 similarity index 100% rename from audio/skill/guose1.mp3 rename to packages/standard/audio/skill/guose1.mp3 diff --git a/audio/skill/guose2.mp3 b/packages/standard/audio/skill/guose2.mp3 similarity index 100% rename from audio/skill/guose2.mp3 rename to packages/standard/audio/skill/guose2.mp3 diff --git a/audio/skill/jianxiong1.mp3 b/packages/standard/audio/skill/jianxiong1.mp3 similarity index 100% rename from audio/skill/jianxiong1.mp3 rename to packages/standard/audio/skill/jianxiong1.mp3 diff --git a/audio/skill/jianxiong2.mp3 b/packages/standard/audio/skill/jianxiong2.mp3 similarity index 100% rename from audio/skill/jianxiong2.mp3 rename to packages/standard/audio/skill/jianxiong2.mp3 diff --git a/audio/skill/jieyin1.mp3 b/packages/standard/audio/skill/jieyin1.mp3 similarity index 100% rename from audio/skill/jieyin1.mp3 rename to packages/standard/audio/skill/jieyin1.mp3 diff --git a/audio/skill/jieyin2.mp3 b/packages/standard/audio/skill/jieyin2.mp3 similarity index 100% rename from audio/skill/jieyin2.mp3 rename to packages/standard/audio/skill/jieyin2.mp3 diff --git a/audio/skill/jijiu1.mp3 b/packages/standard/audio/skill/jijiu1.mp3 similarity index 100% rename from audio/skill/jijiu1.mp3 rename to packages/standard/audio/skill/jijiu1.mp3 diff --git a/audio/skill/jijiu2.mp3 b/packages/standard/audio/skill/jijiu2.mp3 similarity index 100% rename from audio/skill/jijiu2.mp3 rename to packages/standard/audio/skill/jijiu2.mp3 diff --git a/audio/skill/jizhi1.mp3 b/packages/standard/audio/skill/jizhi1.mp3 similarity index 100% rename from audio/skill/jizhi1.mp3 rename to packages/standard/audio/skill/jizhi1.mp3 diff --git a/audio/skill/jizhi2.mp3 b/packages/standard/audio/skill/jizhi2.mp3 similarity index 100% rename from audio/skill/jizhi2.mp3 rename to packages/standard/audio/skill/jizhi2.mp3 diff --git a/audio/skill/keji1.mp3 b/packages/standard/audio/skill/keji1.mp3 similarity index 100% rename from audio/skill/keji1.mp3 rename to packages/standard/audio/skill/keji1.mp3 diff --git a/audio/skill/keji2.mp3 b/packages/standard/audio/skill/keji2.mp3 similarity index 100% rename from audio/skill/keji2.mp3 rename to packages/standard/audio/skill/keji2.mp3 diff --git a/audio/skill/kongcheng1.mp3 b/packages/standard/audio/skill/kongcheng1.mp3 similarity index 100% rename from audio/skill/kongcheng1.mp3 rename to packages/standard/audio/skill/kongcheng1.mp3 diff --git a/audio/skill/kongcheng2.mp3 b/packages/standard/audio/skill/kongcheng2.mp3 similarity index 100% rename from audio/skill/kongcheng2.mp3 rename to packages/standard/audio/skill/kongcheng2.mp3 diff --git a/audio/skill/kurou1.mp3 b/packages/standard/audio/skill/kurou1.mp3 similarity index 100% rename from audio/skill/kurou1.mp3 rename to packages/standard/audio/skill/kurou1.mp3 diff --git a/audio/skill/kurou2.mp3 b/packages/standard/audio/skill/kurou2.mp3 similarity index 100% rename from audio/skill/kurou2.mp3 rename to packages/standard/audio/skill/kurou2.mp3 diff --git a/audio/skill/lianying1.mp3 b/packages/standard/audio/skill/lianying1.mp3 similarity index 100% rename from audio/skill/lianying1.mp3 rename to packages/standard/audio/skill/lianying1.mp3 diff --git a/audio/skill/lianying2.mp3 b/packages/standard/audio/skill/lianying2.mp3 similarity index 100% rename from audio/skill/lianying2.mp3 rename to packages/standard/audio/skill/lianying2.mp3 diff --git a/audio/skill/lijian1.mp3 b/packages/standard/audio/skill/lijian1.mp3 similarity index 100% rename from audio/skill/lijian1.mp3 rename to packages/standard/audio/skill/lijian1.mp3 diff --git a/audio/skill/lijian2.mp3 b/packages/standard/audio/skill/lijian2.mp3 similarity index 100% rename from audio/skill/lijian2.mp3 rename to packages/standard/audio/skill/lijian2.mp3 diff --git a/audio/skill/liuli1.mp3 b/packages/standard/audio/skill/liuli1.mp3 similarity index 100% rename from audio/skill/liuli1.mp3 rename to packages/standard/audio/skill/liuli1.mp3 diff --git a/audio/skill/liuli2.mp3 b/packages/standard/audio/skill/liuli2.mp3 similarity index 100% rename from audio/skill/liuli2.mp3 rename to packages/standard/audio/skill/liuli2.mp3 diff --git a/audio/skill/longdan1.mp3 b/packages/standard/audio/skill/longdan1.mp3 similarity index 100% rename from audio/skill/longdan1.mp3 rename to packages/standard/audio/skill/longdan1.mp3 diff --git a/audio/skill/longdan2.mp3 b/packages/standard/audio/skill/longdan2.mp3 similarity index 100% rename from audio/skill/longdan2.mp3 rename to packages/standard/audio/skill/longdan2.mp3 diff --git a/audio/skill/luoshen1.mp3 b/packages/standard/audio/skill/luoshen1.mp3 similarity index 100% rename from audio/skill/luoshen1.mp3 rename to packages/standard/audio/skill/luoshen1.mp3 diff --git a/audio/skill/luoshen2.mp3 b/packages/standard/audio/skill/luoshen2.mp3 similarity index 100% rename from audio/skill/luoshen2.mp3 rename to packages/standard/audio/skill/luoshen2.mp3 diff --git a/audio/skill/luoyi1.mp3 b/packages/standard/audio/skill/luoyi1.mp3 similarity index 100% rename from audio/skill/luoyi1.mp3 rename to packages/standard/audio/skill/luoyi1.mp3 diff --git a/audio/skill/luoyi2.mp3 b/packages/standard/audio/skill/luoyi2.mp3 similarity index 100% rename from audio/skill/luoyi2.mp3 rename to packages/standard/audio/skill/luoyi2.mp3 diff --git a/audio/skill/paoxiao1.mp3 b/packages/standard/audio/skill/paoxiao1.mp3 similarity index 100% rename from audio/skill/paoxiao1.mp3 rename to packages/standard/audio/skill/paoxiao1.mp3 diff --git a/audio/skill/paoxiao2.mp3 b/packages/standard/audio/skill/paoxiao2.mp3 similarity index 100% rename from audio/skill/paoxiao2.mp3 rename to packages/standard/audio/skill/paoxiao2.mp3 diff --git a/audio/skill/qianxun1.mp3 b/packages/standard/audio/skill/qianxun1.mp3 similarity index 100% rename from audio/skill/qianxun1.mp3 rename to packages/standard/audio/skill/qianxun1.mp3 diff --git a/audio/skill/qianxun2.mp3 b/packages/standard/audio/skill/qianxun2.mp3 similarity index 100% rename from audio/skill/qianxun2.mp3 rename to packages/standard/audio/skill/qianxun2.mp3 diff --git a/audio/skill/qingguo1.mp3 b/packages/standard/audio/skill/qingguo1.mp3 similarity index 100% rename from audio/skill/qingguo1.mp3 rename to packages/standard/audio/skill/qingguo1.mp3 diff --git a/audio/skill/qingguo2.mp3 b/packages/standard/audio/skill/qingguo2.mp3 similarity index 100% rename from audio/skill/qingguo2.mp3 rename to packages/standard/audio/skill/qingguo2.mp3 diff --git a/audio/skill/qingnang1.mp3 b/packages/standard/audio/skill/qingnang1.mp3 similarity index 100% rename from audio/skill/qingnang1.mp3 rename to packages/standard/audio/skill/qingnang1.mp3 diff --git a/audio/skill/qingnang2.mp3 b/packages/standard/audio/skill/qingnang2.mp3 similarity index 100% rename from audio/skill/qingnang2.mp3 rename to packages/standard/audio/skill/qingnang2.mp3 diff --git a/audio/skill/qixi1.mp3 b/packages/standard/audio/skill/qixi1.mp3 similarity index 100% rename from audio/skill/qixi1.mp3 rename to packages/standard/audio/skill/qixi1.mp3 diff --git a/audio/skill/qixi2.mp3 b/packages/standard/audio/skill/qixi2.mp3 similarity index 100% rename from audio/skill/qixi2.mp3 rename to packages/standard/audio/skill/qixi2.mp3 diff --git a/audio/skill/rende1.mp3 b/packages/standard/audio/skill/rende1.mp3 similarity index 100% rename from audio/skill/rende1.mp3 rename to packages/standard/audio/skill/rende1.mp3 diff --git a/audio/skill/rende2.mp3 b/packages/standard/audio/skill/rende2.mp3 similarity index 100% rename from audio/skill/rende2.mp3 rename to packages/standard/audio/skill/rende2.mp3 diff --git a/audio/skill/tiandu1.mp3 b/packages/standard/audio/skill/tiandu1.mp3 similarity index 100% rename from audio/skill/tiandu1.mp3 rename to packages/standard/audio/skill/tiandu1.mp3 diff --git a/audio/skill/tiandu2.mp3 b/packages/standard/audio/skill/tiandu2.mp3 similarity index 100% rename from audio/skill/tiandu2.mp3 rename to packages/standard/audio/skill/tiandu2.mp3 diff --git a/audio/skill/tieqi1.mp3 b/packages/standard/audio/skill/tieqi1.mp3 similarity index 100% rename from audio/skill/tieqi1.mp3 rename to packages/standard/audio/skill/tieqi1.mp3 diff --git a/audio/skill/tieqi2.mp3 b/packages/standard/audio/skill/tieqi2.mp3 similarity index 100% rename from audio/skill/tieqi2.mp3 rename to packages/standard/audio/skill/tieqi2.mp3 diff --git a/audio/skill/tuxi1.mp3 b/packages/standard/audio/skill/tuxi1.mp3 similarity index 100% rename from audio/skill/tuxi1.mp3 rename to packages/standard/audio/skill/tuxi1.mp3 diff --git a/audio/skill/tuxi2.mp3 b/packages/standard/audio/skill/tuxi2.mp3 similarity index 100% rename from audio/skill/tuxi2.mp3 rename to packages/standard/audio/skill/tuxi2.mp3 diff --git a/audio/skill/wusheng1.mp3 b/packages/standard/audio/skill/wusheng1.mp3 similarity index 100% rename from audio/skill/wusheng1.mp3 rename to packages/standard/audio/skill/wusheng1.mp3 diff --git a/audio/skill/wusheng2.mp3 b/packages/standard/audio/skill/wusheng2.mp3 similarity index 100% rename from audio/skill/wusheng2.mp3 rename to packages/standard/audio/skill/wusheng2.mp3 diff --git a/audio/skill/wushuang1.mp3 b/packages/standard/audio/skill/wushuang1.mp3 similarity index 100% rename from audio/skill/wushuang1.mp3 rename to packages/standard/audio/skill/wushuang1.mp3 diff --git a/audio/skill/wushuang2.mp3 b/packages/standard/audio/skill/wushuang2.mp3 similarity index 100% rename from audio/skill/wushuang2.mp3 rename to packages/standard/audio/skill/wushuang2.mp3 diff --git a/audio/skill/xiaoji1.mp3 b/packages/standard/audio/skill/xiaoji1.mp3 similarity index 100% rename from audio/skill/xiaoji1.mp3 rename to packages/standard/audio/skill/xiaoji1.mp3 diff --git a/audio/skill/xiaoji2.mp3 b/packages/standard/audio/skill/xiaoji2.mp3 similarity index 100% rename from audio/skill/xiaoji2.mp3 rename to packages/standard/audio/skill/xiaoji2.mp3 diff --git a/audio/skill/yiji1.mp3 b/packages/standard/audio/skill/yiji1.mp3 similarity index 100% rename from audio/skill/yiji1.mp3 rename to packages/standard/audio/skill/yiji1.mp3 diff --git a/audio/skill/yiji2.mp3 b/packages/standard/audio/skill/yiji2.mp3 similarity index 100% rename from audio/skill/yiji2.mp3 rename to packages/standard/audio/skill/yiji2.mp3 diff --git a/audio/skill/yingzi1.mp3 b/packages/standard/audio/skill/yingzi1.mp3 similarity index 100% rename from audio/skill/yingzi1.mp3 rename to packages/standard/audio/skill/yingzi1.mp3 diff --git a/audio/skill/yingzi2.mp3 b/packages/standard/audio/skill/yingzi2.mp3 similarity index 100% rename from audio/skill/yingzi2.mp3 rename to packages/standard/audio/skill/yingzi2.mp3 diff --git a/audio/skill/zhiheng1.mp3 b/packages/standard/audio/skill/zhiheng1.mp3 similarity index 100% rename from audio/skill/zhiheng1.mp3 rename to packages/standard/audio/skill/zhiheng1.mp3 diff --git a/audio/skill/zhiheng2.mp3 b/packages/standard/audio/skill/zhiheng2.mp3 similarity index 100% rename from audio/skill/zhiheng2.mp3 rename to packages/standard/audio/skill/zhiheng2.mp3 diff --git a/packages/standard/game_rule.lua b/packages/standard/game_rule.lua index ee96946b..a9329851 100644 --- a/packages/standard/game_rule.lua +++ b/packages/standard/game_rule.lua @@ -57,7 +57,6 @@ GameRule = fk.CreateTriggerSkill{ end if event == fk.GameStart then - fk.qInfo("Game started") RoomInstance.tag["FirstRound"] = true return false end @@ -69,6 +68,9 @@ GameRule = fk.CreateTriggerSkill{ -- TODO: need a new function to call the UI local cardIds = room:getNCards(data.num) player:addCards(Player.Hand, cardIds) + for _, id in ipairs(cardIds) do + Fk:filterCard(id, player) + end local move_to_notify = {} ---@type CardsMoveStruct move_to_notify.toArea = Card.PlayerHand move_to_notify.to = player.id @@ -227,7 +229,7 @@ GameRule = fk.CreateTriggerSkill{ end local damage = data.damage if damage and damage.from then - local killer = room:getPlayerById(damage.from) + local killer = damage.from rewardAndPunish(killer, player); end end, diff --git a/image/generals/caocao.jpg b/packages/standard/image/generals/caocao.jpg similarity index 100% rename from image/generals/caocao.jpg rename to packages/standard/image/generals/caocao.jpg diff --git a/image/generals/daqiao.jpg b/packages/standard/image/generals/daqiao.jpg similarity index 100% rename from image/generals/daqiao.jpg rename to packages/standard/image/generals/daqiao.jpg diff --git a/image/generals/diaochan.jpg b/packages/standard/image/generals/diaochan.jpg similarity index 100% rename from image/generals/diaochan.jpg rename to packages/standard/image/generals/diaochan.jpg diff --git a/image/generals/ganning.jpg b/packages/standard/image/generals/ganning.jpg similarity index 100% rename from image/generals/ganning.jpg rename to packages/standard/image/generals/ganning.jpg diff --git a/image/generals/guanyu.jpg b/packages/standard/image/generals/guanyu.jpg similarity index 100% rename from image/generals/guanyu.jpg rename to packages/standard/image/generals/guanyu.jpg diff --git a/image/generals/guojia.jpg b/packages/standard/image/generals/guojia.jpg similarity index 100% rename from image/generals/guojia.jpg rename to packages/standard/image/generals/guojia.jpg diff --git a/image/generals/huanggai.jpg b/packages/standard/image/generals/huanggai.jpg similarity index 100% rename from image/generals/huanggai.jpg rename to packages/standard/image/generals/huanggai.jpg diff --git a/image/generals/huangyueying.jpg b/packages/standard/image/generals/huangyueying.jpg similarity index 100% rename from image/generals/huangyueying.jpg rename to packages/standard/image/generals/huangyueying.jpg diff --git a/image/generals/huatuo.jpg b/packages/standard/image/generals/huatuo.jpg similarity index 100% rename from image/generals/huatuo.jpg rename to packages/standard/image/generals/huatuo.jpg diff --git a/image/generals/liubei.jpg b/packages/standard/image/generals/liubei.jpg similarity index 100% rename from image/generals/liubei.jpg rename to packages/standard/image/generals/liubei.jpg diff --git a/image/generals/luxun.jpg b/packages/standard/image/generals/luxun.jpg similarity index 100% rename from image/generals/luxun.jpg rename to packages/standard/image/generals/luxun.jpg diff --git a/image/generals/lvbu.jpg b/packages/standard/image/generals/lvbu.jpg similarity index 100% rename from image/generals/lvbu.jpg rename to packages/standard/image/generals/lvbu.jpg diff --git a/image/generals/lvmeng.jpg b/packages/standard/image/generals/lvmeng.jpg similarity index 100% rename from image/generals/lvmeng.jpg rename to packages/standard/image/generals/lvmeng.jpg diff --git a/image/generals/machao.jpg b/packages/standard/image/generals/machao.jpg similarity index 100% rename from image/generals/machao.jpg rename to packages/standard/image/generals/machao.jpg diff --git a/image/generals/simayi.jpg b/packages/standard/image/generals/simayi.jpg similarity index 100% rename from image/generals/simayi.jpg rename to packages/standard/image/generals/simayi.jpg diff --git a/image/generals/sunquan.jpg b/packages/standard/image/generals/sunquan.jpg similarity index 100% rename from image/generals/sunquan.jpg rename to packages/standard/image/generals/sunquan.jpg diff --git a/image/generals/sunshangxiang.jpg b/packages/standard/image/generals/sunshangxiang.jpg similarity index 100% rename from image/generals/sunshangxiang.jpg rename to packages/standard/image/generals/sunshangxiang.jpg diff --git a/image/generals/xiahoudun.jpg b/packages/standard/image/generals/xiahoudun.jpg similarity index 100% rename from image/generals/xiahoudun.jpg rename to packages/standard/image/generals/xiahoudun.jpg diff --git a/image/generals/xuchu.jpg b/packages/standard/image/generals/xuchu.jpg similarity index 100% rename from image/generals/xuchu.jpg rename to packages/standard/image/generals/xuchu.jpg diff --git a/image/generals/zhangfei.jpg b/packages/standard/image/generals/zhangfei.jpg similarity index 100% rename from image/generals/zhangfei.jpg rename to packages/standard/image/generals/zhangfei.jpg diff --git a/image/generals/zhangliao.jpg b/packages/standard/image/generals/zhangliao.jpg similarity index 100% rename from image/generals/zhangliao.jpg rename to packages/standard/image/generals/zhangliao.jpg diff --git a/image/generals/zhaoyun.jpg b/packages/standard/image/generals/zhaoyun.jpg similarity index 100% rename from image/generals/zhaoyun.jpg rename to packages/standard/image/generals/zhaoyun.jpg diff --git a/image/generals/zhenji.jpg b/packages/standard/image/generals/zhenji.jpg similarity index 100% rename from image/generals/zhenji.jpg rename to packages/standard/image/generals/zhenji.jpg diff --git a/image/generals/zhouyu.jpg b/packages/standard/image/generals/zhouyu.jpg similarity index 100% rename from image/generals/zhouyu.jpg rename to packages/standard/image/generals/zhouyu.jpg diff --git a/image/generals/zhugeliang.jpg b/packages/standard/image/generals/zhugeliang.jpg similarity index 100% rename from image/generals/zhugeliang.jpg rename to packages/standard/image/generals/zhugeliang.jpg diff --git a/packages/standard/init.lua b/packages/standard/init.lua index be749926..ed59e11e 100644 --- a/packages/standard/init.lua +++ b/packages/standard/init.lua @@ -39,6 +39,7 @@ caocao:addSkill(jianxiong) Fk:loadTranslationTable{ ["caocao"] = "曹操", ["jianxiong"] = "奸雄", + [":jianxiong"] = "当你受到伤害后,你可以获得对你造成伤害的牌。", } local guicai = fk.CreateTriggerSkill{ @@ -69,7 +70,7 @@ local fankui = fk.CreateTriggerSkill{ frequency = Skill.NotFrequent, can_trigger = function(self, event, target, player, data) local room = target.room - local from = room:getPlayerById(data.from) + local from = data.from return from ~= nil and target == player and target:hasSkill(self.name) and @@ -78,7 +79,7 @@ local fankui = fk.CreateTriggerSkill{ end, on_use = function(self, event, target, player, data) local room = player.room - local from = room:getPlayerById(data.from) + local from = data.from local card = room:askForCardChosen(player, from, "he", self.name) room:obtainCard(player.id, card, false) end @@ -89,8 +90,10 @@ simayi:addSkill(fankui) Fk:loadTranslationTable{ ["simayi"] = "司马懿", ["guicai"] = "鬼才", + [":guicai"] = "当一名角色的判定牌生效前,你可以打出一张手牌代替之。", ["#guicai-ask"] = "是否发动“鬼才”,打出一张手牌修改 %dest 的判定?", ["fankui"] = "反馈", + [":fankui"] = "当你受到伤害后,你可以获得伤害来源的一张牌。", } local ganglie = fk.CreateTriggerSkill{ @@ -106,19 +109,19 @@ local ganglie = fk.CreateTriggerSkill{ end, on_use = function(self, event, target, player, data) local room = player.room - local from = room:getPlayerById(data.from) + local from = data.from local judge = { - who = from, + who = player, reason = self.name, pattern = ".|.|spade,club,diamond", } room:judge(judge) if judge.card.suit ~= Card.Heart then - local discards = room:askForDiscard(from, 2, 2, false, self.name) + local discards = room:askForDiscard(from, 2, 2, false, self.name, true) if #discards == 0 then room:damage{ - from = player.id, - to = from.id, + from = player, + to = from, damage = 1, skillName = self.name, } @@ -131,6 +134,7 @@ xiahoudun:addSkill(ganglie) Fk:loadTranslationTable{ ["xiahoudun"] = "夏侯惇", ["ganglie"] = "刚烈", + [":ganglie"] = "当你受到伤害后,你可以进行判定:若结果不为红桃,则伤害来源选择一项:弃置两张手牌,或受到1点伤害。", } local tuxi = fk.CreateTriggerSkill{ @@ -179,7 +183,8 @@ zhangliao:addSkill(tuxi) Fk:loadTranslationTable{ ["zhangliao"] = "张辽", ["tuxi"] = "突袭", - ["#tuxi-ask"] = "是否发动“突袭”,改为获得1-2名角色各一张牌?", + [":tuxi"] = "摸牌阶段,你可以改为获得至多两名其他角色的各一张手牌。", + ["#tuxi-ask"] = "是否发动“突袭”,改为获得1-2名角色各一张手牌?", } local luoyi = fk.CreateTriggerSkill{ @@ -215,6 +220,7 @@ xuchu:addSkill(luoyi) Fk:loadTranslationTable{ ["xuchu"] = "许褚", ["luoyi"] = "裸衣", + [":luoyi"] = "摸牌阶段,你可以少摸一张牌,若如此做,本回合你使用【杀】或【决斗】对目标角色造成伤害时,此伤害+1。", } local tiandu = fk.CreateTriggerSkill{ @@ -254,7 +260,9 @@ guojia:addSkill(yiji) Fk:loadTranslationTable{ ["guojia"] = "郭嘉", ["tiandu"] = "天妒", + [":tiandu"] = "当你的判定牌生效后,你可以获得之。", ["yiji"] = "遗计", + [":yiji"] = "每当你受到1点伤害后,你可以观看牌堆顶的两张牌并任意分配它们。", } local luoshen = fk.CreateTriggerSkill{ @@ -318,7 +326,9 @@ zhenji:addSkill(qingguo) Fk:loadTranslationTable{ ["zhenji"] = "甄姬", ["luoshen"] = "洛神", + [":luoshen"] = "准备阶段开始时,你可以进行判定:若结果为黑色,判定牌生效后你获得之,然后你可以再次发动“洛神”。", ["qingguo"] = "倾国", + [":qingguo"] = "你可以将一张黑色手牌当【闪】使用或打出。", } local rendetrig = fk.CreateTriggerSkill{ @@ -345,7 +355,7 @@ local rende = fk.CreateActiveSkill{ feasible = function(self, targets, cards) return #targets == 1 and #cards > 0 end, - on_effect = function(self, room, effect) + on_use = function(self, room, effect) local target = room:getPlayerById(effect.tos[1]) local player = room:getPlayerById(effect.from) local cards = effect.cards @@ -356,7 +366,7 @@ local rende = fk.CreateActiveSkill{ room:addPlayerMark(player, "_rende_cards", #cards) if marks < 2 and marks + #cards >= 2 and player:isWounded() then room:recover{ - who = player.id, + who = player, num = 1, skillName = self.name } @@ -369,6 +379,7 @@ liubei:addSkill(rende) Fk:loadTranslationTable{ ["liubei"] = "刘备", ["rende"] = "仁德", + [":rende"] = "出牌阶段,你可以将至少一张手牌任意分配给其他角色。你于本阶段内以此法给出的手牌首次达到两张或更多后,你回复1点体力。", } local wusheng = fk.CreateViewAsSkill{ @@ -393,6 +404,7 @@ guanyu:addSkill(wusheng) Fk:loadTranslationTable{ ["guanyu"] = "关羽", ["wusheng"] = "武圣", + [":wusheng"] = "你可以将一张红色牌当【杀】使用或打出。", } local paoxiaoAudio = fk.CreateTriggerSkill{ @@ -427,6 +439,7 @@ zhangfei:addSkill(paoxiao) Fk:loadTranslationTable{ ["zhangfei"] = "张飞", ["paoxiao"] = "咆哮", + [":paoxiao"] = "锁定技,出牌阶段,你使用【杀】无次数限制。", } local guanxing = fk.CreateTriggerSkill{ @@ -482,7 +495,9 @@ zhugeliang:addSkill(kongcheng) Fk:loadTranslationTable{ ["zhugeliang"] = "诸葛亮", ["guanxing"] = "观星", + [":guanxing"] = "准备阶段开始时,你可以观看牌堆顶的X张牌,然后将任意数量的牌置于牌堆顶,将其余的牌置于牌堆底。(X为存活角色数且至多为5)", ["kongcheng"] = "空城", + [":kongcheng"] = "锁定技,若你没有手牌,你不能被选择为【杀】或【决斗】的目标。", } local longdan = fk.CreateViewAsSkill{ @@ -513,6 +528,7 @@ zhaoyun:addSkill(longdan) Fk:loadTranslationTable{ ["zhaoyun"] = "赵云", ["longdan"] = "龙胆", + [":longdan"] = "你可以将一张【杀】当【闪】使用或打出,或将一张【闪】当普通【杀】使用或打出。", } local mashu = fk.CreateDistanceSkill{ @@ -550,7 +566,9 @@ machao:addSkill(tieqi) Fk:loadTranslationTable{ ["machao"] = "马超", ["mashu"] = "马术", + [":mashu"] = "锁定技。你与其他角色的距离-1。", ["tieqi"] = "铁骑", + [":tieqi"] = "每当你指定【杀】的目标后,你可以进行判定:若结果为红色,该角色不能使用【闪】响应此【杀】。", } local jizhi = fk.CreateTriggerSkill{ @@ -582,7 +600,9 @@ huangyueying:addSkill(qicai) Fk:loadTranslationTable{ ["huangyueying"] = "黄月英", ["jizhi"] = "集智", + [":jizhi"] = "每当你使用一张非延时锦囊牌时,你可以摸一张牌。", ["qicai"] = "奇才", + [":qicai"] = "锁定技。你使用锦囊牌无距离限制。", } local zhiheng = fk.CreateActiveSkill{ @@ -594,7 +614,7 @@ local zhiheng = fk.CreateActiveSkill{ feasible = function(self, selected, selected_cards) return #selected == 0 and #selected_cards > 0 end, - on_effect = function(self, room, effect) + on_use = function(self, room, effect) local from = room:getPlayerById(effect.from) room:throwCard(effect.cards, self.name, from) room:drawCards(from, #effect.cards, self.name) @@ -605,6 +625,7 @@ sunquan:addSkill(zhiheng) Fk:loadTranslationTable{ ["sunquan"] = "孙权", ["zhiheng"] = "制衡", + [":zhiheng"] = "阶段技,你可以弃置至少一张牌然后摸等量的牌。", } local qixi = fk.CreateViewAsSkill{ @@ -629,6 +650,7 @@ ganning:addSkill(qixi) Fk:loadTranslationTable{ ["ganning"] = "甘宁", ["qixi"] = "奇袭", + [":qixi"] = "你可以将一张黑色牌当【过河拆桥】使用。", } local keji = fk.CreateTriggerSkill{ @@ -670,6 +692,7 @@ lvmeng:addSkill(keji) Fk:loadTranslationTable{ ["lvmeng"] = "吕蒙", ["keji"] = "克己", + [":keji"] = "若你未于出牌阶段内使用或打出【杀】,你可以跳过弃牌阶段。", } local kurou = fk.CreateActiveSkill{ @@ -678,7 +701,7 @@ local kurou = fk.CreateActiveSkill{ card_filter = function(self, to_select, selected, selected_targets) return false end, - on_effect = function(self, room, effect) + on_use = function(self, room, effect) local from = room:getPlayerById(effect.from) room:loseHp(from, 1, self.name) if from:isAlive() then @@ -691,6 +714,7 @@ huanggai:addSkill(kurou) Fk:loadTranslationTable{ ["huanggai"] = "黄盖", ["kurou"] = "苦肉", + [":kurou"] = "出牌阶段,你可以失去1点体力然后摸两张牌。", } local yingzi = fk.CreateTriggerSkill{ @@ -713,7 +737,7 @@ local fanjian = fk.CreateActiveSkill{ feasible = function(self, selected) return #selected == 1 end, - on_effect = function(self, room, effect) + on_use = function(self, room, effect) local player = room:getPlayerById(effect.from) local target = room:getPlayerById(effect.tos[1]) local choice = room:askForChoice(target, {"spade", "heart", "club", "diamond"}, self.name) @@ -721,8 +745,8 @@ local fanjian = fk.CreateActiveSkill{ room:obtainCard(target.id, card, true) if Fk:getCardById(card):getSuitString() ~= choice then room:damage{ - from = player.id, - to = target.id, + from = player, + to = target, damage = 1, skillName = self.name, } @@ -735,7 +759,9 @@ zhouyu:addSkill(fanjian) Fk:loadTranslationTable{ ["zhouyu"] = "周瑜", ["yingzi"] = "英姿", + [":yingzi"] = "摸牌阶段,你可以多摸一张牌。", ["fanjian"] = "反间", + [":fanjian"] = "阶段技。你可以令一名其他角色选择一种花色,然后正面朝上获得你的一张手牌。若此牌花色与该角色所选花色不同,你对其造成1点伤害。", } local guose = fk.CreateViewAsSkill{ @@ -793,7 +819,9 @@ daqiao:addSkill(liuli) Fk:loadTranslationTable{ ["daqiao"] = "大乔", ["guose"] = "国色", + [":guose"] = "你可以将一张方块牌当【乐不思蜀】使用。", ["liuli"] = "流离", + [":liuli"] = "每当你成为【杀】的目标时,你可以弃置一张牌并选择你攻击范围内为此【杀】合法目标(无距离限制)的一名角色:若如此做,该角色代替你成为此【杀】的目标。", } local qianxun = fk.CreateProhibitSkill{ @@ -831,7 +859,9 @@ luxun:addSkill(lianying) Fk:loadTranslationTable{ ["luxun"] = "陆逊", ["qianxun"] = "谦逊", + [":qianxun"] = "锁定技,你不能被选择为【顺手牵羊】与【乐不思蜀】的目标。", ["lianying"] = "连营", + [":lianying"] = "每当你失去最后的手牌后,你可以摸一张牌。", } local xiaoji = fk.CreateTriggerSkill{ @@ -882,18 +912,18 @@ local jieyin = fk.CreateActiveSkill{ feasible = function(self, selected, selected_cards) return #selected == 1 and #selected_cards == 2 end, - on_effect = function(self, room, effect) + on_use = function(self, room, effect) local from = room:getPlayerById(effect.from) room:throwCard(effect.cards, self.name, from) room:recover({ - who = effect.tos[1], + who = room:getPlayerById(effect.tos[1]), num = 1, recoverBy = effect.from, skillName = self.name }) if from:isWounded() then room:recover({ - who = effect.from, + who = room:getPlayerById(effect.from), num = 1, recoverBy = effect.from, skillName = self.name @@ -907,7 +937,9 @@ sunshangxiang:addSkill(jieyin) Fk:loadTranslationTable{ ["sunshangxiang"] = "孙尚香", ["xiaoji"] = "枭姬", + [":xiaoji"] = "每当你失去一张装备区的装备牌后,你可以摸两张牌。", ["jieyin"] = "结姻", + [":jieyin"] = "阶段技,你可以弃置两张手牌并选择一名已受伤的男性角色:若如此做,你和该角色各回复1点体力。", } local qingnang = fk.CreateActiveSkill{ @@ -925,11 +957,11 @@ local qingnang = fk.CreateActiveSkill{ feasible = function(self, targets, cards) return #targets == 1 and #cards == 1 end, - on_effect = function(self, room, effect) + on_use = function(self, room, effect) local from = room:getPlayerById(effect.from) room:throwCard(effect.cards, self.name, from) room:recover({ - who = effect.tos[1], + who = room:getPlayerById(effect.tos[1]), num = 1, recoverBy = effect.from, skillName = self.name @@ -965,7 +997,9 @@ huatuo:addSkill(jijiu) Fk:loadTranslationTable{ ["huatuo"] = "华佗", ["qingnang"] = "青囊", + [":qingnang"] = "阶段技,你可以弃置一张手牌并选择一名已受伤的角色:若如此做,该角色回复1点体力。", ["jijiu"] = "急救", + [":jijiu"] = "你的回合外,你可以将一张红色牌当【桃】使用。", } local lvbu = General:new(extension, "lvbu", "qun", 4) @@ -990,6 +1024,7 @@ diaochan:addSkill(biyue) Fk:loadTranslationTable{ ["diaochan"] = "貂蝉", ["biyue"] = "闭月", + [":biyue"] = "结束阶段开始时,你可以摸一张牌。", } return extension diff --git a/audio/card/female/amazing_grace.mp3 b/packages/standard_cards/audio/card/female/amazing_grace.mp3 similarity index 100% rename from audio/card/female/amazing_grace.mp3 rename to packages/standard_cards/audio/card/female/amazing_grace.mp3 diff --git a/audio/card/female/archery_attack.mp3 b/packages/standard_cards/audio/card/female/archery_attack.mp3 similarity index 100% rename from audio/card/female/archery_attack.mp3 rename to packages/standard_cards/audio/card/female/archery_attack.mp3 diff --git a/audio/card/female/collateral.mp3 b/packages/standard_cards/audio/card/female/collateral.mp3 similarity index 100% rename from audio/card/female/collateral.mp3 rename to packages/standard_cards/audio/card/female/collateral.mp3 diff --git a/audio/card/female/dismantlement.mp3 b/packages/standard_cards/audio/card/female/dismantlement.mp3 similarity index 100% rename from audio/card/female/dismantlement.mp3 rename to packages/standard_cards/audio/card/female/dismantlement.mp3 diff --git a/audio/card/female/duel.mp3 b/packages/standard_cards/audio/card/female/duel.mp3 similarity index 100% rename from audio/card/female/duel.mp3 rename to packages/standard_cards/audio/card/female/duel.mp3 diff --git a/audio/card/female/ex_nihilo.mp3 b/packages/standard_cards/audio/card/female/ex_nihilo.mp3 similarity index 100% rename from audio/card/female/ex_nihilo.mp3 rename to packages/standard_cards/audio/card/female/ex_nihilo.mp3 diff --git a/audio/card/female/god_salvation.mp3 b/packages/standard_cards/audio/card/female/god_salvation.mp3 similarity index 100% rename from audio/card/female/god_salvation.mp3 rename to packages/standard_cards/audio/card/female/god_salvation.mp3 diff --git a/audio/card/female/indulgence.mp3 b/packages/standard_cards/audio/card/female/indulgence.mp3 similarity index 100% rename from audio/card/female/indulgence.mp3 rename to packages/standard_cards/audio/card/female/indulgence.mp3 diff --git a/audio/card/female/jink.mp3 b/packages/standard_cards/audio/card/female/jink.mp3 similarity index 100% rename from audio/card/female/jink.mp3 rename to packages/standard_cards/audio/card/female/jink.mp3 diff --git a/audio/card/female/lightning.mp3 b/packages/standard_cards/audio/card/female/lightning.mp3 similarity index 100% rename from audio/card/female/lightning.mp3 rename to packages/standard_cards/audio/card/female/lightning.mp3 diff --git a/audio/card/female/nullification.mp3 b/packages/standard_cards/audio/card/female/nullification.mp3 similarity index 100% rename from audio/card/female/nullification.mp3 rename to packages/standard_cards/audio/card/female/nullification.mp3 diff --git a/audio/card/female/peach.mp3 b/packages/standard_cards/audio/card/female/peach.mp3 similarity index 100% rename from audio/card/female/peach.mp3 rename to packages/standard_cards/audio/card/female/peach.mp3 diff --git a/audio/card/female/savage_assault.mp3 b/packages/standard_cards/audio/card/female/savage_assault.mp3 similarity index 100% rename from audio/card/female/savage_assault.mp3 rename to packages/standard_cards/audio/card/female/savage_assault.mp3 diff --git a/audio/card/female/slash.mp3 b/packages/standard_cards/audio/card/female/slash.mp3 similarity index 100% rename from audio/card/female/slash.mp3 rename to packages/standard_cards/audio/card/female/slash.mp3 diff --git a/audio/card/female/snatch.mp3 b/packages/standard_cards/audio/card/female/snatch.mp3 similarity index 100% rename from audio/card/female/snatch.mp3 rename to packages/standard_cards/audio/card/female/snatch.mp3 diff --git a/audio/card/male/amazing_grace.mp3 b/packages/standard_cards/audio/card/male/amazing_grace.mp3 similarity index 100% rename from audio/card/male/amazing_grace.mp3 rename to packages/standard_cards/audio/card/male/amazing_grace.mp3 diff --git a/audio/card/male/archery_attack.mp3 b/packages/standard_cards/audio/card/male/archery_attack.mp3 similarity index 100% rename from audio/card/male/archery_attack.mp3 rename to packages/standard_cards/audio/card/male/archery_attack.mp3 diff --git a/audio/card/male/collateral.mp3 b/packages/standard_cards/audio/card/male/collateral.mp3 similarity index 100% rename from audio/card/male/collateral.mp3 rename to packages/standard_cards/audio/card/male/collateral.mp3 diff --git a/audio/card/male/dismantlement.mp3 b/packages/standard_cards/audio/card/male/dismantlement.mp3 similarity index 100% rename from audio/card/male/dismantlement.mp3 rename to packages/standard_cards/audio/card/male/dismantlement.mp3 diff --git a/audio/card/male/duel.mp3 b/packages/standard_cards/audio/card/male/duel.mp3 similarity index 100% rename from audio/card/male/duel.mp3 rename to packages/standard_cards/audio/card/male/duel.mp3 diff --git a/audio/card/male/ex_nihilo.mp3 b/packages/standard_cards/audio/card/male/ex_nihilo.mp3 similarity index 100% rename from audio/card/male/ex_nihilo.mp3 rename to packages/standard_cards/audio/card/male/ex_nihilo.mp3 diff --git a/audio/card/male/god_salvation.mp3 b/packages/standard_cards/audio/card/male/god_salvation.mp3 similarity index 100% rename from audio/card/male/god_salvation.mp3 rename to packages/standard_cards/audio/card/male/god_salvation.mp3 diff --git a/audio/card/male/indulgence.mp3 b/packages/standard_cards/audio/card/male/indulgence.mp3 similarity index 100% rename from audio/card/male/indulgence.mp3 rename to packages/standard_cards/audio/card/male/indulgence.mp3 diff --git a/audio/card/male/jink.mp3 b/packages/standard_cards/audio/card/male/jink.mp3 similarity index 100% rename from audio/card/male/jink.mp3 rename to packages/standard_cards/audio/card/male/jink.mp3 diff --git a/audio/card/male/lightning.mp3 b/packages/standard_cards/audio/card/male/lightning.mp3 similarity index 100% rename from audio/card/male/lightning.mp3 rename to packages/standard_cards/audio/card/male/lightning.mp3 diff --git a/audio/card/male/nullification.mp3 b/packages/standard_cards/audio/card/male/nullification.mp3 similarity index 100% rename from audio/card/male/nullification.mp3 rename to packages/standard_cards/audio/card/male/nullification.mp3 diff --git a/audio/card/male/peach.mp3 b/packages/standard_cards/audio/card/male/peach.mp3 similarity index 100% rename from audio/card/male/peach.mp3 rename to packages/standard_cards/audio/card/male/peach.mp3 diff --git a/audio/card/male/savage_assault.mp3 b/packages/standard_cards/audio/card/male/savage_assault.mp3 similarity index 100% rename from audio/card/male/savage_assault.mp3 rename to packages/standard_cards/audio/card/male/savage_assault.mp3 diff --git a/audio/card/male/slash.mp3 b/packages/standard_cards/audio/card/male/slash.mp3 similarity index 100% rename from audio/card/male/slash.mp3 rename to packages/standard_cards/audio/card/male/slash.mp3 diff --git a/audio/card/male/snatch.mp3 b/packages/standard_cards/audio/card/male/snatch.mp3 similarity index 100% rename from audio/card/male/snatch.mp3 rename to packages/standard_cards/audio/card/male/snatch.mp3 diff --git a/image/card/amazing_grace.png b/packages/standard_cards/image/card/amazing_grace.png similarity index 100% rename from image/card/amazing_grace.png rename to packages/standard_cards/image/card/amazing_grace.png diff --git a/image/card/archery_attack.png b/packages/standard_cards/image/card/archery_attack.png similarity index 100% rename from image/card/archery_attack.png rename to packages/standard_cards/image/card/archery_attack.png diff --git a/image/card/axe.png b/packages/standard_cards/image/card/axe.png similarity index 100% rename from image/card/axe.png rename to packages/standard_cards/image/card/axe.png diff --git a/image/card/blade.png b/packages/standard_cards/image/card/blade.png similarity index 100% rename from image/card/blade.png rename to packages/standard_cards/image/card/blade.png diff --git a/image/card/chitu.png b/packages/standard_cards/image/card/chitu.png similarity index 100% rename from image/card/chitu.png rename to packages/standard_cards/image/card/chitu.png diff --git a/image/card/collateral.png b/packages/standard_cards/image/card/collateral.png similarity index 100% rename from image/card/collateral.png rename to packages/standard_cards/image/card/collateral.png diff --git a/image/card/crossbow.png b/packages/standard_cards/image/card/crossbow.png similarity index 100% rename from image/card/crossbow.png rename to packages/standard_cards/image/card/crossbow.png diff --git a/image/card/dayuan.png b/packages/standard_cards/image/card/dayuan.png similarity index 100% rename from image/card/dayuan.png rename to packages/standard_cards/image/card/dayuan.png diff --git a/image/card/dilu.png b/packages/standard_cards/image/card/dilu.png similarity index 100% rename from image/card/dilu.png rename to packages/standard_cards/image/card/dilu.png diff --git a/image/card/dismantlement.png b/packages/standard_cards/image/card/dismantlement.png similarity index 100% rename from image/card/dismantlement.png rename to packages/standard_cards/image/card/dismantlement.png diff --git a/image/card/double_swords.png b/packages/standard_cards/image/card/double_swords.png similarity index 100% rename from image/card/double_swords.png rename to packages/standard_cards/image/card/double_swords.png diff --git a/image/card/duel.png b/packages/standard_cards/image/card/duel.png similarity index 100% rename from image/card/duel.png rename to packages/standard_cards/image/card/duel.png diff --git a/image/card/eight_diagram.png b/packages/standard_cards/image/card/eight_diagram.png similarity index 100% rename from image/card/eight_diagram.png rename to packages/standard_cards/image/card/eight_diagram.png diff --git a/image/card/ex_nihilo.png b/packages/standard_cards/image/card/ex_nihilo.png similarity index 100% rename from image/card/ex_nihilo.png rename to packages/standard_cards/image/card/ex_nihilo.png diff --git a/image/card/god_salvation.png b/packages/standard_cards/image/card/god_salvation.png similarity index 100% rename from image/card/god_salvation.png rename to packages/standard_cards/image/card/god_salvation.png diff --git a/image/card/halberd.png b/packages/standard_cards/image/card/halberd.png similarity index 100% rename from image/card/halberd.png rename to packages/standard_cards/image/card/halberd.png diff --git a/image/card/hualiu.png b/packages/standard_cards/image/card/hualiu.png similarity index 100% rename from image/card/hualiu.png rename to packages/standard_cards/image/card/hualiu.png diff --git a/image/card/ice_sword.png b/packages/standard_cards/image/card/ice_sword.png similarity index 100% rename from image/card/ice_sword.png rename to packages/standard_cards/image/card/ice_sword.png diff --git a/image/card/indulgence.png b/packages/standard_cards/image/card/indulgence.png similarity index 100% rename from image/card/indulgence.png rename to packages/standard_cards/image/card/indulgence.png diff --git a/image/card/jink.png b/packages/standard_cards/image/card/jink.png similarity index 100% rename from image/card/jink.png rename to packages/standard_cards/image/card/jink.png diff --git a/image/card/jueying.png b/packages/standard_cards/image/card/jueying.png similarity index 100% rename from image/card/jueying.png rename to packages/standard_cards/image/card/jueying.png diff --git a/image/card/kylin_bow.png b/packages/standard_cards/image/card/kylin_bow.png similarity index 100% rename from image/card/kylin_bow.png rename to packages/standard_cards/image/card/kylin_bow.png diff --git a/image/card/lightning.png b/packages/standard_cards/image/card/lightning.png similarity index 100% rename from image/card/lightning.png rename to packages/standard_cards/image/card/lightning.png diff --git a/image/card/nioh_shield.png b/packages/standard_cards/image/card/nioh_shield.png similarity index 100% rename from image/card/nioh_shield.png rename to packages/standard_cards/image/card/nioh_shield.png diff --git a/image/card/nullification.png b/packages/standard_cards/image/card/nullification.png similarity index 100% rename from image/card/nullification.png rename to packages/standard_cards/image/card/nullification.png diff --git a/image/card/peach.png b/packages/standard_cards/image/card/peach.png similarity index 100% rename from image/card/peach.png rename to packages/standard_cards/image/card/peach.png diff --git a/image/card/qinggang_sword.png b/packages/standard_cards/image/card/qinggang_sword.png similarity index 100% rename from image/card/qinggang_sword.png rename to packages/standard_cards/image/card/qinggang_sword.png diff --git a/image/card/savage_assault.png b/packages/standard_cards/image/card/savage_assault.png similarity index 100% rename from image/card/savage_assault.png rename to packages/standard_cards/image/card/savage_assault.png diff --git a/image/card/slash.png b/packages/standard_cards/image/card/slash.png similarity index 100% rename from image/card/slash.png rename to packages/standard_cards/image/card/slash.png diff --git a/image/card/snatch.png b/packages/standard_cards/image/card/snatch.png similarity index 100% rename from image/card/snatch.png rename to packages/standard_cards/image/card/snatch.png diff --git a/image/card/spear.png b/packages/standard_cards/image/card/spear.png similarity index 100% rename from image/card/spear.png rename to packages/standard_cards/image/card/spear.png diff --git a/image/card/zhuahuangfeidian.png b/packages/standard_cards/image/card/zhuahuangfeidian.png similarity index 100% rename from image/card/zhuahuangfeidian.png rename to packages/standard_cards/image/card/zhuahuangfeidian.png diff --git a/image/card/zixing.png b/packages/standard_cards/image/card/zixing.png similarity index 100% rename from image/card/zixing.png rename to packages/standard_cards/image/card/zixing.png diff --git a/packages/standard_cards/init.lua b/packages/standard_cards/init.lua index c4d98e31..43742318 100644 --- a/packages/standard_cards/init.lua +++ b/packages/standard_cards/init.lua @@ -5,6 +5,20 @@ Fk:loadTranslationTable{ ["standard_cards"] = "标+EX" } +Fk:loadTranslationTable{ + ["unknown_card"] = '未知牌', + ["log_spade"] = "♠", + ["log_heart"] = '', + ["log_club"] = "♣", + ["log_diamond"] = '', + ["log_nosuit"] = "无花色", + ["nosuit"] = "无花色", + ["spade"] = "黑桃", + ["heart"] = "红桃", + ["club"] = "梅花", + ["diamond"] = "方块", +} + local slashSkill = fk.CreateActiveSkill{ name = "slash_skill", max_phase_use_time = 1, @@ -26,8 +40,8 @@ local slashSkill = fk.CreateActiveSkill{ local from = effect.from room:damage({ - from = from, - to = to, + from = room:getPlayerById(from), + to = room:getPlayerById(to), card = effect.card, damage = 1 + (effect.addtionalDamage or 0), damageType = fk.NormalDamage, @@ -137,7 +151,7 @@ local peachSkill = fk.CreateActiveSkill{ local from = effect.from room:recover({ - who = to, + who = room:getPlayerById(to), num = 1, recoverBy = from, skillName = self.name @@ -299,8 +313,8 @@ local duelSkill = fk.CreateActiveSkill{ if currentResponser:isAlive() then room:damage({ - from = responsers[currentTurn % 2 + 1].id, - to = currentResponser.id, + from = responsers[currentTurn % 2 + 1], + to = currentResponser, card = effect.card, damage = 1 + (effect.addtionalDamage or 0), damageType = fk.NormalDamage, @@ -453,8 +467,8 @@ local savageAssaultSkill = fk.CreateActiveSkill{ }) else room:damage({ - from = effect.from, - to = effect.to, + from = room:getPlayerById(effect.from), + to = room:getPlayerById(effect.to), card = effect.card, damage = 1 + (effect.addtionalDamage or 0), damageType = fk.NormalDamage, @@ -503,8 +517,8 @@ local archeryAttackSkill = fk.CreateActiveSkill{ }) else room:damage({ - from = effect.from, - to = effect.to, + from = room:getPlayerById(effect.from), + to = room:getPlayerById(effect.to), card = effect.card, damage = 1 + (effect.addtionalDamage or 0), damageType = fk.NormalDamage, @@ -537,9 +551,14 @@ local godSalvationSkill = fk.CreateActiveSkill{ end end end, - on_effect = function(self, room, cardEffectEvent) + about_to_effect = function(self, room, effect) + if not room:getPlayerById(effect.to):isWounded() then + return true + end + end, + on_effect = function(self, room, effect) room:recover({ - who = cardEffectEvent.to, + who = room:getPlayerById(effect.to), num = 1, skillName = self.name, }) @@ -609,7 +628,7 @@ local lightningSkill = fk.CreateActiveSkill{ local result = judge.card if result.suit == Card.Spade and result.number >= 2 and result.number <= 9 then room:damage{ - to = to.id, + to = to, damage = 3, card = effect.card, damageType = fk.ThunderDamage, @@ -942,8 +961,8 @@ extension:addCards({ local ziXing = fk.CreateOffensiveRide{ name = "zixing", - suit = Card.Heart, - number = 5, + suit = Card.Diamond, + number = 13, } Fk:loadTranslationTable{ ["zixing"] = "紫骍", diff --git a/packages/test/.gitignore b/packages/test/.gitignore new file mode 100644 index 00000000..17f35263 --- /dev/null +++ b/packages/test/.gitignore @@ -0,0 +1,2 @@ +test.lua +test-error.txt diff --git a/packages/test/init.lua b/packages/test/init.lua new file mode 100644 index 00000000..4aab2c44 --- /dev/null +++ b/packages/test/init.lua @@ -0,0 +1,22 @@ +local fkp_extensions = require "packages.test.test" +local extension = fkp_extensions[1] + +local test_filter = fk.CreateFilterSkill{ + name = "test_filter", + card_filter = function(self, card) + return true + end, + view_as = function(self, card) + return Fk:cloneCard("ex_nihilo", card.suit, card.number) + end, +} +local test2 = General(extension, "mouxusheng", "wu", 4) +test2:addSkill(test_filter) + +Fk:loadTranslationTable{ + ["test"] = "测试", + ["test_filter"] = "破军", + ["mouxusheng"] = "谋徐盛", +} + +return fkp_extensions diff --git a/packages/test/test.fkp b/packages/test/test.fkp new file mode 100644 index 00000000..cef6df72 --- /dev/null +++ b/packages/test/test.fkp @@ -0,0 +1,35 @@ +拓展包 '测试包' + +$ '伤摸' "你造成伤害后可以摸5张牌。" + 触发技 + 时机:造成伤害后 + 效果:你摸5张牌 +以上 + +$ '苦肉' “你可以失去一点体力摸3张牌” + 主动技 + 条件:返回真 + 选牌规则:返回假 + 选目标规则:返回假 + 可以点确定:返回真 + 使用后:你失去1点体力,你摸3张牌 +以上 + +$ '倾国' "可以将牌当决斗使用打出" + 视为技 + 条件: 返回真 + 选牌规则: 若'已选卡牌'."长度"是0,则返回真以上。 + 可以点确定: 若'已选卡牌'."长度"是1,则返回真,以上。 + 视为规则: 返回'创建虚拟牌'(0, '无花色', '决斗', '选择的卡牌', "倾国") + 响应条件: 返回真 + 响应规则: [ '决斗' ] +以上 + +$ '生有' “你的小于4的牌视为无中生有” + 状态技 + 选牌规则:返回'备选卡牌'."点数" < 4 + 视为规则:返回‘创建虚拟牌’('备选卡牌'."点数", '备选卡牌'."花色", '无中生有') + 出牌次数修正:若‘卡牌’.“牌名”是'杀',则返回999,以上 +end + +# 魏 "大魏吴王" '魏孙权' 4 [ "伤摸", "苦肉", "倾国", "生有" ] diff --git a/qml/Config.qml b/qml/Config.qml index d05ba443..1386ee65 100644 --- a/qml/Config.qml +++ b/qml/Config.qml @@ -7,6 +7,9 @@ QtObject { property var conf: ({}) property string lastLoginServer property var savedPassword: ({}) + property string lobbyBg + property string roomBg + property string bgmFile // Player property of client property string serverAddr @@ -17,13 +20,18 @@ QtObject { // Client data property int roomCapacity: 0 property int roomTimeout: 0 + property bool enableFreeAssign: false + property bool observing: false function loadConf() { conf = JSON.parse(Backend.loadConf()); - winWidth = conf.winWidth; - winHeight = conf.winHeight; - lastLoginServer = conf.lastLoginServer; - savedPassword = conf.savedPassword; + winWidth = conf.winWidth || 960; + winHeight = conf.winHeight || 540; + lastLoginServer = conf.lastLoginServer || "127.0.0.1"; + savedPassword = conf.savedPassword || {}; + lobbyBg = conf.lobbyBg || AppPath + "/image/background"; + roomBg = conf.roomBg || AppPath + "/image/gamebg"; + bgmFile = conf.bgmFile || AppPath + "/audio/system/bgm.mp3"; } function saveConf() { @@ -31,6 +39,9 @@ QtObject { conf.winHeight = realMainWin.height; conf.lastLoginServer = lastLoginServer; conf.savedPassword = savedPassword; + conf.lobbyBg = lobbyBg; + conf.roomBg = roomBg; + conf.bgmFile = bgmFile; Backend.saveConf(JSON.stringify(conf, undefined, 2)); } diff --git a/qml/Logic.js b/qml/Logic.js index 9e081ac1..77ac58fd 100644 --- a/qml/Logic.js +++ b/qml/Logic.js @@ -38,6 +38,15 @@ callbacks["ErrorMsg"] = function(jsonData) { mainWindow.busy = false; } +callbacks["UpdateBusyText"] = function(jsonData) { + mainWindow.busyText = jsonData; +} + +callbacks["DownloadComplete"] = function() { + mainWindow.busy = false; + mainStack.currentItem.downloadComplete(); // should be pacman page +} + callbacks["BackToStart"] = function(jsonData) { while (mainStack.depth > 1) { mainStack.pop(); @@ -67,6 +76,8 @@ callbacks["EnterRoom"] = function(jsonData) { let data = JSON.parse(jsonData); config.roomCapacity = data[0]; config.roomTimeout = data[1] - 1; + let roomSettings = data[2]; + config.enableFreeAssign = roomSettings.enableFreeAssign; mainStack.push(room); mainWindow.busy = false; } diff --git a/qml/Pages/About.qml b/qml/Pages/About.qml index 5b45d9b6..87b69fc8 100644 --- a/qml/Pages/About.qml +++ b/qml/Pages/About.qml @@ -13,6 +13,7 @@ Item { ListElement { dest: "gplv3" } ListElement { dest: "sqlite" } ListElement { dest: "ossl" } + ListElement { dest: "git2" } } ColumnLayout { diff --git a/qml/Pages/Common/LogEdit.qml b/qml/Pages/Common/LogEdit.qml index 84e57283..00bc58fb 100644 --- a/qml/Pages/Common/LogEdit.qml +++ b/qml/Pages/Common/LogEdit.qml @@ -29,6 +29,7 @@ Flickable { selectByMouse: true wrapMode: TextEdit.WrapAnywhere textFormat: TextEdit.RichText + font.pixelSize: 16 } function append(text) { diff --git a/qml/Pages/GeneralsOverview.qml b/qml/Pages/GeneralsOverview.qml index 55f2f038..3c9a558d 100644 --- a/qml/Pages/GeneralsOverview.qml +++ b/qml/Pages/GeneralsOverview.qml @@ -26,6 +26,11 @@ Item { GeneralCardItem { autoBack: false name: modelData + onClicked: { + generalText.clear(); + generalText.general = modelData; + generalDetail.open(); + } } } } @@ -40,6 +45,50 @@ Item { } } + Drawer { + id: generalDetail + edge: Qt.RightEdge + width: parent.width * 0.4 / mainWindow.scale + height: parent.height / mainWindow.scale + dim: false + clip: true + dragMargin: 0 + scale: mainWindow.scale + transformOrigin: Item.TopRight + + Flickable { + flickableDirection: Flickable.VerticalFlick + contentWidth: generalText.width + contentHeight: generalText.height + width: parent.width * 0.8 + height: parent.height * 0.8 + clip: true + anchors.centerIn: parent + ScrollBar.vertical: ScrollBar {} + + TextEdit { + id: generalText + + property string general: "" + width: generalDetail.width * 0.75 + readOnly: true + selectByKeyboard: true + selectByMouse: true + wrapMode: TextEdit.WordWrap + textFormat: TextEdit.RichText + font.pixelSize: 16 + + onGeneralChanged: { + let data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general])); + this.append(Backend.translate(data.kingdom) + " " + Backend.translate(general) + " " + data.hp + "/" + data.maxHp); + data.skill.forEach(t => { + this.append("" + Backend.translate(t.name) + ": " + t.description) + }); + } + } + } + } + function loadPackages() { if (loaded) return; let packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", [])); diff --git a/qml/Pages/Init.qml b/qml/Pages/Init.qml index bdf0f544..0d3bb86e 100644 --- a/qml/Pages/Init.qml +++ b/qml/Pages/Init.qml @@ -3,11 +3,11 @@ import QtQuick.Controls Item { id: root - scale: 2 Frame { id: join_server anchors.centerIn: parent + scale: 1.5 background: Rectangle { color: "#88888888" radius: 2 @@ -81,6 +81,15 @@ Item { } } + Button { + anchors.right: parent.right + anchors.bottom: parent.bottom + text: qsTr("PackageManage") + onClicked: { + mainStack.push(packageManage); + } + } + Component.onCompleted: { config.loadConf(); server_addr.model = Object.keys(config.savedPassword); diff --git a/qml/Pages/Lobby.qml b/qml/Pages/Lobby.qml index a6002afa..9df7b645 100644 --- a/qml/Pages/Lobby.qml +++ b/qml/Pages/Lobby.qml @@ -11,32 +11,9 @@ Item { id: roomDelegate Item { - height: 18 + height: 22 width: roomList.width - Rectangle { - anchors.fill: parent - color: "white" - opacity: 0 - radius: 2 - Behavior on opacity { - NumberAnimation { duration: 300; easing.type: Easing.InOutQuad } - } - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: parent.opacity = 1; - onExited: parent.opacity = 0; - onClicked: { - mainWindow.busy = true; - ClientInstance.notifyServer( - "EnterRoom", - JSON.stringify([roomId]) - ); - } - } - } - RowLayout { anchors.fill: parent spacing: 16 @@ -58,6 +35,38 @@ Item { color: (playerNum == capacity) ? "red" : "black" text: playerNum + "/" + capacity } + + Text { + text: Backend.translate("Enter") + font.pixelSize: 24 + MouseArea { + anchors.fill: parent + onClicked: { + config.observing = false; + mainWindow.busy = true; + ClientInstance.notifyServer( + "EnterRoom", + JSON.stringify([roomId]) + ); + } + } + } + + Text { + text: Backend.translate("Observe") + font.pixelSize: 24 + MouseArea { + anchors.fill: parent + onClicked: { + config.observing = true; + mainWindow.busy = true; + ClientInstance.notifyServer( + "ObserveRoom", + JSON.stringify([roomId]) + ); + } + } + } } } } @@ -102,16 +111,16 @@ Item { iconSource: "configure" text: Backend.translate("Edit Profile") onClicked: { - globalPopup.source = "EditProfile.qml"; - globalPopup.open(); + lobby_dialog.source = "LobbyElement/EditProfile.qml"; + lobby_drawer.open(); } } TileButton { iconSource: "create_room" text: Backend.translate("Create Room") onClicked: { - globalPopup.source = "CreateRoom.qml"; - globalPopup.open(); + lobby_dialog.source = "LobbyElement/CreateRoom.qml"; + lobby_drawer.open(); } } TileButton { @@ -157,28 +166,27 @@ Item { } } - Loader { - id: lobby_dialog - z: 1000 - onSourceChanged: { - if (item === null) - return; - item.finished.connect(function(){ - source = ""; - }); - item.widthChanged.connect(function(){ - lobby_dialog.moveToCenter(); - }); - item.heightChanged.connect(function(){ - lobby_dialog.moveToCenter(); - }); - moveToCenter(); - } + Drawer { + id: lobby_drawer + width: parent.width * 0.4 / mainWindow.scale + height: parent.height / mainWindow.scale + dim: false + clip: true + dragMargin: 0 + scale: mainWindow.scale + transformOrigin: Item.TopLeft - function moveToCenter() - { - item.x = Math.round((root.width - item.width) / 2); - item.y = Math.round(root.height * 0.67 - item.height / 2); + Loader { + id: lobby_dialog + anchors.centerIn: parent + onSourceChanged: { + if (item === null) + return; + item.finished.connect(() => { + source = ""; + lobby_drawer.close(); + }); + } } } diff --git a/qml/GlobalPopups/CreateRoom.qml b/qml/Pages/LobbyElement/CreateRoom.qml similarity index 80% rename from qml/GlobalPopups/CreateRoom.qml rename to qml/Pages/LobbyElement/CreateRoom.qml index 52cfed29..486588aa 100644 --- a/qml/GlobalPopups/CreateRoom.qml +++ b/qml/Pages/LobbyElement/CreateRoom.qml @@ -39,6 +39,12 @@ Item { } } + CheckBox { + id: freeAssignCheck + checked: Debugging ? true : false + text: Backend.translate("Enable free assign") + } + RowLayout { anchors.rightMargin: 8 spacing: 16 @@ -49,7 +55,9 @@ Item { mainWindow.busy = true; ClientInstance.notifyServer( "CreateRoom", - JSON.stringify([roomName.text, playerNum.value]) + JSON.stringify([roomName.text, playerNum.value, { + enableFreeAssign: freeAssignCheck.checked + }]) ); } } diff --git a/qml/GlobalPopups/EditProfile.qml b/qml/Pages/LobbyElement/EditProfile.qml similarity index 60% rename from qml/GlobalPopups/EditProfile.qml rename to qml/Pages/LobbyElement/EditProfile.qml index 0611ec77..d79341ff 100644 --- a/qml/GlobalPopups/EditProfile.qml +++ b/qml/Pages/LobbyElement/EditProfile.qml @@ -1,6 +1,7 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.0 -import QtQuick.Layouts 1.15 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Dialogs Item { id: root @@ -36,6 +37,17 @@ Item { font.pixelSize: 18 text: Self.avatar } + Button { + text: Backend.translate("Update Avatar") + enabled: avatarName.text !== "" + onClicked: { + mainWindow.busy = true; + ClientInstance.notifyServer( + "UpdateAvatar", + JSON.stringify([avatarName.text]) + ); + } + } } RowLayout { @@ -62,22 +74,6 @@ Item { echoMode: TextInput.Password passwordCharacter: "*" } - } - - RowLayout { - anchors.rightMargin: 8 - spacing: 16 - Button { - text: Backend.translate("Update Avatar") - enabled: avatarName.text !== "" - onClicked: { - mainWindow.busy = true; - ClientInstance.notifyServer( - "UpdateAvatar", - JSON.stringify([avatarName.text]) - ); - } - } Button { text: Backend.translate("Update Password") enabled: oldPassword.text !== "" && newPassword.text !== "" @@ -89,12 +85,69 @@ Item { ); } } + } + + RowLayout { + anchors.rightMargin: 8 + spacing: 16 + Text { + text: Backend.translate("Lobby BG") + } + TextField { + text: config.lobbyBg + } Button { - text: Backend.translate("Quit") + text: "..." onClicked: { - root.finished(); + fdialog.nameFilters = ["Image Files (*.jpg *.png)"]; + fdialog.configKey = "lobbyBg"; + fdialog.open(); + } + } + } + + RowLayout { + anchors.rightMargin: 8 + spacing: 16 + Text { + text: Backend.translate("Room BG") + } + TextField { + text: config.roomBg + } + Button { + text: "..." + onClicked: { + fdialog.nameFilters = ["Image Files (*.jpg *.png)"]; + fdialog.configKey = "roomBg"; + fdialog.open(); + } + } + } + + RowLayout { + anchors.rightMargin: 8 + spacing: 16 + Text { + text: Backend.translate("Game BGM") + } + TextField { + text: config.bgmFile + } + Button { + text: "..." + onClicked: { + fdialog.nameFilters = ["Music Files (*.mp3)"]; + fdialog.configKey = "bgmFile"; + fdialog.open(); } } } } + + FileDialog { + id: fdialog + property string configKey + onAccepted: { config[configKey] = selectedFile; } + } } diff --git a/qml/Pages/PackageManage.qml b/qml/Pages/PackageManage.qml new file mode 100644 index 00000000..4a08c93b --- /dev/null +++ b/qml/Pages/PackageManage.qml @@ -0,0 +1,217 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +Item { + id: root + Button { + text: qsTr("Quit") + anchors.right: parent.right + onClicked: { + mainStack.pop(); + } + } + + Component { + id: packageDelegate + + Item { + height: 22 + width: packageList.width + + RowLayout { + anchors.fill: parent + spacing: 16 + Text { + font.pixelSize: 20 + text: pkgName + } + + Text { + font.pixelSize: 20 + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + text: pkgURL + } + + Text { + font.pixelSize: 20 + text: pkgVersion + } + + Text { + font.pixelSize: 20 + color: pkgEnabled === "1" ? "green" : "red" + text: pkgEnabled === "1" ? qsTr("Enabled") : qsTr("Disabled") + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + if (packageList.currentIndex === index) { + packageList.currentIndex = -1; + } else { + packageList.currentIndex = index; + } + } + } + } + } + + ListModel { + id: packageModel + } + + ColumnLayout { + anchors.fill: parent + + RowLayout { + Layout.fillHeight: true + Layout.alignment: Qt.AlignHCenter + Item { + Layout.preferredWidth: root.width * 0.9 + Layout.fillHeight: true + Rectangle { + anchors.fill: parent + color: "#88888888" + } + ListView { + id: packageList + anchors.fill: parent + + contentHeight: packageDelegate.height * count + ScrollBar.vertical: ScrollBar {} + header: RowLayout { + height: 22 + width: packageList.width + spacing: 16 + Text { + font.pixelSize: 20 + text: qsTr("Name") + } + + Text { + font.pixelSize: 20 + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + text: "URL" + } + + Text { + font.pixelSize: 20 + text: qsTr("Version") + } + + Text { + font.pixelSize: 20 + text: qsTr("Enable") + } + } + delegate: packageDelegate + model: packageModel + highlight: Rectangle { color: "lightsteelblue"; radius: 5 } + Component.onCompleted: { currentIndex = -1; } + } + } + + ColumnLayout { + Button { + enabled: packageList.currentItem + text: qsTr("Enable") + onClicked: { + let idx = packageList.currentIndex; + let name = packageModel.get(idx).pkgName; + Pacman.enablePack(name); + updatePackageList(); + packageList.currentIndex = idx; + } + } + Button { + enabled: packageList.currentItem + text: qsTr("Disable") + onClicked: { + let idx = packageList.currentIndex; + let name = packageModel.get(idx).pkgName; + Pacman.disablePack(name); + updatePackageList(); + packageList.currentIndex = idx; + } + } + Button { + enabled: packageList.currentItem + text: qsTr("Upgrade") + onClicked: { + let idx = packageList.currentIndex; + let name = packageModel.get(idx).pkgName; + Pacman.upgradePack(name); + updatePackageList(); + packageList.currentIndex = idx; + } + } + Button { + enabled: packageList.currentItem + text: qsTr("Remove") + onClicked: { + let idx = packageList.currentIndex; + let name = packageModel.get(idx).pkgName; + Pacman.removePack(name); + updatePackageList(); + packageList.currentIndex = idx; + } + } + Button { + enabled: packageList.currentItem + text: qsTr("Copy URL") + onClicked: { + let idx = packageList.currentIndex; + let name = packageModel.get(idx).pkgURL; + Backend.copyToClipboard(name); + toast.show(qsTr("Copied.")); + } + } + } + } + + RowLayout { + Layout.fillWidth: true + TextField { + id: urlEdit + Layout.fillWidth: true + clip: true + } + + Button { + text: qsTr("Install From URL") + enabled: urlEdit.text !== "" + onClicked: { + let url = urlEdit.text; + mainWindow.busy = true; + Pacman.downloadNewPack(url, true); + } + } + } + + } + + function updatePackageList() { + packageModel.clear(); + let data = JSON.parse(Pacman.listPackages()); + data.forEach(e => packageModel.append({ + pkgName: e.name, + pkgURL: e.url, + pkgVersion: e.hash.substring(0, 8), + pkgEnabled: e.enabled + })); + } + + function downloadComplete() { + let idx = packageList.currentIndex; + updatePackageList(); + packageList.currentIndex = idx; + } + + Component.onCompleted: { + updatePackageList(); + } +} diff --git a/qml/Pages/Room.qml b/qml/Pages/Room.qml index 5e986afb..a80be8c5 100644 --- a/qml/Pages/Room.qml +++ b/qml/Pages/Room.qml @@ -31,14 +31,14 @@ Item { property var extra_data: ({}) Image { - source: AppPath + "/image/gamebg" + source: config.roomBg anchors.fill: parent fillMode: Image.PreserveAspectCrop } MediaPlayer { id: bgm - source: AppPath + "/audio/system/bgm.mp3" + source: config.bgmFile // loops: MediaPlayer.Infinite onPlaybackStateChanged: { @@ -264,6 +264,14 @@ Item { } } + GlowText { + text: Backend.translate("Observing ...") + visible: config.observing + color: "#4B83CD" + font.family: fontLi2.name + font.pixelSize: 48 + } + Item { id: controls anchors.bottom: dashboard.top @@ -390,11 +398,13 @@ Item { Drawer { id: roomDrawer - width: parent.width * 0.3 - height: parent.height + width: parent.width * 0.3 / mainWindow.scale + height: parent.height / mainWindow.scale dim: false clip: true dragMargin: 0 + scale: mainWindow.scale + transformOrigin: Item.TopLeft ColumnLayout { anchors.fill: parent @@ -433,6 +443,30 @@ Item { } } + Drawer { + id: cheatDrawer + edge: Qt.RightEdge + width: parent.width * 0.4 / mainWindow.scale + height: parent.height / mainWindow.scale + dim: false + clip: true + dragMargin: 0 + scale: mainWindow.scale + transformOrigin: Item.TopRight + + Loader { + id: cheatLoader + anchors.fill: parent + onSourceChanged: { + if (item === null) + return; + item.finish.connect(() => { + cheatDrawer.close(); + }); + } + } + } + Item { id: dynamicCardArea anchors.fill: parent @@ -514,9 +548,9 @@ Item { function addToChat(pid, raw, msg) { chat.append(msg); - let photo = Logic.getPhoto(pid); + let photo = Logic.getPhotoOrSelf(pid); if (photo === undefined) - photo = dashboard.self; + return; photo.chat(raw.msg); } @@ -536,6 +570,12 @@ Item { } } + function startCheat(source, data) { + cheatLoader.source = source; + cheatLoader.item.extra_data = data; + cheatDrawer.open(); + } + Component.onCompleted: { toast.show(Backend.translate("$EnterRoom")); diff --git a/qml/Pages/RoomElement/CardItem.qml b/qml/Pages/RoomElement/CardItem.qml index 6b46da29..19e74df0 100644 --- a/qml/Pages/RoomElement/CardItem.qml +++ b/qml/Pages/RoomElement/CardItem.qml @@ -21,6 +21,8 @@ Item { property string suit: "club" property int number: 7 property string name: "slash" + property string extension: "" + property string virt_name: "" property string subtype: "" property string color: "" // only use when suit is empty property string footnote: "" // footnote, e.g. "A use card to B" @@ -53,6 +55,7 @@ Item { signal toggleDiscards() signal clicked() + signal rightClicked() signal doubleClicked() signal thrown() signal released() @@ -74,7 +77,7 @@ Item { Image { id: cardItem - source: known ? (name != "" ? SkinBank.CARD_DIR + name : "") + source: known ? SkinBank.getCardPicture(cid) : (SkinBank.CARD_DIR + "card-back") anchors.fill: parent fillMode: Image.PreserveAspectCrop @@ -108,6 +111,17 @@ Item { x: 1 } + Rectangle { + visible: root.virt_name !== "" + width: parent.width + height: 14 + anchors.verticalCenter: parent.verticalCenter + Text { + anchors.centerIn: parent + text: Backend.translate(root.virt_name) + } + } + GlowText { id: footnoteItem text: footnote @@ -135,6 +149,7 @@ Item { MouseArea { anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton drag.target: draggable ? parent : undefined drag.axis: Drag.XAndYAxis hoverEnabled: true @@ -162,9 +177,17 @@ Item { } } - onClicked: { - selected = selectable ? !selected : false; - parent.clicked(); + onClicked: (mouse) => { + if (mouse.button == Qt.LeftButton) { + selected = selectable ? !selected : false; + parent.clicked(); + } else if (mouse.button === Qt.RightButton) { + parent.rightClicked(); + } + } + + onPressAndHold: { + parent.rightClicked(); } } diff --git a/qml/Pages/RoomElement/Cheat/FreeAssign.qml b/qml/Pages/RoomElement/Cheat/FreeAssign.qml new file mode 100644 index 00000000..b617e87f --- /dev/null +++ b/qml/Pages/RoomElement/Cheat/FreeAssign.qml @@ -0,0 +1,53 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +Item { + id: root + anchors.fill: parent + property var extra_data: ({}) + + signal finish() + + Flickable { + height: parent.height + width: generalButtons.width + anchors.centerIn: parent + contentHeight: generalButtons.height + ScrollBar.vertical: ScrollBar {} + ColumnLayout { + id: generalButtons + Repeater { + model: ListModel { + id: packages + } + + ColumnLayout { + Text { text: Backend.translate(name) } + GridLayout { + columns: 5 + Repeater { + model: JSON.parse(Backend.callLuaFunction("GetGenerals", [name])) + Button { + text: Backend.translate(modelData) + onClicked: { + extra_data.card.name = modelData; + root.finish(); + } + } + } + } + } + } + } + } + + function load() { + let packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", [])); + packs.forEach((name) => packages.append({ name: name })); + } + + Component.onCompleted: { + load(); + } +} diff --git a/qml/Pages/RoomElement/ChooseGeneralBox.qml b/qml/Pages/RoomElement/ChooseGeneralBox.qml index 67774100..0887aeb8 100644 --- a/qml/Pages/RoomElement/ChooseGeneralBox.qml +++ b/qml/Pages/RoomElement/ChooseGeneralBox.qml @@ -116,6 +116,11 @@ GraphicsBox { updatePosition(); } + onRightClicked: { + if (selectedItem.indexOf(this) === -1 && config.enableFreeAssign) + roomScene.startCheat("RoomElement/Cheat/FreeAssign.qml", { card: this }); + } + onReleased: { if (!isClicked) arrangeCards(); diff --git a/qml/Pages/RoomElement/GeneralCardItem.qml b/qml/Pages/RoomElement/GeneralCardItem.qml index 25f44844..ac32b15b 100644 --- a/qml/Pages/RoomElement/GeneralCardItem.qml +++ b/qml/Pages/RoomElement/GeneralCardItem.qml @@ -20,7 +20,7 @@ CardItem { suit: "" number: 0 footnote: "" - card.source: SkinBank.GENERAL_DIR + name + card.source: SkinBank.getGeneralPicture(name) glow.color: "white" //Engine.kingdomColor[kingdom] Image { diff --git a/qml/Pages/RoomElement/GraphicsBox.qml b/qml/Pages/RoomElement/GraphicsBox.qml index ae7c6b3a..70f6a94e 100644 --- a/qml/Pages/RoomElement/GraphicsBox.qml +++ b/qml/Pages/RoomElement/GraphicsBox.qml @@ -1,5 +1,4 @@ import QtQuick -import Qt5Compat.GraphicalEffects Item { property alias title: titleItem @@ -11,24 +10,13 @@ Item { Rectangle { id: background anchors.fill: parent - color: "#B0000000" + color: "#020302" + opacity: 0.8 radius: 5 border.color: "#A6967A" border.width: 1 } - DropShadow { - source: background - anchors.fill: background - color: "#B0000000" - radius: 5 - //samples: 12 - spread: 0.2 - horizontalOffset: 5 - verticalOffset: 4 - transparentBorder: true - } - Text { id: titleItem color: "#E4D5A0" diff --git a/qml/Pages/RoomElement/Photo.qml b/qml/Pages/RoomElement/Photo.qml index d5d937a9..b4e6f8bd 100644 --- a/qml/Pages/RoomElement/Photo.qml +++ b/qml/Pages/RoomElement/Photo.qml @@ -30,6 +30,7 @@ Item { property alias handcardArea: handcardAreaItem property alias equipArea: equipAreaItem + property alias markArea: markAreaItem property alias delayedTrickArea: delayedTrickAreaItem property alias specialArea: handcardAreaItem @@ -142,7 +143,7 @@ Item { smooth: true visible: false fillMode: Image.PreserveAspectCrop - source: (general != "") ? SkinBank.GENERAL_DIR + general : "" + source: (general != "") ? SkinBank.getGeneralPicture(general) : "" } Rectangle { @@ -203,6 +204,14 @@ Item { y: 139 } + MarkArea { + id: markAreaItem + + anchors.bottom: equipAreaItem.top + anchors.bottomMargin: -18 + x: 31 + } + Image { id: chain visible: root.chained diff --git a/qml/Pages/RoomElement/PhotoElement/DelayedTrickArea.qml b/qml/Pages/RoomElement/PhotoElement/DelayedTrickArea.qml index 9a999391..d10abfe4 100644 --- a/qml/Pages/RoomElement/PhotoElement/DelayedTrickArea.qml +++ b/qml/Pages/RoomElement/PhotoElement/DelayedTrickArea.qml @@ -38,11 +38,13 @@ Item { } inputs.forEach(card => { let v = JSON.parse(Backend.callLuaFunction("GetVirtualEquip", [parent.playerid, card.cid])); - console.log(JSON.stringify(v)); if (v !== null) { cards.append(v); } else { - cards.append(card); + cards.append({ + name: card.name, + cid: card.cid + }); } }); } diff --git a/qml/Pages/RoomElement/PhotoElement/MarkArea.qml b/qml/Pages/RoomElement/PhotoElement/MarkArea.qml new file mode 100644 index 00000000..fb4809c2 --- /dev/null +++ b/qml/Pages/RoomElement/PhotoElement/MarkArea.qml @@ -0,0 +1,73 @@ +import QtQuick +import QtQuick.Layouts + +Item { + id: root + width: 138 + height: markTxtList.height + + ListModel { + id: markList + } + + Rectangle { + anchors.bottom: parent.bottom + width: parent.width + height: parent.height + color: "#3C3229" + opacity: 0.8 + radius: 4 + border.color: "white" + border.width: 1 + } + + ColumnLayout { + id: markTxtList + x: 2 + spacing: 0 + Repeater { + model: markList + Item { + width: childrenRect.width + height: 22 + Text { + text: Backend.translate(mark_name) + ' ' + Backend.translate(mark_extra) + font.family: fontLibian.name + font.pixelSize: 22 + color: "white" + style: Text.Outline + textFormat: Text.RichText + } + + // TODO: for pile + // MouseArea { + // anchors.fill: parent + // } + } + } + } + + function setMark(mark, data) { + let i, modelItem; + for (i = 0; i < markList.count; i++) { + if (markList.get(i).mark_name === mark) { + modelItem = markList.get(i); + break; + } + } + if (modelItem) + modelItem.mark_extra = data; + else + markList.append({ mark_name: mark, mark_extra: data }); + } + + function removeMark(mark) { + let i, modelItem; + for (i = 0; i < markList.count; i++) { + if (markList.get(i).mark_name === mark) { + markList.remove(i, 1); + return; + } + } + } +} diff --git a/qml/Pages/RoomElement/PlayerCardBox.qml b/qml/Pages/RoomElement/PlayerCardBox.qml index a2c2813a..bb97e7b0 100644 --- a/qml/Pages/RoomElement/PlayerCardBox.qml +++ b/qml/Pages/RoomElement/PlayerCardBox.qml @@ -64,6 +64,7 @@ GraphicsBox { suit: "" number: 0 autoBack: false + known: false selectable: true onClicked: root.cardSelected(cid); } diff --git a/qml/Pages/RoomLogic.js b/qml/Pages/RoomLogic.js index 463566d3..e30a28e2 100644 --- a/qml/Pages/RoomLogic.js +++ b/qml/Pages/RoomLogic.js @@ -784,6 +784,18 @@ callbacks["WaitForNullification"] = function() { roomScene.state = "notactive"; } +callbacks["SetPlayerMark"] = function(jsonData) { + let data = JSON.parse(jsonData); + let player = getPhotoOrSelf(data[0]); + let mark = data[1]; + let value = data[2]; + if (value == 0) { + player.markArea.removeMark(mark); + } else { + player.markArea.setMark(mark, mark.startsWith("@@") ? "" : value); + } +} + callbacks["Animate"] = function(jsonData) { // jsonData: [Object object] let data = JSON.parse(jsonData); @@ -847,7 +859,13 @@ callbacks["LogEvent"] = function(jsonData) { break; } case "PlaySkillSound": { - Backend.playSound("./audio/skill/" + data.name, data.i); + let skill = data.name; + let extension = data.extension; + if (!extension) { + let data = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill])); + extension = data.extension; + } + Backend.playSound("./packages/" + extension + "/audio/skill/" + skill, data.i); break; } case "PlaySound": { @@ -859,7 +877,8 @@ callbacks["LogEvent"] = function(jsonData) { if (data.to === dashboardModel.id) { item = dashboard.self; } - Backend.playSound("./audio/death/" + item.general); + let extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [item.general])).extension; + Backend.playSound("./packages/" + extension + "/audio/death/" + item.general); } default: break; diff --git a/qml/Pages/skin-bank.js b/qml/Pages/skin-bank.js index 130cfac5..28f56a8a 100644 --- a/qml/Pages/skin-bank.js +++ b/qml/Pages/skin-bank.js @@ -14,3 +14,24 @@ var DELAYED_TRICK_DIR = AppPath + "/image/card/delayedTrick/"; var EQUIP_ICON_DIR = AppPath + "/image/card/equipIcon/"; var PIXANIM_DIR = AppPath + "/image/anim/" var TILE_ICON_DIR = AppPath + "/image/button/tileicon/" + +function getGeneralPicture(name) { + let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name])); + let extension = data.extension; + let path = AppPath + "/packages/" + extension + "/image/generals/" + name + ".jpg"; + if (Backend.exists(path)) { + return path; + } + return GENERAL_DIR + "0.jpg"; +} + +function getCardPicture(cid) { + let data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid])); + let extension = data.extension; + let name = data.name; + let path = AppPath + "/packages/" + extension + "/image/card/" + name + ".png"; + if (Backend.exists(path)) { + return path; + } + return CARD_DIR + "unknown.png"; +} diff --git a/qml/main.qml b/qml/main.qml index afb4b62f..2a2c016f 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -25,7 +25,7 @@ Item { } Image { - source: AppPath + "/image/background" + source: config.lobbyBg anchors.fill: parent fillMode: Image.PreserveAspectCrop } @@ -42,6 +42,7 @@ Item { Component { id: init; Init {} } Component { id: webinit; WebInit {} } + Component { id: packageManage; PackageManage {} } Component { id: lobby; Lobby {} } Component { id: generalsOverview; GeneralsOverview {} } Component { id: cardsOverview; CardsOverview {} } @@ -51,13 +52,30 @@ Item { property var generalsOverviewPage property var cardsOverviewPage property alias aboutPage: aboutPage - property bool busy: false + property string busyText: "" + onBusyChanged: busyText = ""; + BusyIndicator { running: true anchors.centerIn: parent visible: mainWindow.busy === true } + Item { + visible: mainWindow.busy === true && mainWindow.busyText !== "" + anchors.bottom: parent.bottom + height: 32 + width: parent.width + Rectangle { + anchors.fill: parent + color: "#88888888" + } + Text { + anchors.centerIn: parent + text: mainWindow.busyText + font.pixelSize: 24 + } + } // global popup. it is modal and just lower than toast Rectangle { @@ -126,6 +144,26 @@ Item { } } + Popup { + id: errDialog + property string txt: "" + modal: true + anchors.centerIn: parent + width: Math.min(contentWidth + 24, realMainWin.width * 0.9) + height: Math.min(contentHeight + 24, realMainWin.height * 0.9) + closePolicy: Popup.CloseOnEscape + padding: 12 + contentItem: Text { + text: errDialog.txt + wrapMode: Text.WordWrap + + MouseArea { + anchors.fill: parent + onClicked: errDialog.close(); + } + } + } + ToastManager { id: toast } @@ -133,6 +171,11 @@ Item { Connections { target: Backend function onNotifyUI(command, jsonData) { + if (command === "ErrorDialog") { + errDialog.txt = jsonData; + errDialog.open(); + return; + } let cb = callbacks[command] if (typeof(cb) === "function") { cb(jsonData); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index badeba01..2a2d0fd8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,8 @@ set(freekill_SRCS "main.cpp" "core/player.cpp" "core/util.cpp" + "core/parser.cpp" + "core/packman.cpp" "network/server_socket.cpp" "network/client_socket.cpp" "network/router.cpp" @@ -41,13 +43,16 @@ if (WIN32) set(LUA_LIB ${PROJECT_SOURCE_DIR}/lib/win/lua54.dll) set(SQLITE3_LIB ${PROJECT_SOURCE_DIR}/lib/win/sqlite3.dll) set(CRYPTO_LIB OpenSSL::Crypto) + set(GIT_LIB ${PROJECT_SOURCE_DIR}/lib/win/libgit2.dll) elseif (ANDROID) set(LUA_LIB ${PROJECT_SOURCE_DIR}/lib/android/liblua54.so) set(SQLITE3_LIB ${PROJECT_SOURCE_DIR}/lib/android/libsqlite3.so) - set(CRYPTO_LIB ${PROJECT_SOURCE_DIR}/lib/android/libcrypto_1_1.so) + set(CRYPTO_LIB ${PROJECT_SOURCE_DIR}/lib/android/libcrypto.so) + set(SSL_LIB ${PROJECT_SOURCE_DIR}/lib/android/libssl.so) + set(GIT_LIB ${PROJECT_SOURCE_DIR}/lib/android/libgit2.so) set_target_properties(FreeKill PROPERTIES QT_ANDROID_PACKAGE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/android - QT_ANDROID_EXTRA_LIBS "${LUA_LIB};${SQLITE3_LIB};${CRYPTO_LIB}" + QT_ANDROID_EXTRA_LIBS "${LUA_LIB};${SQLITE3_LIB};${CRYPTO_LIB};${SSL_LIB};${GIT_LIB}" ) list(REMOVE_ITEM QT_LIB Qt6::QuickControls2) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") @@ -69,6 +74,7 @@ else () set(CRYPTO_LIB OpenSSL::Crypto) set(READLINE_LIB readline) list(APPEND freekill_SRCS "server/shell.cpp") + set(GIT_LIB git2) endif () source_group("Include" FILES ${freekill_HEADERS}) @@ -79,7 +85,9 @@ target_link_libraries(FreeKill PRIVATE ${LUA_LIB} ${SQLITE3_LIB} ${CRYPTO_LIB} + ${SSL_LIB} ${READLINE_LIB} ${FKP_LIB} ${QT_LIB} + ${GIT_LIB} ) diff --git a/src/client/client.cpp b/src/client/client.cpp index 0d7aa44c..4213f8f3 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -2,6 +2,7 @@ #include "client_socket.h" #include "clientplayer.h" #include "util.h" +#include "parser.h" Client *ClientInstance; ClientPlayer *Self; @@ -19,6 +20,8 @@ Client::Client(QObject* parent) connect(socket, &ClientSocket::error_message, this, &Client::error_message); router = new Router(this, socket, Router::TYPE_CLIENT); + Parser::parseFkp(); + L = CreateLuaState(); DoLuaScript(L, "lua/freekill.lua"); DoLuaScript(L, "lua/client/client.lua"); diff --git a/src/core/packman.cpp b/src/core/packman.cpp new file mode 100644 index 00000000..2a933df1 --- /dev/null +++ b/src/core/packman.cpp @@ -0,0 +1,367 @@ +#include "packman.h" +#include "util.h" +#include "qmlbackend.h" +#include "git2.h" + +PackMan *Pacman; + +PackMan::PackMan(QObject *parent) : QObject(parent) { + git_libgit2_init(); + db = OpenDatabase("./packages/packages.db", "./packages/init.sql"); +#ifdef Q_OS_ANDROID + git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, NULL, "./certs"); +#endif +} + +PackMan::~PackMan() { + git_libgit2_shutdown(); + sqlite3_close(db); +} +/* +void PackMan::readConfig() { + QFile f("packages/packages.txt"); + if (!f.exists()) + return; + + if (!f.open(QIODevice::ReadOnly)) { + qFatal("cannot open packages.txt. Quit now."); + qApp->exit(1); + } + + while (true) { + auto data = f.readLine(); + if (data.isEmpty()) + break; + auto data_list = data.split(' '); + pack_list << data_list[0]; + pack_url_list << data_list[1]; + hash_list << data_list[2]; + enabled_list << data_list[3].toInt(); + } + f.close(); +} + +void PackMan::writeConfig() { + QFile f("packages/packages.txt"); + if (!f.open(QIODevice::ReadWrite | QIODevice::Truncate)) { + qFatal("Cannot open packages.txt for write. Quitting."); + } + + for (int i = 0; i < pack_list.length(); i++) { + QStringList l; + l << pack_list[i]; + l << pack_url_list[i]; + l << hash_list[i]; + l << QString::number(enabled_list[i]); + f.write(l.join(" ").toUtf8() + '\n'); + } + f.close(); +} + +void PackMan::loadConfString(const QString &conf) { + auto lines = conf.split('\n'); + foreach (QString s, lines) { + auto data_list = s.split(' '); + int idx = pack_list.indexOf(data_list[0]); + if (idx == -1) { + pack_list << data_list[0]; + pack_url_list << data_list[1]; + hash_list << data_list[2]; + enabled_list << data_list[3].toInt(); + } else { + pack_url_list[idx] = data_list[1]; + hash_list[idx] = data_list[2]; + enabled_list[idx] = data_list[3].toInt(); + } + } +} +*/ +void PackMan::downloadNewPack(const QString &url, bool useThread) { + auto threadFunc = [=](){ + int error = clone(url); + if (error < 0) return; + QString fileName = QUrl(url).fileName(); + if (fileName.endsWith(".git")) + fileName.chop(4); + + auto result = SelectFromDatabase(db, QString("SELECT name FROM packages \ + WHERE name = '%1';").arg(fileName)); + if (result.isEmpty()) { + ExecSQL(db, QString("INSERT INTO packages (name,url,hash,enabled) \ + VALUES ('%1','%2','%3',1);").arg(fileName).arg(url).arg(head(fileName))); + } + }; + if (useThread) { + auto thread = QThread::create(threadFunc); + thread->start(); + connect(thread, &QThread::finished, [=](){ + thread->deleteLater(); + Backend->emitNotifyUI("DownloadComplete", ""); + }); + } else { + threadFunc(); + } +} + +void PackMan::enablePack(const QString &pack) { + ExecSQL(db, QString("UPDATE packages SET enabled = 1 WHERE name = '%1';").arg(pack)); + QDir d(QString("packages")); + d.rename(pack + ".disabled", pack); +} + +void PackMan::disablePack(const QString &pack) { + ExecSQL(db, QString("UPDATE packages SET enabled = 0 WHERE name = '%1';").arg(pack)); + QDir d(QString("packages")); + d.rename(pack, pack + ".disabled"); +} + +void PackMan::updatePack(const QString &pack) { + auto result = SelectFromDatabase(db, QString("SELECT hash FROM packages \ + WHERE name = '%1';").arg(pack)); + if (result.isEmpty()) return; + int error; + error = pull(pack); + if (error < 0) return; + error = checkout(pack, result[0].toObject()["hash"].toString()); + if (error < 0) return; +} + +void PackMan::upgradePack(const QString &pack) { + int error; + error = checkout_branch(pack, "master"); + if (error < 0) return; + error = pull(pack); + if (error < 0) return; + ExecSQL(db, QString("UPDATE packages SET hash = '%1' WHERE name = '%2';").arg(head(pack)).arg(pack)); +} + +void PackMan::removePack(const QString &pack) { + auto result = SelectFromDatabase(db, QString("SELECT enabled FROM packages \ + WHERE name = '%1';").arg(pack)); + if (result.isEmpty()) return; + bool enabled = result[0].toObject()["enabled"].toString().toInt() == 1; + ExecSQL(db, QString("DELETE FROM packages WHERE name = '%1';").arg(pack)); + QDir d(QString("packages/%1%2").arg(pack).arg(enabled ? "" : ".disabled")); + d.removeRecursively(); +} + +QString PackMan::listPackages() { + auto obj = SelectFromDatabase(db, QString("SELECT * FROM packages;")); + return QJsonDocument(obj).toJson(); +} + +#define GIT_FAIL \ + const git_error *e = git_error_last(); \ + qCritical("Error %d/%d: %s\n", error, e->klass, e->message) + +static int transfer_progress_cb(const git_indexer_progress *stats, void *payload) +{ + (void)payload; + + if (Backend == nullptr) { + if (stats->received_objects == stats->total_objects) { + printf("Resolving deltas %u/%u\r", + stats->indexed_deltas, stats->total_deltas); + } else if (stats->total_objects > 0) { + printf("Received %u/%u objects (%u) in %zu bytes\r", + stats->received_objects, stats->total_objects, + stats->indexed_objects, stats->received_bytes); + } + } else { + if (stats->received_objects == stats->total_objects) { + auto msg = QString("Resolving deltas %1/%2") + .arg(stats->indexed_deltas).arg(stats->total_deltas); + Backend->emitNotifyUI("UpdateBusyText", msg); + } else if (stats->total_objects > 0) { + auto msg = QString("Received %1/%2 objects (%3) in %4 KiB") + .arg(stats->received_objects).arg(stats->total_objects) + .arg(stats->indexed_objects).arg(stats->received_bytes / 1024); + Backend->emitNotifyUI("UpdateBusyText", msg); + } + } + + return 0; +} + +int PackMan::clone(const QString &url) { + git_repository *repo = NULL; + const char *u = url.toUtf8().constData(); + QString fileName = QUrl(url).fileName(); + if (fileName.endsWith(".git")) + fileName.chop(4); + fileName = "packages/" + fileName; + const char *path = fileName.toUtf8().constData(); + + git_clone_options opt = GIT_CLONE_OPTIONS_INIT; + opt.fetch_opts.callbacks.transfer_progress = transfer_progress_cb; + int error = git_clone(&repo, u, path, &opt); + if (error < 0) { + GIT_FAIL; + QDir(fileName).removeRecursively(); + QDir(".").rmdir(fileName); + } else { + if (Backend == nullptr) + printf("\n"); + else + qWarning("Completed."); + } + git_repository_free(repo); + return error; +} + +int PackMan::pull(const QString &name) { + git_repository *repo = NULL; + int error; + git_remote *remote = NULL; + const char *path = QString("packages/%1").arg(name).toUtf8().constData(); + git_fetch_options opt = GIT_FETCH_OPTIONS_INIT; + opt.callbacks.transfer_progress = transfer_progress_cb; + error = git_repository_open(&repo, path); + if (error < 0) { + GIT_FAIL; + goto clean; + } + error = git_remote_lookup(&remote, repo, "origin"); + if (error < 0) { + GIT_FAIL; + goto clean; + } + error = git_remote_fetch(remote, NULL, &opt, "pull"); + if (error < 0) { + GIT_FAIL; + goto clean; + } else { + if (Backend == nullptr) + printf("\n"); + else + qWarning("Completed."); + } + +clean: + git_remote_free(remote); + git_repository_free(repo); + return error; +} + +int PackMan::checkout(const QString &name, const QString &hash) { + git_repository *repo = NULL; + git_oid oid = {0}; + int error; + git_commit *commit = NULL; + const char *path = QString("packages/%1").arg(name).toUtf8().constData(); + const char *sha = hash.toLatin1().constData(); + error = git_repository_open(&repo, path); + if (error < 0) { + GIT_FAIL; + goto clean; + } + error = git_oid_fromstr(&oid, sha); + if (error < 0) { + GIT_FAIL; + goto clean; + } + error = git_commit_lookup(&commit, repo, &oid); + if (error < 0) { + GIT_FAIL; + goto clean; + } + error = git_checkout_tree(repo, (git_object *)commit, NULL); + if (error < 0) { + GIT_FAIL; + goto clean; + } + +clean: + git_commit_free(commit); + git_repository_free(repo); + return error; +} + +int PackMan::checkout_branch(const QString &name, const QString &branch) { + git_repository *repo = NULL; + git_oid oid = {0}; + int error; + git_object *obj = NULL; + const char *path = QString("packages/%1").arg(name).toUtf8().constData(); + error = git_repository_open(&repo, path); + if (error < 0) { + GIT_FAIL; + goto clean; + } + error = git_revparse_single(&obj, repo, branch.toUtf8().constData()); + if (error < 0) { + GIT_FAIL; + goto clean; + } + error = git_checkout_tree(repo, obj, NULL); + if (error < 0) { + GIT_FAIL; + goto clean; + } + +clean: + git_object_free(obj); + git_repository_free(repo); + return error; +} + +int PackMan::status(const QString &name) { + git_repository *repo = NULL; + int error; + git_status_list *status_list; + size_t i, maxi; + const git_status_entry *s; + const char *path = QString("packages/%1").arg(name).toUtf8().constData(); + error = git_repository_open(&repo, path); + if (error < 0) { + GIT_FAIL; + goto clean; + } + error = git_status_list_new(&status_list, repo, NULL); + if (error < 0) { + GIT_FAIL; + goto clean; + } + maxi = git_status_list_entrycount(status_list); + for (i = 0; i < maxi; ++i) { + char *istatus = NULL; + s = git_status_byindex(status_list, i); + if (s->status != GIT_STATUS_CURRENT && s->status != GIT_STATUS_IGNORED) + return 1; + } + +clean: + git_status_list_free(status_list); + git_repository_free(repo); + return error; +} + +QString PackMan::head(const QString &name) { + git_repository *repo = NULL; + int error; + git_object *obj = NULL; + const char *path = QString("packages/%1").arg(name).toUtf8().constData(); + error = git_repository_open(&repo, path); + if (error < 0) { + GIT_FAIL; + git_object_free(obj); + git_repository_free(repo); + return QString(); + } + error = git_revparse_single(&obj, repo, "HEAD"); + if (error < 0) { + GIT_FAIL; + git_object_free(obj); + git_repository_free(repo); + return QString(); + } + + const git_oid *oid = git_object_id(obj); + char buf[42]; + git_oid_tostr(buf, 41, oid); + git_object_free(obj); + git_repository_free(repo); + return QString(buf); +} + +#undef GIT_FAIL diff --git a/src/core/packman.h b/src/core/packman.h new file mode 100644 index 00000000..11d650ef --- /dev/null +++ b/src/core/packman.h @@ -0,0 +1,34 @@ +#ifndef _PACKMAN_H +#define _PACKMAN_H + +class PackMan : public QObject { + Q_OBJECT +public: + PackMan(QObject *parent = nullptr); + ~PackMan(); +/* + void readConfig(); + void writeConfig(); + void loadConfString(const QString &conf); +*/ + Q_INVOKABLE void downloadNewPack(const QString &url, bool useThread = false); + Q_INVOKABLE void enablePack(const QString &pack); + Q_INVOKABLE void disablePack(const QString &pack); + Q_INVOKABLE void updatePack(const QString &pack); + Q_INVOKABLE void upgradePack(const QString &pack); + Q_INVOKABLE void removePack(const QString &pack); + Q_INVOKABLE QString listPackages(); +private: + sqlite3 *db; + + int clone(const QString &url); + int pull(const QString &name); + int checkout(const QString &name, const QString &hash); + int checkout_branch(const QString &name, const QString &branch); + int status(const QString &name); // return 1 if the workdir is modified + QString head(const QString &name); // get commit hash of HEAD +}; + +extern PackMan *Pacman; + +#endif diff --git a/src/core/parser.cpp b/src/core/parser.cpp new file mode 100644 index 00000000..fe6a4d9d --- /dev/null +++ b/src/core/parser.cpp @@ -0,0 +1,96 @@ +#include "parser.h" + +static Parser *p = nullptr; + +Parser::Parser() { parser = fkp_new_parser(); } + +Parser::~Parser() { fkp_close(parser); } + +int Parser::parse(const QString &fileName) { + if (!QFile::exists(fileName)) { + return 1; + } + QString cwd = QDir::currentPath(); + + QStringList strlist = fileName.split('/'); + QString shortFileName = strlist.last(); + strlist.removeLast(); + QString path = strlist.join('/'); + QDir::setCurrent(path); + + auto fnamebytes = shortFileName.toUtf8(); + + bool error = fkp_parse(parser, fnamebytes.constData(), FKP_FK_LUA); + + if (error) { + QStringList tmplist = shortFileName.split('.'); + tmplist.removeLast(); + QString fName = tmplist.join('.') + "-error.txt"; + if (!QFile::exists(fName)) { + qCritical("FKP parse error: Unknown error."); + } else { + QFile f(fName); + f.open(QIODevice::ReadOnly); + qCritical() << "FKP parse error:\n" << f.readAll().constData(); + f.remove(); + } + } + + QDir::setCurrent(cwd); + return error; +} + +static QStringList findFile(const QString &path, const QString &filename) { + QStringList ret; + if (path.isEmpty() || filename.isEmpty()) { + return ret; + } + + QDir dir; + QStringList filters; + + filters + << filename; + dir.setPath(path); + dir.setNameFilters(filters); + QDirIterator iter(dir, QDirIterator::Subdirectories); + + while (iter.hasNext()) { + iter.next(); + auto info = iter.fileInfo(); + if (info.isFile()) { + ret.append(info.absoluteFilePath()); + } else if (info.isDir()) { + ret.append(findFile(path, filename)); + } + } + + return ret; +} + +void Parser::parseFkp() { + if (!p) { + p = new Parser; + } + + foreach (QString s, findFile("./packages", "*.fkp")) { + p->parse(s); + } +} + +#ifndef Q_OS_WASM +static void copyFkpHash2QHash(QHash &dst, fkp_hash *from) { + dst.clear(); + for (size_t i = 0; i < from->capacity; i++) { + if (from->entries[i].key != NULL) { + dst[from->entries[i].key] = QString((const char *)from->entries[i].value); + } + } +} + +void Parser::readHashFromParser() { + copyFkpHash2QHash(generals, parser->generals); + copyFkpHash2QHash(skills, parser->skills); + copyFkpHash2QHash(marks, parser->marks); +} +#endif diff --git a/src/core/parser.h b/src/core/parser.h new file mode 100644 index 00000000..cab4c87d --- /dev/null +++ b/src/core/parser.h @@ -0,0 +1,22 @@ +#ifndef _PARSER_H +#define _PARSER_H + +#include "fkparse.h" + +class Parser { +public: + Parser(); + ~Parser(); + int parse(const QString &filename); + static void parseFkp(); + +private: + fkp_parser *parser; + QHash generals; + QHash skills; + QHash marks; + + void readHashFromParser(); +}; + +#endif diff --git a/src/core/util.cpp b/src/core/util.cpp index cb00ac24..6631c995 100644 --- a/src/core/util.cpp +++ b/src/core/util.cpp @@ -62,14 +62,14 @@ void Dumpstack(lua_State *L) } #ifndef Q_OS_WASM -sqlite3 *OpenDatabase(const QString &filename) +sqlite3 *OpenDatabase(const QString &filename, const QString &initSql) { sqlite3 *ret; int rc; if (!QFile::exists(filename)) { - QFile file("./server/init.sql"); + QFile file(initSql); if (!file.open(QIODevice::ReadOnly)) { - qFatal("cannot open init.sql. Quit now."); + qFatal("cannot open %s. Quit now.", initSql.toUtf8().data()); qApp->exit(1); } @@ -99,23 +99,21 @@ sqlite3 *OpenDatabase(const QString &filename) static int callback(void *jsonDoc, int argc, char **argv, char **cols) { QJsonObject obj; for (int i = 0; i < argc; i++) { - QJsonArray arr = obj[QString(cols[i])].toArray(); - arr << QString(argv[i] ? argv[i] : "#null"); - obj[QString(cols[i])] = arr; + obj[QString(cols[i])] = QString(argv[i] ? argv[i] : "#null"); } - ((QJsonObject *)jsonDoc)->swap(obj); + ((QJsonArray *)jsonDoc)->append(obj); return 0; } -QJsonObject SelectFromDatabase(sqlite3 *db, const QString &sql) { - QJsonObject obj; +QJsonArray SelectFromDatabase(sqlite3 *db, const QString &sql) { + QJsonArray arr; auto bytes = sql.toUtf8(); - sqlite3_exec(db, bytes.data(), callback, (void *)&obj, nullptr); - return obj; + sqlite3_exec(db, bytes.data(), callback, (void *)&arr, nullptr); + return arr; } QString SelectFromDb(sqlite3 *db, const QString &sql) { - QJsonObject obj = SelectFromDatabase(db, sql); + auto obj = SelectFromDatabase(db, sql); return QJsonDocument(obj).toJson(QJsonDocument::Compact); } @@ -171,7 +169,7 @@ static void writeDirMD5(QFile &dest, const QString &dir, const QString &filter) auto entries = d.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); auto re = QRegularExpression::fromWildcard(filter); foreach (QFileInfo info, entries) { - if (info.isDir()) { + if (info.isDir() && !info.fileName().endsWith(".disabled")) { writeDirMD5(dest, info.filePath(), filter); } else { if (re.match(info.fileName()).hasMatch()) { diff --git a/src/core/util.h b/src/core/util.h index 281f4bc5..1bc901cd 100644 --- a/src/core/util.h +++ b/src/core/util.h @@ -7,8 +7,8 @@ lua_State *CreateLuaState(); bool DoLuaScript(lua_State *L, const char *script); #ifndef Q_OS_WASM -sqlite3 *OpenDatabase(const QString &filename = "./server/users.db"); -QJsonObject SelectFromDatabase(sqlite3 *db, const QString &sql); +sqlite3 *OpenDatabase(const QString &filename = "./server/users.db", const QString &initSql = "./server/init.sql"); +QJsonArray SelectFromDatabase(sqlite3 *db, const QString &sql); // For Lua QString SelectFromDb(sqlite3 *db, const QString &sql); void ExecSQL(sqlite3 *db, const QString &sql); diff --git a/src/main.cpp b/src/main.cpp index c9e1d8be..9a3979f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include "qmlbackend.h" #ifndef Q_OS_WASM #include "server.h" +#include "packman.h" #endif #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) @@ -61,9 +62,16 @@ void fkMsgHandler(QtMsgType type, const QMessageLogContext &context, const QStri break; case QtWarningMsg: fprintf(stderr, "[%s/WARNING] %s\n", threadName.constData(), localMsg.constData()); + if (Backend != nullptr) { + Backend->notifyUI("ErrorDialog", localMsg); + } break; case QtCriticalMsg: fprintf(stderr, "[%s/CRITICAL] %s\n", threadName.constData(), localMsg.constData()); + if (Backend != nullptr) { + Backend->notifyUI("ErrorDialog", QString("⛔ %1/Error occured!\n %2") + .arg(threadName).arg(localMsg)); + } break; case QtFatalMsg: fprintf(stderr, "[%s/FATAL] %s\n", threadName.constData(), localMsg.constData()); @@ -107,6 +115,7 @@ int main(int argc, char *argv[]) qInfo("Server is listening on port %d", serverPort); #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) auto shell = new Shell; + Pacman = new PackMan; shell->start(); #endif } @@ -121,10 +130,6 @@ int main(int argc, char *argv[]) ((QApplication *)app)->setWindowIcon(QIcon("image/icon.png")); #endif - QTranslator translator; - Q_UNUSED(translator.load("zh_CN.qm")); - QCoreApplication::installTranslator(&translator); - #define SHOW_SPLASH_MSG(msg) \ splash.showMessage(msg, Qt::AlignHCenter | Qt::AlignBottom); @@ -147,11 +152,20 @@ int main(int argc, char *argv[]) #ifndef Q_OS_ANDROID QQuickStyle::setStyle("Material"); #endif + + QTranslator translator; + Q_UNUSED(translator.load("zh_CN.qm")); + QCoreApplication::installTranslator(&translator); QmlBackend backend; backend.setEngine(engine); + +#ifndef Q_OS_WASM + Pacman = new PackMan; +#endif engine->rootContext()->setContextProperty("Backend", &backend); + engine->rootContext()->setContextProperty("Pacman", Pacman); #ifdef QT_DEBUG bool debugging = true; @@ -169,6 +183,7 @@ int main(int argc, char *argv[]) engine->rootContext()->setContextProperty("ServerAddr", "127.0.0.1:9530"); #elif defined(Q_OS_WIN32) system = "Win"; + ::system("chcp 65001"); #elif defined(Q_OS_LINUX) system = "Linux"; #else @@ -188,6 +203,7 @@ int main(int argc, char *argv[]) // delete the engine first // to avoid "TypeError: Cannot read property 'xxx' of null" delete engine; + delete Pacman; return ret; } diff --git a/src/network/router.cpp b/src/network/router.cpp index e34187d9..f3a0880d 100644 --- a/src/network/router.cpp +++ b/src/network/router.cpp @@ -1,6 +1,7 @@ #include "router.h" #include "client.h" #include "client_socket.h" +#include #ifndef Q_OS_WASM #include "server.h" #include "serverplayer.h" @@ -178,15 +179,16 @@ void Router::handlePacket(const QByteArray& rawPacket) .arg(sender->getId()); auto passed = false; - auto result = SelectFromDatabase(ServerInstance->getDatabase(), sql_find); - passed = (result["password"].toArray()[0].toString() == + auto arr2 = SelectFromDatabase(ServerInstance->getDatabase(), sql_find); + auto result = arr2[0].toObject(); + passed = (result["password"].toString() == QCryptographicHash::hash( - oldpw.append(result["salt"].toArray()[0].toString()).toLatin1(), + oldpw.append(result["salt"].toString()).toLatin1(), QCryptographicHash::Sha256).toHex()); if (passed) { auto sql_update = QString("UPDATE userinfo SET password='%1' WHERE id=%2;") .arg(QCryptographicHash::hash( - newpw.append(result["salt"].toArray()[0].toString()).toLatin1(), + newpw.append(result["salt"].toString()).toLatin1(), QCryptographicHash::Sha256).toHex()) .arg(sender->getId()); ExecSQL(ServerInstance->getDatabase(), sql_update); @@ -198,17 +200,24 @@ void Router::handlePacket(const QByteArray& rawPacket) auto arr = String2Json(jsonData).array(); auto name = arr[0].toString(); auto capacity = arr[1].toInt(); - ServerInstance->createRoom(sender, name, capacity); + auto settings = QJsonDocument(arr[2].toObject()).toJson(QJsonDocument::Compact); + ServerInstance->createRoom(sender, name, capacity, settings); }; lobby_actions["EnterRoom"] = [](ServerPlayer *sender, const QString &jsonData){ auto arr = String2Json(jsonData).array(); auto roomId = arr[0].toInt(); ServerInstance->findRoom(roomId)->addPlayer(sender); }; + lobby_actions["ObserveRoom"] = [](ServerPlayer *sender, const QString &jsonData){ + auto arr = String2Json(jsonData).array(); + auto roomId = arr[0].toInt(); + ServerInstance->findRoom(roomId)->addObserver(sender); + }; lobby_actions["Chat"] = [](ServerPlayer *sender, const QString &jsonData){ sender->getRoom()->chat(sender, jsonData); }; } +#endif QJsonDocument packet = QJsonDocument::fromJson(rawPacket); if (packet.isNull() || !packet.isArray()) @@ -222,7 +231,10 @@ void Router::handlePacket(const QByteArray& rawPacket) if (type & TYPE_NOTIFICATION) { if (type & DEST_CLIENT) { ClientInstance->callLua(command, jsonData); - } else { + } +#ifndef Q_OS_WASM + else + { ServerPlayer *player = qobject_cast(parent()); Room *room = player->getRoom(); @@ -238,6 +250,7 @@ void Router::handlePacket(const QByteArray& rawPacket) } } } +#endif } else if (type & TYPE_REQUEST) { this->requestId = requestId; @@ -250,6 +263,7 @@ void Router::handlePacket(const QByteArray& rawPacket) Q_ASSERT(false); } } +#ifndef Q_OS_WASM else if (type & TYPE_REPLY) { QMutexLocker locker(&replyMutex); @@ -273,28 +287,6 @@ void Router::handlePacket(const QByteArray& rawPacket) locker.unlock(); emit replyReady(); } -#else - QJsonDocument packet = QJsonDocument::fromJson(rawPacket); - if (packet.isNull() || !packet.isArray()) - return; - - int requestId = packet[0].toInt(); - int type = packet[1].toInt(); - QString command = packet[2].toString(); - QString jsonData = packet[3].toString(); - - if (type & TYPE_NOTIFICATION) { - if (type & DEST_CLIENT) { - ClientInstance->callLua(command, jsonData); - } - } else if (type & TYPE_REQUEST) { - this->requestId = requestId; - this->requestTimeout = packet[4].toInt(); - - if (type & DEST_CLIENT) { - qobject_cast(parent())->callLua(command, jsonData); - } - } #endif } diff --git a/src/server/room.cpp b/src/server/room.cpp index 82bad244..44ae986b 100644 --- a/src/server/room.cpp +++ b/src/server/room.cpp @@ -2,6 +2,8 @@ #include "serverplayer.h" #include "server.h" #include "util.h" +#include +#include Room::Room(Server* server) { @@ -80,6 +82,14 @@ bool Room::isFull() const return players.count() == capacity; } +const QByteArray Room::getSettings() const { + return settings; +} + +void Room::setSettings(QByteArray settings) { + this->settings = settings; +} + bool Room::isAbandoned() const { if (isLobby()) @@ -143,6 +153,7 @@ void Room::addPlayer(ServerPlayer *player) jsonData = QJsonArray(); jsonData << this->capacity; jsonData << this->timeout; + jsonData << QJsonDocument::fromJson(this->settings).object(); player->doNotify("EnterRoom", JsonArray2Bytes(jsonData)); foreach (ServerPlayer *p, getOtherPlayers(player)) { @@ -181,6 +192,11 @@ void Room::addRobot(ServerPlayer *player) void Room::removePlayer(ServerPlayer *player) { + if (observers.contains(player)) { + removeObserver(player); + return; + } + if (!gameStarted) { if (players.contains(player)) { players.removeOne(player); @@ -244,6 +260,34 @@ ServerPlayer *Room::findPlayer(int id) const return nullptr; } +void Room::addObserver(ServerPlayer *player) { + if (!gameStarted) { + player->doNotify("ErrorMsg", "Can only observe running room."); + return; + } + observers.append(player); + player->setRoom(this); + pushRequest(QString("%1,observe").arg(player->getId())); +} + +void Room::removeObserver(ServerPlayer *player) { + observers.removeOne(player); + player->setRoom(server->lobby()); + if (player->getState() == Player::Online) { + QJsonArray arr; + arr << player->getId(); + arr << player->getScreenName(); + arr << player->getAvatar(); + player->doNotify("Setup", JsonArray2Bytes(arr)); + player->doNotify("EnterLobby", ""); + } + pushRequest(QString("%1,leave").arg(player->getId())); +} + +QList Room::getObservers() const { + return observers; +} + int Room::getTimeout() const { return timeout; @@ -274,7 +318,9 @@ void Room::chat(ServerPlayer *sender, const QString &jsonData) { if (type == 1) { // TODO: server chatting } else { - doBroadcastNotify(players, "Chat", QJsonDocument(doc).toJson(QJsonDocument::Compact)); + auto json = QJsonDocument(doc).toJson(QJsonDocument::Compact); + doBroadcastNotify(players, "Chat", json); + doBroadcastNotify(observers, "Chat", json); } } diff --git a/src/server/room.h b/src/server/room.h index dd014d52..735aa863 100644 --- a/src/server/room.h +++ b/src/server/room.h @@ -21,6 +21,8 @@ public: int getCapacity() const; void setCapacity(int capacity); bool isFull() const; + const QByteArray getSettings() const; + void setSettings(QByteArray settings); bool isAbandoned() const; void setAbandoned(bool abandoned); // never use this function @@ -34,6 +36,10 @@ public: QList getOtherPlayers(ServerPlayer *expect) const; ServerPlayer *findPlayer(int id) const; + void addObserver(ServerPlayer *player); + void removeObserver(ServerPlayer *player); + QList getObservers() const; + int getTimeout() const; void setTimeout(int timeout); @@ -72,10 +78,12 @@ private: int id; // Lobby's id is 0 QString name; // “阴间大乱斗” int capacity; // by default is 5, max is 8 + QByteArray settings; // JSON string bool m_abandoned; // If room is empty, delete it ServerPlayer *owner; // who created this room? QList players; + QList observers; QList runned_players; int robot_id; bool gameStarted; diff --git a/src/server/server.cpp b/src/server/server.cpp index a2d2c349..84cdd7aa 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -5,6 +5,7 @@ #include "router.h" #include "serverplayer.h" #include "util.h" +#include "parser.h" Server *ServerInstance; @@ -18,6 +19,7 @@ Server::Server(QObject* parent) file.open(QIODevice::ReadOnly); QTextStream in(&file); public_key = in.readAll(); + Parser::parseFkp(); md5 = calcFileMD5(); server = new ServerSocket(); @@ -45,7 +47,7 @@ bool Server::listen(const QHostAddress& address, ushort port) return server->listen(address, port); } -void Server::createRoom(ServerPlayer* owner, const QString &name, int capacity) +void Server::createRoom(ServerPlayer* owner, const QString &name, int capacity, const QByteArray &settings) { Room *room; if (!idle_rooms.isEmpty()) { @@ -65,6 +67,7 @@ void Server::createRoom(ServerPlayer* owner, const QString &name, int capacity) room->setName(name); room->setCapacity(capacity); + room->setSettings(settings); room->addPlayer(owner); if (!room->isLobby()) room->setOwner(owner); } @@ -204,15 +207,15 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString& name, co auto decrypted_pw = QByteArray::fromRawData((const char *)buf, strlen((const char *)buf)); bool passed = false; QString error_msg; - QJsonObject result; + QJsonArray result; + QJsonObject obj; if (!nameExp.match(name).hasMatch() && !name.isEmpty()) { // Then we check the database, QString sql_find = QString("SELECT * FROM userinfo \ WHERE name='%1';").arg(name); result = SelectFromDatabase(db, sql_find); - QJsonArray arr = result["password"].toArray(); - if (arr.isEmpty()) { + if (result.isEmpty()) { auto salt_gen = QRandomGenerator::securelySeeded(); auto salt = QByteArray::number(salt_gen(), 16); decrypted_pw.append(salt); @@ -228,16 +231,18 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString& name, co .arg("FALSE"); ExecSQL(db, sql_reg); result = SelectFromDatabase(db, sql_find); // refresh result + obj = result[0].toObject(); passed = true; } else { + obj = result[0].toObject(); // check if this username already login - int id = result["id"].toArray()[0].toString().toInt(); + int id = obj["id"].toString().toInt(); if (!players.value(id)) { // check if password is the same - auto salt = result["salt"].toArray()[0].toString().toLatin1(); + auto salt = obj["salt"].toString().toLatin1(); decrypted_pw.append(salt); auto passwordHash = QCryptographicHash::hash(decrypted_pw, QCryptographicHash::Sha256).toHex(); - passed = (passwordHash == arr[0].toString()); + passed = (passwordHash == obj["password"].toString()); if (!passed) error_msg = "username or password error"; } else { auto player = players.value(id); @@ -264,8 +269,8 @@ void Server::handleNameAndPassword(ClientSocket *client, const QString& name, co connect(player, &ServerPlayer::disconnected, this, &Server::onUserDisconnected); connect(player, &Player::stateChanged, this, &Server::onUserStateChanged); player->setScreenName(name); - player->setAvatar(result["avatar"].toArray()[0].toString()); - player->setId(result["id"].toArray()[0].toString().toInt()); + player->setAvatar(obj["avatar"].toString()); + player->setId(obj["id"].toString().toInt()); players.insert(player->getId(), player); // tell the lobby player's basic property @@ -312,6 +317,11 @@ void Server::onUserDisconnected() qInfo() << "Player" << player->getId() << "disconnected"; Room *room = player->getRoom(); if (room->isStarted()) { + if (room->getObservers().contains(player)) { + room->removeObserver(player); + player->deleteLater(); + return; + } player->setState(Player::Offline); player->setSocket(nullptr); // TODO: add a robot diff --git a/src/server/server.h b/src/server/server.h index aa661336..a61ab05f 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -16,7 +16,7 @@ public: bool listen(const QHostAddress &address = QHostAddress::Any, ushort port = 9527u); - void createRoom(ServerPlayer *owner, const QString &name, int capacity); + void createRoom(ServerPlayer *owner, const QString &name, int capacity, const QByteArray &settings = "{}"); Room *findRoom(int id) const; Room *lobby() const; diff --git a/src/server/shell.cpp b/src/server/shell.cpp index 47e37ab0..89af9a26 100644 --- a/src/server/shell.cpp +++ b/src/server/shell.cpp @@ -2,6 +2,7 @@ #include "shell.h" #include "server.h" #include "serverplayer.h" +#include "packman.h" #include #include #include @@ -20,6 +21,12 @@ void Shell::helpCommand(QStringList &) { qInfo("%s: Shut down the server.", "quit"); qInfo("%s: List all online players.", "lsplayer"); qInfo("%s: List all running rooms.", "lsroom"); + qInfo("%s: Install a new package from .", "install"); + qInfo("%s: Remove a package.", "remove"); + qInfo("%s: List all packages.", "lspkg"); + qInfo("%s: Enable a package.", "enable"); + qInfo("%s: Disable a package.", "disable"); + qInfo("%s: Upgrade a package.", "upgrade"); qInfo("For more commands, check the documentation."); } @@ -45,6 +52,69 @@ void Shell::lsrCommand(QStringList &) { } } +void Shell::installCommand(QStringList &list) { + if (list.isEmpty()) { + qWarning("The 'install' command need a URL to install."); + return; + } + + auto url = list[0]; + Pacman->downloadNewPack(url); +} + +void Shell::removeCommand(QStringList &list) { + if (list.isEmpty()) { + qWarning("The 'remove' command need a package name to remove."); + return; + } + + auto pack = list[0]; + Pacman->removePack(pack); +} + +void Shell::upgradeCommand(QStringList &list) { + if (list.isEmpty()) { + qWarning("The 'upgrade' command need a package name to upgrade."); + return; + } + + auto pack = list[0]; + Pacman->upgradePack(pack); +} + +void Shell::enableCommand(QStringList &list) { + if (list.isEmpty()) { + qWarning("The 'enable' command need a package name to enable."); + return; + } + + auto pack = list[0]; + Pacman->enablePack(pack); +} + +void Shell::disableCommand(QStringList &list) { + if (list.isEmpty()) { + qWarning("The 'disable' command need a package name to disable."); + return; + } + + auto pack = list[0]; + Pacman->disablePack(pack); +} + +void Shell::lspkgCommand(QStringList &) { + auto arr = QJsonDocument::fromJson(Pacman->listPackages().toUtf8()).array(); + qInfo("Name\tVersion\t\tEnabled"); + qInfo("------------------------------"); + foreach (auto a, arr) { + auto obj = a.toObject(); + auto hash = obj["hash"].toString(); + qInfo() << obj["name"].toString().toUtf8().constData() << "\t" + << hash.first(8).toUtf8().constData() << "\t" + << obj["enabled"].toString().toUtf8().constData(); + } +} + Shell::Shell() { setObjectName("Shell"); signal(SIGINT, sigintHandler); @@ -55,6 +125,12 @@ Shell::Shell() { handlers["?"] = &Shell::helpCommand; handlers["lsplayer"] = &Shell::lspCommand; handlers["lsroom"] = &Shell::lsrCommand; + handlers["install"] = &Shell::installCommand; + handlers["remove"] = &Shell::removeCommand; + handlers["upgrade"] = &Shell::upgradeCommand; + handlers["lspkg"] = &Shell::lspkgCommand; + handlers["enable"] = &Shell::enableCommand; + handlers["disable"] = &Shell::disableCommand; } handler_map = handlers; } diff --git a/src/server/shell.h b/src/server/shell.h index fa966604..76000ced 100644 --- a/src/server/shell.h +++ b/src/server/shell.h @@ -30,6 +30,12 @@ private: void quitCommand(QStringList &); void lspCommand(QStringList &); void lsrCommand(QStringList &); + void installCommand(QStringList &); + void removeCommand(QStringList &); + void upgradeCommand(QStringList &); + void lspkgCommand(QStringList &); + void enableCommand(QStringList &); + void disableCommand(QStringList &); }; #endif diff --git a/src/swig/client.i b/src/swig/client.i index 6b626712..953e73b0 100644 --- a/src/swig/client.i +++ b/src/swig/client.i @@ -9,8 +9,6 @@ public: static QString pwd(); static bool exists(const QString &file); static bool isDir(const QString &file); - - void parseFkp(const QString &file); }; extern QmlBackend *Backend; diff --git a/src/swig/server.i b/src/swig/server.i index 579df26a..0e5ea122 100644 --- a/src/swig/server.i +++ b/src/swig/server.i @@ -37,6 +37,7 @@ public: QList getPlayers() const; ServerPlayer *findPlayer(int id) const; + QList getObservers() const; int getTimeout() const; bool isStarted() const; diff --git a/src/ui/qmlbackend.cpp b/src/ui/qmlbackend.cpp index 11af88fa..4219a250 100644 --- a/src/ui/qmlbackend.cpp +++ b/src/ui/qmlbackend.cpp @@ -3,13 +3,14 @@ #include #include #include +#include #ifndef Q_OS_WASM #include "server.h" #endif #include "client.h" #include "util.h" -QmlBackend *Backend; +QmlBackend *Backend = nullptr; QmlBackend::QmlBackend(QObject* parent) : QObject(parent) @@ -17,18 +18,12 @@ QmlBackend::QmlBackend(QObject* parent) Backend = this; engine = nullptr; rsa = RSA_new(); -#ifndef Q_OS_WASM - parser = fkp_new_parser(); -#endif } QmlBackend::~QmlBackend() { Backend = nullptr; RSA_free(rsa); -#ifndef Q_OS_WASM - fkp_close(parser); -#endif } QQmlApplicationEngine *QmlBackend::getEngine() const @@ -82,6 +77,8 @@ void QmlBackend::quitLobby() { if (ClientInstance) delete ClientInstance; + if (ServerInstance) + delete ServerInstance; } void QmlBackend::emitNotifyUI(const QString &command, const QString &jsonData) { @@ -106,11 +103,16 @@ QString QmlBackend::pwd() { } bool QmlBackend::exists(const QString &file) { - return QFile::exists(file); + QString s = file; +#ifdef Q_OS_WIN + if (s.startsWith("file:///")) + s.replace(0, 8, "file://"); +#endif + return QFile::exists(QUrl(s).path()); } bool QmlBackend::isDir(const QString &file) { - return QFileInfo(file).isDir(); + return QFileInfo(QUrl(file).path()).isDir(); } QString QmlBackend::translate(const QString &src) { @@ -202,18 +204,7 @@ QString QmlBackend::loadConf() { QFile conf("freekill.client.config.json"); if (!conf.exists()) { conf.open(QIODevice::WriteOnly); - static const char *init_conf = "{\ - \"winWidth\": 960,\ - \"winHeight\": 540,\ - \"lastLoginServer\": \"127.0.0.1\",\ - \"savedPassword\": {\ - \"127.0.0.1\": {\ - \"username\": \"player\",\ - \"password\": \"\",\ - \"shorten_password\": \"\"\ - }\ - }\ - }"; + static const char *init_conf = "{}"; conf.write(init_conf); return init_conf; } @@ -227,64 +218,6 @@ void QmlBackend::saveConf(const QString &conf) { c.write(conf.toUtf8()); } -void QmlBackend::parseFkp(const QString &fileName) { -#ifndef Q_OS_WASM - if (!QFile::exists(fileName)) { -// errorEdit->setText(tr("File does not exist!")); - return; - } - QString cwd = QDir::currentPath(); - - QStringList strlist = fileName.split('/'); - QString shortFileName = strlist.last(); - strlist.removeLast(); - QString path = strlist.join('/'); - QDir::setCurrent(path); - - bool error = fkp_parse( - parser, - shortFileName.toUtf8().data(), - FKP_QSAN_LUA - ); -/* setError(error); - - if (error) { - QStringList tmplist = shortFileName.split('.'); - tmplist.removeLast(); - QString fName = tmplist.join('.') + "-error.txt"; - if (!QFile::exists(fName)) { - errorEdit->setText(tr("Unknown compile error.")); - } else { - QFile f(fName); - f.open(QIODevice::ReadOnly); - errorEdit->setText(f.readAll()); - f.remove(); - } - } else { - errorEdit->setText(tr("Successfully compiled chosen file.")); - } -*/ - QDir::setCurrent(cwd); -#endif -} - -#ifndef Q_OS_WASM -static void copyFkpHash2QHash(QHash &dst, fkp_hash *from) { - dst.clear(); - for (size_t i = 0; i < from->capacity; i++) { - if (from->entries[i].key != NULL) { - dst[from->entries[i].key] = QString((const char *)from->entries[i].value); - } - } -} - -void QmlBackend::readHashFromParser() { - copyFkpHash2QHash(generals, parser->generals); - copyFkpHash2QHash(skills, parser->skills); - copyFkpHash2QHash(marks, parser->marks); -} -#endif - QString QmlBackend::calcFileMD5() { return ::calcFileMD5(); } @@ -324,3 +257,6 @@ void QmlBackend::playSound(const QString &name, int index) { player->play(); } +void QmlBackend::copyToClipboard(const QString &s) { + QGuiApplication::clipboard()->setText(s); +} diff --git a/src/ui/qmlbackend.h b/src/ui/qmlbackend.h index 79a7bd2e..1480defb 100644 --- a/src/ui/qmlbackend.h +++ b/src/ui/qmlbackend.h @@ -1,11 +1,6 @@ #ifndef _QMLBACKEND_H #define _QMLBACKEND_H -#ifndef Q_OS_WASM -#include "fkparse.h" -#endif -#include - class QmlBackend : public QObject { Q_OBJECT public: @@ -39,27 +34,20 @@ public: Q_INVOKABLE QString pubEncrypt(const QString &key, const QString &data); Q_INVOKABLE QString loadConf(); Q_INVOKABLE void saveConf(const QString &conf); - // support fkp - Q_INVOKABLE void parseFkp(const QString &filename); Q_INVOKABLE QString calcFileMD5(); Q_INVOKABLE void playSound(const QString &name, int index = 0); + Q_INVOKABLE void copyToClipboard(const QString &s); + signals: void notifyUI(const QString &command, const QString &jsonData); private: QQmlApplicationEngine *engine; RSA *rsa; -#ifndef Q_OS_WASM - fkp_parser *parser; -#endif - QHash generals; - QHash skills; - QHash marks; void pushLuaValue(lua_State *L, QVariant v); - void readHashFromParser(); }; extern QmlBackend *Backend;