Standard equips (#50)

* support fkp

* get default setting in qml

* correct zixing

* mark

* TODO: parse fkp in c++

* scale the drawer

* free assign

* fix free assign bug

* add submodule for official generals

* generate fkp in cpp code

* use UTF-8 in windows conhost

* use onUse for regular skill

* active skill for fkp

* add fkp function; change data for DMG and Heal

* add cancelable to askForDiscard

* don't let generals naked

* config bg and bgm

* fix exists for win

* bugfix: rewardandpunish

* fkp: vs skill

* room config

* observe

* god_salavation

* fkp: judge

* add read storage permission for android build

* remove submodule fk_official

* remove include/

* use a submodule as include directory

* libgit2

* remove debugging 'downloadNewPack'

* libgit2.dll for Windows

* rewrite system_enum, disable dangerous function

* fix bug in trigger()

* filter skill

* filter judgement card

* add about page for git2

* very basic general detail

* FKP: status skill

* libgit: android test

* libgit: build for android

* 1

* libgit2.dll

* android: load qm file after copy asset

* filter skill: if no filter skill then remove filtered card

* allow warning and critical to show a popup, and fix warnings from QML

* resource: move general audio/image to packages/

* move assets of cards

* FKP: modify

* use sqlite db to manage packages

* packman cli

* packman gui

* use Popup for error dialog

* android full screen note

* fix android ssl problem
This commit is contained in:
notify 2023-02-15 19:54:35 +08:00 committed by GitHub
parent c6d883eccf
commit cc271bcdf8
300 changed files with 2671 additions and 7001 deletions

2
.gitignore vendored
View File

@ -1,5 +1,6 @@
# Compile output # Compile output
build/ build/
lib/libgit2/
*.o *.o
zh_CN.qm zh_CN.qm
@ -34,6 +35,7 @@ QtQuick/
QtQuick.2/ QtQuick.2/
Qt5Compat/ Qt5Compat/
QtQml/ QtQml/
QtMultimedia/
sqldrivers/ sqldrivers/
styles/ styles/
tls/ tls/

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "fkparse"] [submodule "fkparse"]
path = fkparse path = fkparse
url = https://github.com/Notify-ctrl/fkparse url = https://github.com/Notify-ctrl/fkparse
[submodule "include"]
path = include
url = https://github.com/Notify-ctrl/fk_headers

View File

@ -27,7 +27,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(REQUIRED_QT_VERSION "6.3") set(REQUIRED_QT_VERSION "6.3")
include_directories(include/lua) include_directories(include/lua)
include_directories(include/sqlite3) include_directories(include)
include_directories(include/libgit2)
include_directories(src) include_directories(src)
include_directories(src/client) include_directories(src/client)
include_directories(src/core) include_directories(src/core)

View File

@ -6,6 +6,7 @@
android:versionName="1.0"> android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<supports-screens <supports-screens
android:anyDensity="true" android:anyDensity="true"

View File

@ -15,7 +15,13 @@ cp -r ../audio assets/res
cp -r ../fonts assets/res cp -r ../fonts assets/res
cp -r ../image assets/res cp -r ../image assets/res
cp -r ../lua assets/res cp -r ../lua assets/res
cp -r ../packages assets/res # TODO: Windows hosts machine
cp -r /etc/ca-certificates/extracted/cadir assets/res/certs
mkdir assets/res/packages
cp -r ../packages/standard assets/res/packages
cp -r ../packages/standard_cards assets/res/packages
cp -r ../packages/test assets/res/packages
cp ../packages/init.sql assets/res/packages
cp -r ../qml assets/res cp -r ../qml assets/res
cp -r ../server assets/res cp -r ../server assets/res
rm assets/res/server/users.db rm assets/res/server/users.db

View File

@ -92,6 +92,20 @@ ___
用Qt安装器装好Android库然后配置一下android-sdk就能编译了。 用Qt安装器装好Android库然后配置一下android-sdk就能编译了。
(Qt 6.4的刘海屏bug手动往QActivity.java的onCreate函数追加如下代码即可实现完全全屏。这里做个笔记方便复制粘贴等Qt修了再说)
```java
getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);
if (Build.VERSION.SDK_INT > 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下编译 ## WASM下编译

View File

@ -7,3 +7,9 @@ ___
FreeKill 使用 sqlite3 数据库。 FreeKill 使用 sqlite3 数据库。
关于数据库的组织详见server/init.sql。单纯存个用户名和密码而已 关于数据库的组织详见server/init.sql。单纯存个用户名和密码而已
## 服务端用来管理用户的数据库
保存用户名与密码而已。
## 包管理用的数据库

View File

@ -11,3 +11,4 @@ FreeKill采用Qt框架提供底层支持在上层使用lua语言开发。在U
- [游戏逻辑](./gamelogic.md) - [游戏逻辑](./gamelogic.md)
- [数据库](./database.md) - [数据库](./database.md)
- [UI](./ui.md) - [UI](./ui.md)
- [包管理](./package.md)

51
doc/dev/package.md Normal file
View File

@ -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 \<hash\>。
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。

View File

@ -147,3 +147,15 @@ ___
旁观者的处理方式或许可以像观看录像那样过滤所有的request事件。这样就确确实实只能看着了。 旁观者的处理方式或许可以像观看录像那样过滤所有的request事件。这样就确确实实只能看着了。
而不过滤request的旁观就可以理解为操控其他玩家了。hhh 而不过滤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专门适配旁观者。

@ -1 +1 @@
Subproject commit bbf45faf7dd67fca4bedf535c14a8037990a7399 Subproject commit d150d2eec986c49a16f9e84772525a4fb7a84926

BIN
image/generals/0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
image/logo/git2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

1
include Submodule

@ -0,0 +1 @@
Subproject commit 4fd2070d099d1f967d1070d72beb0fae2cb6e4be

View File

@ -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

View File

@ -1,252 +0,0 @@
# 1 "./lua/lauxlib.h"
#ifndef lauxlib_h
#define lauxlib_h
#include <stddef.h>
#include <stdio.h>
#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 <assert.h>
#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

View File

@ -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

View File

@ -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 <limits.h>
#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 <ctype.h>
#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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
};

View File

@ -1,92 +0,0 @@
# 1 "./lua/llex.h"
#ifndef llex_h
#define llex_h
#include <limits.h>
#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

View File

@ -1,321 +0,0 @@
# 1 "./lua/llimits.h"
#ifndef llimits_h
#define llimits_h
#include <limits.h>
#include <stddef.h>
#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 <assert.h>
#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

View File

@ -1,74 +0,0 @@
# 1 "./lua/lmem.h"
#ifndef lmem_h
#define lmem_h
#include <stddef.h>
#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

View File

@ -1,627 +0,0 @@
# 1 "./lua/lobject.h"
#ifndef lobject_h
#define lobject_h
#include <stdarg.h>
#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

View File

@ -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<<SIZE_Bx)-1)
#else
#define MAXARG_Bx MAX_INT
#endif
#define OFFSET_sBx (MAXARG_Bx>>1)
#if L_INTHASBITS(SIZE_Ax)
#define MAXARG_Ax ((1<<SIZE_Ax)-1)
#else
#define MAXARG_Ax MAX_INT
#endif
#if L_INTHASBITS(SIZE_sJ)
#define MAXARG_sJ ((1 << SIZE_sJ) - 1)
#else
#define MAXARG_sJ MAX_INT
#endif
#define OFFSET_sJ (MAXARG_sJ >> 1)
#define MAXARG_A ((1<<SIZE_A)-1)
#define MAXARG_B ((1<<SIZE_B)-1)
#define MAXARG_C ((1<<SIZE_C)-1)
#define OFFSET_sC (MAXARG_C >> 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_OP)&MASK1(SIZE_OP,POS_OP))))
#define checkopm(i,m) (getOpMode(GET_OPCODE(i)) == m)
#define getarg(i,pos,size) (cast_int(((i)>>(pos)) & MASK1(size,0)))
#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \
((cast(Instruction, v)<<pos)&MASK1(size,pos))))
#define GETARG_A(i) getarg(i, POS_A, SIZE_A)
#define SETARG_A(i,v) setarg(i, v, POS_A, SIZE_A)
#define GETARG_B(i) check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B))
#define GETARG_sB(i) sC2int(GETARG_B(i))
#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B)
#define GETARG_C(i) check_exp(checkopm(i, iABC), getarg(i, POS_C, SIZE_C))
#define GETARG_sC(i) sC2int(GETARG_C(i))
#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C)
#define TESTARG_k(i) check_exp(checkopm(i, iABC), (cast_int(((i) & (1u << POS_k)))))
#define GETARG_k(i) check_exp(checkopm(i, iABC), getarg(i, POS_k, 1))
#define SETARG_k(i,v) setarg(i, v, POS_k, 1)
#define GETARG_Bx(i) check_exp(checkopm(i, iABx), getarg(i, POS_Bx, SIZE_Bx))
#define SETARG_Bx(i,v) setarg(i, v, POS_Bx, SIZE_Bx)
#define GETARG_Ax(i) check_exp(checkopm(i, iAx), getarg(i, POS_Ax, SIZE_Ax))
#define SETARG_Ax(i,v) setarg(i, v, POS_Ax, SIZE_Ax)
#define GETARG_sBx(i) \
check_exp(checkopm(i, iAsBx), getarg(i, POS_Bx, SIZE_Bx) - OFFSET_sBx)
#define SETARG_sBx(i,b) SETARG_Bx((i),cast_uint((b)+OFFSET_sBx))
#define GETARG_sJ(i) \
check_exp(checkopm(i, isJ), getarg(i, POS_sJ, SIZE_sJ) - OFFSET_sJ)
#define SETARG_sJ(i,j) \
setarg(i, cast_uint((j)+OFFSET_sJ), POS_sJ, SIZE_sJ)
#define CREATE_ABCk(o,a,b,c,k) ((cast(Instruction, o)<<POS_OP) \
| (cast(Instruction, a)<<POS_A) \
| (cast(Instruction, b)<<POS_B) \
| (cast(Instruction, c)<<POS_C) \
| (cast(Instruction, k)<<POS_k))
#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
| (cast(Instruction, a)<<POS_A) \
| (cast(Instruction, bc)<<POS_Bx))
#define CREATE_Ax(o,a) ((cast(Instruction, o)<<POS_OP) \
| (cast(Instruction, a)<<POS_Ax))
#define CREATE_sJ(o,j,k) ((cast(Instruction, o) << POS_OP) \
| (cast(Instruction, j) << POS_sJ) \
| (cast(Instruction, k) << POS_k))
#if !defined(MAXINDEXRK)
#define MAXINDEXRK MAXARG_B
#endif
#define NO_REG MAXARG_A
# 197 "./lua/lopcodes.h"
typedef enum {
OP_MOVE,
OP_LOADI,
OP_LOADF,
OP_LOADK,
OP_LOADKX,
OP_LOADFALSE,
OP_LFALSESKIP,
OP_LOADTRUE,
OP_LOADNIL,
OP_GETUPVAL,
OP_SETUPVAL,
OP_GETTABUP,
OP_GETTABLE,
OP_GETI,
OP_GETFIELD,
OP_SETTABUP,
OP_SETTABLE,
OP_SETI,
OP_SETFIELD,
OP_NEWTABLE,
OP_SELF,
OP_ADDI,
OP_ADDK,
OP_SUBK,
OP_MULK,
OP_MODK,
OP_POWK,
OP_DIVK,
OP_IDIVK,
OP_BANDK,
OP_BORK,
OP_BXORK,
OP_SHRI,
OP_SHLI,
OP_ADD,
OP_SUB,
OP_MUL,
OP_MOD,
OP_POW,
OP_DIV,
OP_IDIV,
OP_BAND,
OP_BOR,
OP_BXOR,
OP_SHL,
OP_SHR,
OP_MMBIN,
OP_MMBINI,
OP_MMBINK,
OP_UNM,
OP_BNOT,
OP_NOT,
OP_LEN,
OP_CONCAT,
OP_CLOSE,
OP_TBC,
OP_JMP,
OP_EQ,
OP_LT,
OP_LE,
OP_EQK,
OP_EQI,
OP_LTI,
OP_LEI,
OP_GTI,
OP_GEI,
OP_TEST,
OP_TESTSET,
OP_CALL,
OP_TAILCALL,
OP_RETURN,
OP_RETURN0,
OP_RETURN1,
OP_FORLOOP,
OP_FORPREP,
OP_TFORPREP,
OP_TFORCALL,
OP_TFORLOOP,
OP_SETLIST,
OP_CLOSURE,
OP_VARARG,
OP_VARARGPREP,
OP_EXTRAARG
} OpCode;
#define NUM_OPCODES ((int)(OP_EXTRAARG) + 1)
# 381 "./lua/lopcodes.h"
LUAI_DDEC(const lu_byte luaP_opmodes[NUM_OPCODES];)
#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 7))
#define testAMode(m) (luaP_opmodes[m] & (1 << 3))
#define testTMode(m) (luaP_opmodes[m] & (1 << 4))
#define testITMode(m) (luaP_opmodes[m] & (1 << 5))
#define testOTMode(m) (luaP_opmodes[m] & (1 << 6))
#define testMMMode(m) (luaP_opmodes[m] & (1 << 7))
#define isOT(i) \
((testOTMode(GET_OPCODE(i)) && GETARG_C(i) == 0) || \
GET_OPCODE(i) == OP_TAILCALL)
#define isIT(i) (testITMode(GET_OPCODE(i)) && GETARG_B(i) == 0)
#define opmode(mm,ot,it,t,a,m) \
(((mm) << 7) | ((ot) << 6) | ((it) << 5) | ((t) << 4) | ((a) << 3) | (m))
#define LFIELDS_PER_FLUSH 50
#endif

View File

@ -1,103 +0,0 @@
# 1 "./lua/lopnames.h"
#if !defined(lopnames_h)
#define lopnames_h
#include <stddef.h>
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

View File

@ -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

View File

@ -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

View File

@ -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 <signal.h>
#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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,458 +0,0 @@
# 1 "./lua/lua.h"
# 9 "./lua/lua.h"
#ifndef lua_h
#define lua_h
#include <stdarg.h>
#include <stddef.h>
#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

View File

@ -1,6 +0,0 @@
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}

View File

@ -1,474 +0,0 @@
# 1 "./lua/luaconf.h"
#ifndef luaconf_h
#define luaconf_h
#include <limits.h>
#include <stddef.h>
# 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 <stdint.h>
#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 <assert.h>
#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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,10 @@
<source>Console start</source> <source>Console start</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>PackageManage</source>
<translation></translation>
</message>
</context> </context>
<context> <context>
@ -68,4 +72,56 @@
<translation></translation> <translation></translation>
</message> </message>
</context> </context>
<context>
<name>PackageManage</name>
<message>
<source>Quit</source>
<translation>退</translation>
</message>
<message>
<source>Install From URL</source>
<translation>URL安装</translation>
</message>
<message>
<source>Enable</source>
<translation></translation>
</message>
<message>
<source>Disable</source>
<translation></translation>
</message>
<message>
<source>Enabled</source>
<translation></translation>
</message>
<message>
<source>Disabled</source>
<translation></translation>
</message>
<message>
<source>Remove</source>
<translation></translation>
</message>
<message>
<source>Upgrade</source>
<translation></translation>
</message>
<message>
<source>Name</source>
<translation></translation>
</message>
<message>
<source>Version</source>
<translation></translation>
</message>
<message>
<source>Copy URL</source>
<translation>URL</translation>
</message>
<message>
<source>Copied.</source>
<translation></translation>
</message>
</context>
</TS> </TS>

BIN
lib/android/libcrypto.so Executable file

Binary file not shown.

Binary file not shown.

BIN
lib/android/libgit2.so Normal file

Binary file not shown.

BIN
lib/android/libssl.so Executable file

Binary file not shown.

BIN
lib/win/libgit2.dll Executable file

Binary file not shown.

View File

@ -2,6 +2,7 @@
---@field client fk.Client ---@field client fk.Client
---@field players ClientPlayer[] ---@field players ClientPlayer[]
---@field alive_players ClientPlayer[] ---@field alive_players ClientPlayer[]
---@field observers ClientPlayer[]
---@field current ClientPlayer ---@field current ClientPlayer
---@field discard_pile integer[] ---@field discard_pile integer[]
---@field status_skills Skill[] ---@field status_skills Skill[]
@ -28,6 +29,7 @@ function Client:initialize()
self.players = {} -- ClientPlayer[] self.players = {} -- ClientPlayer[]
self.alive_players = {} self.alive_players = {}
self.observers = {}
self.discard_pile = {} self.discard_pile = {}
self.status_skills = {} self.status_skills = {}
for class, skills in pairs(Fk.global_status_skill) do for class, skills in pairs(Fk.global_status_skill) do
@ -80,6 +82,8 @@ function Client:moveCards(moves)
elseif move.toArea == Card.DiscardPile then elseif move.toArea == Card.DiscardPile then
table.insert(self.discard_pile, move.ids[1]) table.insert(self.discard_pile, move.ids[1])
end end
Fk:filterCard(move.ids[1], move.to == Self.id and Self or nil)
end end
end end
@ -122,7 +126,7 @@ function Client:appendLog(msg)
else else
local card_str = {} local card_str = {}
for _, id in ipairs(card) do for _, id in ipairs(card) do
table.insert(card_str, Fk:getCardById(id):toLogString()) table.insert(card_str, Fk:getCardById(id, true):toLogString())
end end
if unknownCount > 0 then if unknownCount > 0 then
table.insert(card_str, Fk:translate("unknown_card") table.insert(card_str, Fk:translate("unknown_card")
@ -200,6 +204,31 @@ fk.client_callback["RemovePlayer"] = function(jsonData)
end end
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) fk.client_callback["ArrangeSeats"] = function(jsonData)
local data = json.decode(jsonData) local data = json.decode(jsonData)
local n = #ClientInstance.players local n = #ClientInstance.players
@ -365,15 +394,28 @@ fk.client_callback["SetPlayerMark"] = function(jsonData)
local player, mark, value = data[1], data[2], data[3] local player, mark, value = data[1], data[2], data[3]
ClientInstance:getPlayerById(player):setMark(mark, value) 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 end
fk.client_callback["Chat"] = function(jsonData) fk.client_callback["Chat"] = function(jsonData)
-- jsonData: { int type, string msg } -- jsonData: { int type, string msg }
local data = json.decode(jsonData) local data = json.decode(jsonData)
local p = ClientInstance:getPlayerById(data.type) local p = ClientInstance:getPlayerById(data.type)
data.userName = p.player:getScreenName() -- 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 data.general = p.general
end
data.userName = p.player:getScreenName()
data.time = os.date("%H:%M:%S") data.time = os.date("%H:%M:%S")
ClientInstance:notifyUI("Chat", json.encode(data)) ClientInstance:notifyUI("Chat", json.encode(data))
end end

View File

@ -8,12 +8,40 @@ function GetGeneralData(name)
local general = Fk.generals[name] local general = Fk.generals[name]
if general == nil then general = Fk.generals["diaochan"] end if general == nil then general = Fk.generals["diaochan"] end
return json.encode { return json.encode {
package = general.package.name,
extension = general.package.extensionName,
kingdom = general.kingdom, kingdom = general.kingdom,
hp = general.hp, hp = general.hp,
maxHp = general.maxHp maxHp = general.maxHp
} }
end 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 = { local cardSubtypeStrings = {
[Card.SubtypeNone] = "none", [Card.SubtypeNone] = "none",
[Card.SubtypeDelayedTrick] = "delayed_trick", [Card.SubtypeDelayedTrick] = "delayed_trick",
@ -25,7 +53,7 @@ local cardSubtypeStrings = {
} }
function GetCardData(id) function GetCardData(id)
local card = Fk.cards[id] local card = Fk:getCardById(id)
if card == nil then return json.encode{ if card == nil then return json.encode{
cid = id, cid = id,
known = false known = false
@ -33,11 +61,17 @@ function GetCardData(id)
local ret = { local ret = {
cid = id, cid = id,
name = card.name, name = card.name,
extension = card.package.extensionName,
number = card.number, number = card.number,
suit = card:getSuitString(), suit = card:getSuitString(),
color = card.color, color = card.color,
subtype = cardSubtypeStrings[card.sub_type] 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) return json.encode(ret)
end end
@ -187,6 +221,7 @@ function GetSkillData(skill_name)
return json.encode{ return json.encode{
skill = Fk:translate(skill_name), skill = Fk:translate(skill_name),
orig_skill = skill_name, orig_skill = skill_name,
extension = skill.package.extensionName,
freq = freq freq = freq
} }
end end
@ -332,6 +367,7 @@ Fk:loadTranslationTable{
-- Lobby -- Lobby
["Room List"] = "房间列表", ["Room List"] = "房间列表",
["Enter"] = "进入", ["Enter"] = "进入",
["Observe"] = "旁观",
["Edit Profile"] = "编辑个人信息", ["Edit Profile"] = "编辑个人信息",
["Username"] = "用户名", ["Username"] = "用户名",
@ -340,11 +376,15 @@ Fk:loadTranslationTable{
["New Password"] = "新密码", ["New Password"] = "新密码",
["Update Avatar"] = "更新头像", ["Update Avatar"] = "更新头像",
["Update Password"] = "更新密码", ["Update Password"] = "更新密码",
["Lobby BG"] = "大厅壁纸",
["Room BG"] = "房间背景",
["Game BGM"] = "游戏BGM",
["Create Room"] = "创建房间", ["Create Room"] = "创建房间",
["Room Name"] = "房间名字", ["Room Name"] = "房间名字",
["$RoomName"] = "%1的房间", ["$RoomName"] = "%1的房间",
["Player num"] = "玩家数目", ["Player num"] = "玩家数目",
["Enable free assign"] = "自由选将",
["Generals Overview"] = "武将一览", ["Generals Overview"] = "武将一览",
["Cards Overview"] = "卡牌一览", ["Cards Overview"] = "卡牌一览",
@ -374,6 +414,10 @@ Fk:loadTranslationTable{
"SQLite是一个轻量级的数据库具有占用资源低、运行效率快、嵌入性好等优点。<br/>" .. "SQLite是一个轻量级的数据库具有占用资源低、运行效率快、嵌入性好等优点。<br/>" ..
"<br/>FreeKill使用sqlite3在服务端保存用户的各种信息。<br/>" .. "<br/>FreeKill使用sqlite3在服务端保存用户的各种信息。<br/>" ..
"<br/>官网: https://www.sqlite.org", "<br/>官网: https://www.sqlite.org",
["about_git2_description"] = "<b>关于Libgit2</b><br/>" ..
"Libgit2是一个轻量级的、跨平台的、纯C实现的库支持Git的大部分核心操作并且支持几乎任何能与C语言交互的编程语言。<br/>" ..
"<br/>FreeKill使用的是libgit2的C API与此同时使用Git完成拓展包的下载、更新、管理等等功能。<br/>" ..
"<br/>官网: https://libgit2.org",
["Exit Lobby"] = "退出大厅", ["Exit Lobby"] = "退出大厅",
@ -421,6 +465,8 @@ Fk:loadTranslationTable{
["Sort Cards"] = "牌序", ["Sort Cards"] = "牌序",
["Chat"] = "聊天", ["Chat"] = "聊天",
["Log"] = "战报", ["Log"] = "战报",
["Trusting ..."] = "托管中 ...",
["Observing ..."] = "旁观中 ...",
["$GameOver"] = "游戏结束", ["$GameOver"] = "游戏结束",
["$Winner"] = "%1 获胜", ["$Winner"] = "%1 获胜",
@ -457,17 +503,6 @@ Fk:loadTranslationTable{
["#LoseSkill"] = "%from 失去了技能“%arg”", ["#LoseSkill"] = "%from 失去了技能“%arg”",
-- moveCards (they are sent by notifyMoveCards) -- moveCards (they are sent by notifyMoveCards)
["unknown_card"] = '<font color="#B5BA00"><b>未知牌</b></font>',
["log_spade"] = "",
["log_heart"] = '<font color="#CC3131">♥</font>',
["log_club"] = "",
["log_diamond"] = '<font color="#CC3131">♦</font>',
["log_nosuit"] = "无花色",
["nosuit"] = "无花色",
["spade"] = "黑桃",
["heart"] = "红桃",
["club"] = "梅花",
["diamond"] = "方块",
["$DrawCards"] = "%from 摸了 %arg 张牌 %card", ["$DrawCards"] = "%from 摸了 %arg 张牌 %card",
["$DiscardCards"] = "%from 弃置了 %arg 张牌 %card", ["$DiscardCards"] = "%from 弃置了 %arg 张牌 %card",
@ -491,6 +526,8 @@ Fk:loadTranslationTable{
["#UseV0CardToCard"] = "%from 使用了 %arg2目标是 %arg", ["#UseV0CardToCard"] = "%from 使用了 %arg2目标是 %arg",
["#ResponsePlayV0Card"] = "%from 打出了 %arg", ["#ResponsePlayV0Card"] = "%from 打出了 %arg",
["#FilterCard"] = "由于 %arg 的效果,与 %from 相关的 %arg2 被视为了 %arg3",
-- skill -- skill
["#InvokeSkill"] = "%from 发动了 “%arg”", ["#InvokeSkill"] = "%from 发动了 “%arg”",

View File

@ -10,6 +10,7 @@
---@field sub_type CardSubtype ---@field sub_type CardSubtype
---@field area CardArea ---@field area CardArea
---@field subcards integer[] ---@field subcards integer[]
---@field skillName string @ for virtual cards
local Card = class("Card") local Card = class("Card")
---@alias Suit integer ---@alias Suit integer
@ -76,6 +77,7 @@ function Card:initialize(name, suit, number, color)
self.sub_type = Card.SubTypeNone self.sub_type = Card.SubTypeNone
self.skill = nil self.skill = nil
self.subcards = {} self.subcards = {}
self.skillName = ""
end end
---@param suit Suit ---@param suit Suit
@ -174,6 +176,18 @@ function Card:getColorString()
return "nocolor" return "nocolor"
end 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) local function getNumberStr(num)
if num == 1 then if num == 1 then
return "A" return "A"

View File

@ -63,7 +63,8 @@ function Engine:loadPackages()
table.removeOne(directories, "standard_cards") table.removeOne(directories, "standard_cards")
for _, dir in ipairs(directories) do 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)) local pack = require(string.format("packages.%s", dir))
-- Note that instance of Package is a table too -- Note that instance of Package is a table too
-- so dont use type(pack) == "table" here -- so dont use type(pack) == "table" here
@ -148,8 +149,10 @@ function Engine:addCard(card)
card.id = cardId card.id = cardId
cardId = cardId + 1 cardId = cardId + 1
table.insert(self.cards, card) table.insert(self.cards, card)
if _card_name_table[card.name] == nil then
_card_name_table[card.name] = card _card_name_table[card.name] = card
end end
end
---@param cards Card[] ---@param cards Card[]
function Engine:addCards(cards) function Engine:addCards(cards)
@ -165,7 +168,9 @@ end
function Engine:cloneCard(name, suit, number) function Engine:cloneCard(name, suit, number)
local cd = _card_name_table[name] local cd = _card_name_table[name]
assert(cd, "Attempt to clone a card that not added to engine") 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 end
---@param num integer ---@param num integer
@ -232,10 +237,81 @@ function Engine:getAllCardIds(except)
return result return result
end end
local filtered_cards = {}
---@param id integer ---@param id integer
---@param ignoreFilter boolean
---@return Card ---@return Card
function Engine:getCardById(id) function Engine:getCardById(id, ignoreFilter)
return self.cards[id] 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 end
function Engine:currentRoom() function Engine:currentRoom()
@ -245,4 +321,8 @@ function Engine:currentRoom()
return RoomInstance return RoomInstance
end end
function Engine:getDescription(name)
return self:translate(":" .. name)
end
return Engine return Engine

View File

@ -34,6 +34,7 @@ function General:addSkill(skill)
table.insert(self.other_skills, skill) table.insert(self.other_skills, skill)
elseif (skill.class and skill.class:isSubclassOf(Skill)) then elseif (skill.class and skill.class:isSubclassOf(Skill)) then
table.insert(self.skills, skill) table.insert(self.skills, skill)
skill.package = self.package
end end
end end

View File

@ -1,5 +1,6 @@
---@class Package : Object ---@class Package : Object
---@field name string ---@field name string
---@field extensionName string
---@field type PackageType ---@field type PackageType
---@field generals General[] ---@field generals General[]
---@field extra_skills Skill[] ---@field extra_skills Skill[]
@ -17,6 +18,7 @@ function Package:initialize(name, _type)
assert(type(name) == "string") assert(type(name) == "string")
assert(type(_type) == "nil" or type(_type) == "number") assert(type(_type) == "nil" or type(_type) == "number")
self.name = name self.name = name
self.extensionName = name -- used for get assets
self.type = _type or Package.GeneralPack self.type = _type or Package.GeneralPack
self.generals = {} self.generals = {}

View File

@ -127,6 +127,10 @@ function Player:clearFlags()
self.flag = {} self.flag = {}
end 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) function Player:addMark(mark, count)
count = count or 1 count = count or 1
local num = self.mark[mark] local num = self.mark[mark]
@ -255,6 +259,11 @@ function Player:getCardIds(playerAreas, specialName)
return cardIds return cardIds
end end
-- for fkp only
function Player:getHandcardNum()
return #self:getCardIds(Player.Hand)
end
---@param cardSubtype CardSubtype ---@param cardSubtype CardSubtype
---@return integer|null ---@return integer|null
function Player:getEquipment(cardSubtype) function Player:getEquipment(cardSubtype)
@ -560,4 +569,15 @@ function Player:loseSkill(skill, source_skill)
return ret return ret
end 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 return Player

View File

@ -1,5 +1,6 @@
---@class Skill : Object ---@class Skill : Object
---@field name string ---@field name string
---@field package Package
---@field frequency Frequency ---@field frequency Frequency
---@field visible boolean ---@field visible boolean
---@field mute boolean ---@field mute boolean
@ -18,6 +19,10 @@ Skill.Wake = 5
function Skill:initialize(name, frequency) function Skill:initialize(name, frequency)
-- TODO: visible, lord, etc -- TODO: visible, lord, etc
self.name = name 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.frequency = frequency
self.visible = true self.visible = true
self.mute = false self.mute = false

View File

@ -48,6 +48,10 @@ end
---@param cardUseEvent CardUseStruct ---@param cardUseEvent CardUseStruct
function ActiveSkill:onUse(room, cardUseEvent) end function ActiveSkill:onUse(room, cardUseEvent) end
---@param room Room
---@param cardEffectEvent CardEffectEvent | SkillEffectEvent
function ActiveSkill:aboutToEffect(room, cardEffectEvent) end
---@param room Room ---@param room Room
---@param cardEffectEvent CardEffectEvent | SkillEffectEvent ---@param cardEffectEvent CardEffectEvent | SkillEffectEvent
function ActiveSkill:onEffect(room, cardEffectEvent) end function ActiveSkill:onEffect(room, cardEffectEvent) end

View File

@ -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

View File

@ -10,6 +10,7 @@ ProhibitSkill = require "core.skill_type.prohibit"
AttackRangeSkill = require "core.skill_type.attack_range" AttackRangeSkill = require "core.skill_type.attack_range"
MaxCardsSkill = require "core.skill_type.max_cards" MaxCardsSkill = require "core.skill_type.max_cards"
TargetModSkill = require "core.skill_type.target_mod" TargetModSkill = require "core.skill_type.target_mod"
FilterSkill = require "core.skill_type.filter"
BasicCard = require "core.card_type.basic" BasicCard = require "core.card_type.basic"
local Trick = require "core.card_type.trick" 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 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 feasible fun(self: ActiveSkill, selected: integer[], selected_cards: integer[]): boolean
---@field on_use fun(self: ActiveSkill, room: Room, cardUseEvent: CardUseStruct): 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_effect fun(self: ActiveSkill, room: Room, cardEffectEvent: CardEffectEvent): boolean
---@field on_nullified 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.target_filter then skill.targetFilter = spec.target_filter end
if spec.feasible then skill.feasible = spec.feasible end if spec.feasible then skill.feasible = spec.feasible end
if spec.on_use then skill.onUse = spec.on_use 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_effect then skill.onEffect = spec.on_effect end
if spec.on_nullified then skill.onNullified = spec.on_nullified end if spec.on_nullified then skill.onNullified = spec.on_nullified end
return skill return skill
@ -292,6 +295,27 @@ function fk.CreateTargetModSkill(spec)
return skill return skill
end 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 ---@class CardSpec: Card
---@field skill Skill ---@field skill Skill

View File

@ -4,6 +4,13 @@
package.path = package.path .. ";./lua/lib/?.lua" package.path = package.path .. ";./lua/lib/?.lua"
.. ";./lua/?.lua" .. ";./lua/?.lua"
-- disable dangerous functions
os.remove = nil
os.execute = nil
os.exit = nil
os.rename = nil
io = nil
-- load libraries -- load libraries
class = require "middleclass" class = require "middleclass"

View File

@ -5,64 +5,299 @@
-- In most cases, fk's basic modules are loaded before extension calls -- In most cases, fk's basic modules are loaded before extension calls
-- "require 'fkparser'", so we needn't to import lua modules here. -- "require 'fkparser'", so we needn't to import lua modules here.
fkp = { local string2suit = {
functions = {}, spade = Card.Spade,
newlist = function(t) club = Card.Club,
t.length = function(self) heart = Card.Heart,
return #self diamond = Card.Diamond,
end, no_suit = Card.NoSuit,
no_suit_black = Card.NoSuitBlack,
t.prepend = function(self, element) no_suit_red = Card.NoSuitRed,
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,
} }
fkp.functions.prepend = function(arr, e) local fkp = { functions = {} }
if arr:length() == 0 then
arr = fkp.newlist{e} fkp.functions.prepend = function(arr, e) table.insert(arr, 1, e) end
else fkp.functions.append = function(arr, e) table.insert(arr, e) end
arr:prepend(e) 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 end
return arr
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, end,
fkp.functions.append = function(arr, e) refresh_events = refresh_eve,
if arr:length() == 0 then can_refresh = function(self, event, target, player, data)
arr = fkp.newlist{e} local func = re_specs[event] and re_specs[event][1] or nil
else if not func then
arr:append(e) return TriggerSkill.canRefresh(self, event, target, player, data)
end end
return arr return func(self, target, player, data)
end, 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

View File

@ -142,6 +142,9 @@ function GameLogic:prepareForStart()
for _, s in ipairs(skills) do for _, s in ipairs(skills) do
room:handleAddLoseSkills(p, s.name, nil, false) room:handleAddLoseSkills(p, s.name, nil, false)
end end
for _, sname in ipairs(Fk.generals[p.general].other_skills) do
room:handleAddLoseSkills(p, sname, nil, false)
end
end end
self:addTriggerSkill(GameRule) self:addTriggerSkill(GameRule)
@ -219,15 +222,11 @@ function GameLogic:trigger(event, target, data)
local broken = false local broken = false
local skills = self.skill_table[event] or {} local skills = self.skill_table[event] or {}
local skills_to_refresh = self.refresh_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}) self.event_stack:push({event, target, data})
if target == nil then
target = room.current
player = target
end
repeat do repeat do
-- refresh skills. This should not be broken -- refresh skills. This should not be broken
for _, skill in ipairs(skills_to_refresh) do for _, skill in ipairs(skills_to_refresh) do
@ -236,7 +235,7 @@ function GameLogic:trigger(event, target, data)
end end
end end
player = player.next player = player.next
end until player == target end until player == _target
---@param a TriggerSkill ---@param a TriggerSkill
---@param b TriggerSkill ---@param b TriggerSkill
@ -281,7 +280,7 @@ function GameLogic:trigger(event, target, data)
if broken then break end if broken then break end
player = player.next player = player.next
end until player == target end until player == _target
self.event_stack:pop() self.event_stack:pop()
return broken return broken

View File

@ -2,6 +2,7 @@
---@field room fk.Room ---@field room fk.Room
---@field players ServerPlayer[] ---@field players ServerPlayer[]
---@field alive_players ServerPlayer[] ---@field alive_players ServerPlayer[]
---@field observers fk.ServerPlayer[]
---@field current ServerPlayer ---@field current ServerPlayer
---@field game_finished boolean ---@field game_finished boolean
---@field timeout integer ---@field timeout integer
@ -77,6 +78,7 @@ function Room:initialize(_room)
self.players = {} self.players = {}
self.alive_players = {} self.alive_players = {}
self.observers = {}
self.current = nil self.current = nil
self.game_finished = false self.game_finished = false
self.timeout = _room:getTimeout() self.timeout = _room:getTimeout()
@ -127,6 +129,16 @@ function Room:getCardArea(cardId)
return self.card_place[cardId] or Card.Unknown return self.card_place[cardId] or Card.Unknown
end 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 ---@param id integer
---@return ServerPlayer ---@return ServerPlayer
function Room:getPlayerById(id) function Room:getPlayerById(id)
@ -139,7 +151,7 @@ function Room:getPlayerById(id)
end end
end end
error("cannot find player by " .. id) return nil
end end
---@param playerIds integer[] ---@param playerIds integer[]
@ -309,11 +321,9 @@ end
---@param players ServerPlayer[] | nil @ default all players ---@param players ServerPlayer[] | nil @ default all players
function Room:doBroadcastNotify(command, jsonData, players) function Room:doBroadcastNotify(command, jsonData, players)
players = players or self.players players = players or self.players
local tolist = fk.SPlayerList()
for _, p in ipairs(players) do for _, p in ipairs(players) do
tolist:append(p.serverplayer) p:doNotify(command, jsonData)
end end
self.room:doBroadcastNotify(tolist, command, jsonData)
end end
---@param player ServerPlayer ---@param player ServerPlayer
@ -391,6 +401,71 @@ end
-- main loop for the request handling coroutine -- main loop for the request handling coroutine
function Room:requestLoop() 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 while true do
local request = self.room:fetchRequest() local request = self.room:fetchRequest()
if request ~= "" then if request ~= "" then
@ -398,6 +473,10 @@ function Room:requestLoop()
id = tonumber(id) id = tonumber(id)
if command == "reconnect" then if command == "reconnect" then
self:getPlayerById(id):reconnect() self:getPlayerById(id):reconnect()
elseif command == "observe" then
addObserver(id)
elseif command == "leave" then
removeObserver(id)
end end
end end
coroutine.yield() coroutine.yield()
@ -589,7 +668,7 @@ function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra
local card_data = json.decode(card) local card_data = json.decode(card)
local selected_cards = card_data.subcards local selected_cards = card_data.subcards
self:doIndicate(player.id, targets) self:doIndicate(player.id, targets)
skill:onEffect(self, { skill:onUse(self, {
from = player.id, from = player.id,
cards = selected_cards, cards = selected_cards,
tos = targets, tos = targets,
@ -606,10 +685,11 @@ end
---@param maxNum integer ---@param maxNum integer
---@param includeEquip boolean ---@param includeEquip boolean
---@param skillName string ---@param skillName string
function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName) function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName, cancelable)
if minNum < 1 then if minNum < 1 then
return nil return nil
end end
cancelable = cancelable or false
local toDiscard = {} local toDiscard = {}
local data = { local data = {
@ -619,11 +699,15 @@ function Room:askForDiscard(player, minNum, maxNum, includeEquip, skillName)
reason = skillName reason = skillName
} }
local prompt = "#AskForDiscard:::" .. maxNum .. ":" .. minNum 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 if ret then
toDiscard = ret.cards toDiscard = ret.cards
else else
if cancelable then return {} end
local hands = player:getCardIds(Player.Hand) local hands = player:getCardIds(Player.Hand)
if includeEquip then
table.insertTable(hands, player:getCardIds(Player.Equip))
end
for i = 1, minNum do for i = 1, minNum do
local randomId = hands[math.random(1, #hands)] local randomId = hands[math.random(1, #hands)]
table.insert(toDiscard, randomId) table.insert(toDiscard, randomId)
@ -793,7 +877,7 @@ function Room:handleUseCardReply(player, data)
self:notifySkillInvoked(player, skill.name) self:notifySkillInvoked(player, skill.name)
player:addSkillUseHistory(skill.name) player:addSkillUseHistory(skill.name)
self:doIndicate(player.id, targets) self:doIndicate(player.id, targets)
skill:onEffect(self, { skill:onUse(self, {
from = player.id, from = player.id,
cards = selected_cards, cards = selected_cards,
tos = targets, tos = targets,
@ -914,7 +998,17 @@ end
---@param cardUseEvent CardUseStruct ---@param cardUseEvent CardUseStruct
local sendCardEmotionAndLog = function(room, cardUseEvent) local sendCardEmotionAndLog = function(room, cardUseEvent)
local from = cardUseEvent.from 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) room:setEmotion(room:getPlayerById(from), card.name)
local soundName local soundName
@ -928,11 +1022,12 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
subTypeStr = "armor" subTypeStr = "armor"
end end
soundName = "common/" .. subTypeStr soundName = "./audio/card/common/" .. subTypeStr
else 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 end
room:broadcastPlaySound("./audio/card/" .. soundName) room:broadcastPlaySound(soundName)
room:doAnimate("Indicate", { room:doAnimate("Indicate", {
from = from, from = from,
@ -946,7 +1041,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
table.insert(to, t[1]) table.insert(to, t[1])
end end
if card:isVirtual() then if card:isVirtual() or (card ~= _card) then
if #useCardIds == 0 then if #useCardIds == 0 then
room:sendLog{ room:sendLog{
type = "#UseV0CardToTargets", type = "#UseV0CardToTargets",
@ -985,7 +1080,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
end end
end end
elseif cardUseEvent.toCard then elseif cardUseEvent.toCard then
if card:isVirtual() then if card:isVirtual() or (card ~= _card) then
if #useCardIds == 0 then if #useCardIds == 0 then
room:sendLog{ room:sendLog{
type = "#UseV0CardToCard", type = "#UseV0CardToCard",
@ -1011,7 +1106,7 @@ local sendCardEmotionAndLog = function(room, cardUseEvent)
} }
end end
else else
if card:isVirtual() then if card:isVirtual() or (card ~= _card) then
if #useCardIds == 0 then if #useCardIds == 0 then
room:sendLog{ room:sendLog{
type = "#UseV0Card", type = "#UseV0Card",
@ -1362,6 +1457,7 @@ function Room:doCardEffect(cardEffectEvent)
end end
if event == fk.PreCardEffect then if event == fk.PreCardEffect then
if cardEffectEvent.card.skill:aboutToEffect(self, cardEffectEvent) then return end
if cardEffectEvent.card.name == 'slash' and if cardEffectEvent.card.name == 'slash' and
not ( not (
cardEffectEvent.disresponsive or cardEffectEvent.disresponsive or
@ -1563,6 +1659,7 @@ function Room:moveCards(...)
table.insert(toAreaIds, toAreaIds == Card.DrawPile and 1 or #toAreaIds + 1, info.cardId) table.insert(toAreaIds, toAreaIds == Card.DrawPile and 1 or #toAreaIds + 1, info.cardId)
end end
self:setCardArea(info.cardId, data.toArea, data.to) self:setCardArea(info.cardId, data.toArea, data.to)
Fk:filterCard(info.cardId, self:getPlayerById(data.to))
end end
end end
end end
@ -1692,7 +1789,7 @@ function Room:changeHp(player, num, reason, skillName, damageStruct)
if damageStruct.from then if damageStruct.from then
self:sendLog{ self:sendLog{
type = "#Damage", type = "#Damage",
to = {damageStruct.from}, to = {damageStruct.from.id},
from = player.id, from = player.id,
arg = 0 - num, arg = 0 - num,
arg2 = damage_nature_table[damageStruct.damageType], arg2 = damage_nature_table[damageStruct.damageType],
@ -1810,11 +1907,11 @@ function Room:damage(damageStruct)
return false return false
end end
if damageStruct.from and not self:getPlayerById(damageStruct.from):isAlive() then if damageStruct.from and not damageStruct.from:isAlive() then
damageStruct.from = nil damageStruct.from = nil
end end
assert(type(damageStruct.to) == "number") assert(damageStruct.to:isInstanceOf(ServerPlayer))
local stages = { local stages = {
{fk.PreDamage, damageStruct.from}, {fk.PreDamage, damageStruct.from},
@ -1823,22 +1920,19 @@ function Room:damage(damageStruct)
} }
for _, struct in ipairs(stages) do for _, struct in ipairs(stages) do
local event, playerId = table.unpack(struct) local event, player = table.unpack(struct)
local player = playerId and self:getPlayerById(playerId) or nil
if self.logic:trigger(event, player, damageStruct) or damageStruct.damage < 1 then if self.logic:trigger(event, player, damageStruct) or damageStruct.damage < 1 then
return false return false
end end
assert(type(damageStruct.to) == "number") assert(damageStruct.to:isInstanceOf(ServerPlayer))
end end
assert(self:getPlayerById(damageStruct.to)) if not damageStruct.to:isAlive() then
local victim = self:getPlayerById(damageStruct.to)
if not victim:isAlive() then
return false return false
end 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 return false
end end
@ -1849,8 +1943,7 @@ function Room:damage(damageStruct)
} }
for _, struct in ipairs(stages) do for _, struct in ipairs(stages) do
local event, playerId = table.unpack(struct) local event, player = table.unpack(struct)
local player = playerId and self:getPlayerById(playerId) or nil
self.logic:trigger(event, player, damageStruct) self.logic:trigger(event, player, damageStruct)
end end
@ -1864,7 +1957,7 @@ function Room:recover(recoverStruct)
return false return false
end end
local who = self:getPlayerById(recoverStruct.who) local who = recoverStruct.who
if self.logic:trigger(fk.PreHpRecover, who, recoverStruct) or recoverStruct.num < 1 then if self.logic:trigger(fk.PreHpRecover, who, recoverStruct) or recoverStruct.num < 1 then
return false return false
end end
@ -1914,7 +2007,7 @@ function Room:killPlayer(deathStruct)
if killer then if killer then
self:sendLog{ self:sendLog{
type = "#KillPlayer", type = "#KillPlayer",
to = {killer}, to = {killer.id},
from = victim.id, from = victim.id,
arg = victim.role, arg = victim.role,
} }
@ -2035,6 +2128,7 @@ function Room:judge(data)
self.logic:trigger(fk.AskForRetrial, who, data) self.logic:trigger(fk.AskForRetrial, who, data)
self.logic:trigger(fk.FinishRetrial, who, data) self.logic:trigger(fk.FinishRetrial, who, data)
Fk:filterCard(data.card.id, who, data)
self:sendLog{ self:sendLog{
type = "#JudgeResult", type = "#JudgeResult",
from = who.id, from = who.id,

View File

@ -35,6 +35,13 @@ end
---@param jsonData string ---@param jsonData string
function ServerPlayer:doNotify(command, jsonData) function ServerPlayer:doNotify(command, jsonData)
self.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 end
--- Send a request to client, and allow client to reply within *timeout* seconds. --- 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("EnterLobby", "")
self:doNotify("EnterRoom", json.encode{ self:doNotify("EnterRoom", json.encode{
#room.players, room.timeout, #room.players, room.timeout,
-- FIXME: use real room settings here
{ enableFreeAssign = false }
}) })
room:notifyProperty(self, self, "role") room:notifyProperty(self, self, "role")
-- send player data -- 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{ self:doNotify("AddPlayer", json.encode{
p.id, p.id,
p.serverplayer:getScreenName(), p.serverplayer:getScreenName(),

View File

@ -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 } ---@class CardsMoveInfo
---@alias MoveInfo {cardId: integer, fromArea: CardArea} ---@field ids integer[]
---@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 } ---@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 } ---@class MoveInfo
---@alias HpLostData { num: integer, skillName: string } ---@field cardId integer
---@alias DamageStruct { from: integer|null, to: integer, damage: integer, card: Card, damageType: DamageType, skillName: string } ---@field fromArea CardArea
---@alias RecoverStruct { who: integer, num: integer, recoverBy: integer|null, skillName: string|null }
---@alias DyingStruct { who: integer, damage: DamageStruct } ---@class CardsMoveStruct
---@alias DeathStruct { who: integer, damage: DamageStruct } ---@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 } ---@class HpChangedData
---@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 } ---@field num integer
---@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 } ---@field reason string
---@alias SkillEffectEvent { from: integer, tos: integer[], cards: integer[] } ---@field skillName string
---@alias JudgeStruct { who: ServerPlayer, card: Card, reason: string, pattern: string } ---@class HpLostData
---@alias CardResponseEvent { from: integer, card: Card, responseToEvent: CardEffectEvent|null, skipDrop: boolean|null, customFrom: integer|null } ---@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 ---@alias CardMoveReason integer
@ -31,10 +142,11 @@ fk.ReasonExchange = 8
fk.ReasonUse = 9 fk.ReasonUse = 9
fk.ReasonResonpse = 10 fk.ReasonResonpse = 10
---@alias DamageType integer ---@class LogMessage
---@field type string
fk.NormalDamage = 1 ---@field from integer
fk.ThunderDamage = 2 ---@field to integer[]
fk.FireDamage = 3 ---@field card integer[]
---@field arg any
---@alias LogMessage {type: string, from: integer, to: integer[], card: integer[], arg: any, arg2: any, arg3: any} ---@field arg2 any
---@field arg3 any

7
packages/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
/*
!standard/
!standard_cards/
!test/
!manuvering/
!.gitignore
!init.sql

6
packages/init.sql Normal file
View File

@ -0,0 +1,6 @@
CREATE TABLE packages (
name VARCHAR(128),
url VARCHAR(255),
hash CHAR(40),
enabled BOOLEAN
);

Some files were not shown because too many files have changed in this diff Show More