From 0044f6e24a96c37e61c142a804148c9850f28e0d Mon Sep 17 00:00:00 2001
From: yyc12345
Date: Sun, 21 Jun 2020 16:59:21 +0800
Subject: [PATCH] bug fix and feature
- Fix bug that a pTarget linked to a export pin will raise error.
- Fix bug that a export pOut can't create shortcut correctly.
- Add helper ui in viewer.
- Use std lib rewrite entire exporter.
---
README_ZH.md | 21 +-
SuperScriptMaterializer/database.cpp | 483 ++++++++++--------
SuperScriptMaterializer/database.h | 91 ++--
SuperScriptMaterializer/env_export.cpp | 40 +-
SuperScriptMaterializer/env_export.h | 2 -
SuperScriptMaterializer/script_export.cpp | 104 ++--
SuperScriptViewer/DecoratorCore.py | 39 +-
SuperScriptViewer/ServerCore.py | 4 +-
SuperScriptViewer/SuperScriptViewer.py | 4 +-
.../static/{site.css => viewer.css} | 0
.../static/{site.js => viewer.js} | 0
SuperScriptViewer/templates/about.html | 2 +
SuperScriptViewer/templates/help.html | 16 +-
.../templates/help/converter.html | 50 ++
.../templates/help/env_database.html | 0
15 files changed, 508 insertions(+), 348 deletions(-)
rename SuperScriptViewer/static/{site.css => viewer.css} (100%)
rename SuperScriptViewer/static/{site.js => viewer.js} (100%)
create mode 100644 SuperScriptViewer/templates/help/converter.html
create mode 100644 SuperScriptViewer/templates/help/env_database.html
diff --git a/README_ZH.md b/README_ZH.md
index 554d73d..41a1dae 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -6,7 +6,7 @@
将Virtools文档中的所有脚本导出成一个SQLite数据库文件,然后经过Python进行排布处理,最后提供一个本地Web前端查看脚本。这同样适用于`Script Hidden`的Virtools脚本,也适用于其中含有不可展开的`Behavior Graph`的脚本。
-物化器不能完全恢复脚本的原有排布,无论原有排布是否存在,物化器都将重新自动生成脚本中的各个元素的位置。某些结构的关系可能会改变(例如Export parameter)但是逻辑思路将不会改变。同时物化器不能将已经生成的结构回写成Virtools可接受的格式,因此物化器只能提供无视脚本隐藏的分析功能。
+物化器不能完全恢复脚本的原有排布,无论原有排布是否存在,物化器都将重新自动生成脚本中的各个元素的位置。某些结构的关系可能会改变(例如Export parameter),亦或者是与Virtools中的呈现不同,但是逻辑思路将不会改变。同时物化器不能将已经生成的结构回写成Virtools可接受的格式,因此物化器只能提供无视脚本隐藏的分析功能。
本工程代码源于另两个工程:[BearKidsTeam/Script-Materializer](https://github.com/BearKidsTeam/Script-Materializer)(该工程用于将指定脚本导出为JSON文档)和[BearKidsTeam/VirtoolsScriptDeobfuscation](https://github.com/BearKidsTeam/VirtoolsScriptDeobfuscation)(该工程能够在Virtools 3.5中提供内置的隐藏脚本解析功能,将解析结果解析为可以被Virtools识别的格式)
@@ -22,16 +22,31 @@
将导出文件重命名为`export.db`并和`SuperScriptViewer.py`放在一起。然后在此目录中运行`python ./SuperScriptViewer.py`,等待Python交互界面提示可以打开本地的网页即可。
+`SuperScriptViewer.py`具有一些命令行开关:
+
+- `-i`:指定输入的`export.db`
+- `-o`:指定输出的`decorated.db`,如果已经存在将不考虑输入,直接使用输出数据库呈现
+- `-e`:指定输入的`env.db`,环境数据库
+- `-f`:无参数,用于强制重新生成输出数据库,无论输出数据库是否存在
+
+以上选项在基本使用中应该不会用到,因此按上述规则直接放置好文件直接运行即可。
+
### 使用注意
- 您需要先安装Virtools, Python和任意一种浏览器才能使用本工程。Python需要先安装`Flask`库。
- 导出插件目前只支持Virtools 5,后期会支持Virtools 3.5
- 导出插件选择完文件后卡住,或者Python交互界面弹出错误堆栈,这可能是设计失误,请附带您引起bug的文件提交bug
-- 如果Python交互界面提示数据库`TEXT`类型解码失败,那么可能您需要手动在`DecoratorCore.py`中指定数据库文本解码方式。因为Virtools使用多字节编码,依赖于当前操作系统的代码页,`DecoratorCore.py`做了特殊获取以保证大多数计算机可以直接运行,但仍然不能排除一些特殊情况。
+- 如果Python交互界面提示数据库`TEXT`类型解码失败,那么可能您需要手动在`CustomConfig.py`中的`database_encoding`中指定数据库文本解码方式。因为Virtools使用多字节编码,依赖于当前操作系统的代码页,`SuperScriptMaterializer`做了特殊获取以保证大多数计算机可以直接运行,但仍然不能排除一些特殊情况。
- 如果您使用本工程的Release页面中提供的已编译好的Virtools界面插件(现在因为仍然在开发所以没有),您需要放入的`sqlite3.dll`版本应为`sqlite-dll-win32-x86-3310100`
## 编译
只有Virtools界面插件需要编译,其余均为解释性语言无需编译。
-需要手动配置Virtools插件的编译参数,例如包含路径等,需要指向您自己的Virtools SDK。对于SQLite SDK,您可以从[sqlite.org](http://www.sqlite.org/)下载,然后使用Visual C++的工具集执行`LIB /DEF:sqlite3.def /machine:IX86`以获取可以用于编译的文件。
\ No newline at end of file
+需要手动配置Virtools插件的编译参数,例如包含路径等,需要指向您自己的Virtools SDK。对于SQLite SDK,您可以从[sqlite.org](http://www.sqlite.org/)下载,然后使用Visual C++的工具集执行`LIB /DEF:sqlite3.def /machine:IX86`以获取可以用于编译的文件。
+
+## 下一版本计划
+
+第一个版本的开发即将告一段落,下一版本的开放将会加入一直搁置的移动功能。
+
+至于之后的企划,可能只包含修复各种Bug的内容,因为已做完应该做完的事情了。
\ No newline at end of file
diff --git a/SuperScriptMaterializer/database.cpp b/SuperScriptMaterializer/database.cpp
index b715c73..08dc1f8 100644
--- a/SuperScriptMaterializer/database.cpp
+++ b/SuperScriptMaterializer/database.cpp
@@ -16,7 +16,11 @@ void dbScriptDataStructHelper::init(CKParameterManager* paramManager) {
_db_pLocalData = new db_pLocalData();
_db_pOper = new db_pOper();
_db_eLink = new db_eLink();
+
_parameterManager = paramManager;
+ _stringCache = (char*)malloc(STRINGCACHE_SIZE * sizeof(char));
+ if (_stringCache == NULL)
+ throw new std::bad_alloc();
}
void dbScriptDataStructHelper::dispose() {
@@ -33,7 +37,9 @@ void dbScriptDataStructHelper::dispose() {
delete _db_pLocal;
delete _db_pOper;
delete _db_eLink;
+
_parameterManager = NULL;
+ free(_stringCache);
}
void dbEnvDataStructHelper::init() {
@@ -42,6 +48,10 @@ void dbEnvDataStructHelper::init() {
_db_envMsg = new db_envMsg;
_db_envAttr = new db_envAttr;
_db_envPlugin = new db_envPlugin;
+
+ _stringCache = (char*)malloc(STRINGCACHE_SIZE * sizeof(char));
+ if (_stringCache == NULL)
+ throw new std::bad_alloc();
}
void dbEnvDataStructHelper::dispose() {
@@ -50,6 +60,8 @@ void dbEnvDataStructHelper::dispose() {
delete _db_envMsg;
delete _db_envAttr;
delete _db_envPlugin;
+
+ free(_stringCache);
}
#pragma endregion
@@ -59,8 +71,7 @@ void dbEnvDataStructHelper::dispose() {
void database::open(const char* file) {
db = NULL;
- errmsg = (char*)calloc(256, sizeof(char));
- commandStr = (char*)calloc(2048, sizeof(char));
+ stmtCache = new std::vector(13, NULL);
//open db
int result;
@@ -82,139 +93,148 @@ void database::close() {
//release res
sqlite3_close(db);
db = NULL;
-
- free(errmsg);
- free(commandStr);
+ delete stmtCache;
}
BOOL scriptDatabase::init() {
int result;
- result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg);
+ result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
//init table
- result = sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
+ result = sqlite3_exec(db, "begin;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE script([thisobj] INTEGER, [name] TEXT, [index] INTEGER, [behavior] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE behavior([thisobj] INTEGER, [name] TEXT, [type] INTEGER, [proto_name] TEXT, [proto_guid] TEXT, [flags] INTEGER, [priority] INTEGER, [version] INTEGER, [pin_count] TEXT, [parent] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pTarget([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bLink([input] INTEGER, [output] INTEGER, [delay] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLocal([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [is_setting] INTEGER, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLocalData([field] TEXT, [data] TEXT, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLink([input] INTEGER, [output] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_is_bb] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_is_bb] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pOper([thisobj] INTEGER, [op] TEXT, [op_guid] TEXT, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE eLink([export_obj] INTEGER, [internal_obj] INTEGER, [is_in] INTEGER, [index] INTEGER, [belong_to] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
- result = sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
+ result = sqlite3_exec(db, "commit;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
//start job
- sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
+ sqlite3_exec(db, "begin;", NULL, NULL, NULL);
return TRUE;
}
BOOL scriptDatabase::finalJob() {
//stop job
- sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
+ for (auto it = stmtCache->begin(); it != stmtCache->end(); it++) {
+ if (*it != NULL)
+ sqlite3_finalize(*it);
+ }
+ sqlite3_exec(db, "commit;", NULL, NULL, NULL);
//create index for quick select in following app
- /*sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
- sqlite3_exec(db, "CREATE INDEX [quick_where1] ON bIn (thisobj)", NULL, NULL, &errmsg);
- sqlite3_exec(db, "CREATE INDEX [quick_where2] ON bOut (thisobj)", NULL, NULL, &errmsg);
- sqlite3_exec(db, "CREATE INDEX [quick_where3] ON pIn (thisobj)", NULL, NULL, &errmsg);
- sqlite3_exec(db, "CREATE INDEX [quick_where4] ON pOut (thisobj)", NULL, NULL, &errmsg);
- sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);*/
+ /*sqlite3_exec(db, "begin;", NULL, NULL, NULL);
+ sqlite3_exec(db, "CREATE INDEX [quick_where1] ON bIn (thisobj)", NULL, NULL, NULL);
+ sqlite3_exec(db, "CREATE INDEX [quick_where2] ON bOut (thisobj)", NULL, NULL, NULL);
+ sqlite3_exec(db, "CREATE INDEX [quick_where3] ON pIn (thisobj)", NULL, NULL, NULL);
+ sqlite3_exec(db, "CREATE INDEX [quick_where4] ON pOut (thisobj)", NULL, NULL, NULL);
+ sqlite3_exec(db, "commit;", NULL, NULL, NULL);*/
return TRUE;
}
BOOL envDatabase::init() {
+ stmtCache = new std::vector(5, NULL);
+
+
int result;
- result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg);
+ result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
//init table
- result = sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
+ result = sqlite3_exec(db, "begin;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE op([funcptr] INTEGER, [in1_guid] TEXT, [in2_guid] TEXT, [out_guid] TEXT, [op_guid] INTEGER, [op_name] TEXT, [op_code] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE param([index] INTEGER, [guid] TEXT, [derived_from] TEXT, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] INTEGER, [func_Delete] INTEGER, [func_SaveLoad] INTEGER, [func_Check] INTEGER, [func_Copy] INTEGER, [func_String] INTEGER, [func_UICreator] INTEGER, [creator_dll_index] INTEGER, [creator_plugin_index] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] TEXT);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE msg([index] INTEGER, [name] TEXT);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE attr([index] INTEGER, [name] TEXT, [category_index] INTEGER, [category_name] TEXT, [flags] INTEGER, [param_index] INTEGER, [compatible_classid] INTEGER, [default_value] TEXT);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE plugin([dll_index] INTEGER, [dll_name] TEXT, [plugin_index] INTEGER, [category] TEXT, [active] INTEGER, [needed_by_file] INTEGER, [guid] TEXT, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [func_init] INTEGER, [func_exit] INTEGER);",
- NULL, NULL, &errmsg);
+ NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
- result = sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
+ result = sqlite3_exec(db, "commit;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
//start job
- sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
+ sqlite3_exec(db, "begin;", NULL, NULL, NULL);
return TRUE;
}
BOOL envDatabase::finalJob() {
//stop job
- sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
+ for (auto it = stmtCache->begin(); it != stmtCache->end(); it++) {
+ if (*it != NULL)
+ sqlite3_finalize(*it);
+ }
+ sqlite3_exec(db, "commit;", NULL, NULL, NULL);
return TRUE;
}
@@ -223,293 +243,318 @@ BOOL envDatabase::finalJob() {
#pragma region write func
+#define tryGetStmt(index,defaultStr) stmt=(*stmtCache)[index];if(stmt==NULL){sqlite3_prepare_v2(db,defaultStr,-1,&stmt,NULL);(*stmtCache)[index]=stmt;}
+
void scriptDatabase::write_CKBehavior(dbCKBehavior* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO behavior VALUES (%d, '%s', %d, '%s', '%d, %d', %d, %d, %d, '%s', %d);",
- data->thisobj,
- data->name,
- data->type,
- data->proto_name,
- data->proto_guid[0],
- data->proto_guid[1],
- data->flags,
- data->priority,
- data->version,
- data->pin_count,
- data->parent);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(0, "INSERT INTO behavior VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data->type);
+ sqlite3_bind_text(stmt, 4, data->proto_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data->proto_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 6, data->flags);
+ sqlite3_bind_int(stmt, 7, data->priority);
+ sqlite3_bind_int(stmt, 8, data->version);
+ sqlite3_bind_text(stmt, 9, data->pin_count.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 10, data->parent);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_CKScript(dbCKScript* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO script VALUES (%d, '%s', %d, %d);",
- data->thisobj,
- data->host_name,
- data->index,
- data->behavior);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(1, "INSERT INTO script VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_text(stmt, 2, data->host_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data->index);
+ sqlite3_bind_int(stmt, 4, data->behavior);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_pTarget(db_pTarget* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pTarget VALUES (%d, '%s', '%s', '%d, %d', %d, %d, %d);",
- data->thisobj,
- data->name,
- data->type,
- data->type_guid[0],
- data->type_guid[1],
- data->belong_to,
- data->direct_source,
- data->shared_source);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(2, "INSERT INTO pTarget VALUES (?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data->type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data->type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data->belong_to);
+ sqlite3_bind_int(stmt, 6, data->direct_source);
+ sqlite3_bind_int(stmt, 7, data->shared_source);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_pIn(db_pIn* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pIn VALUES (%d, %d, '%s', '%s', '%d, %d', %d, %d, %d);",
- data->thisobj,
- data->index,
- data->name,
- data->type,
- data->type_guid[0],
- data->type_guid[1],
- data->belong_to,
- data->direct_source,
- data->shared_source);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(3, "INSERT INTO pIn VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_int(stmt, 2, data->index);
+ sqlite3_bind_text(stmt, 3, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data->type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data->type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 6, data->belong_to);
+ sqlite3_bind_int(stmt, 7, data->direct_source);
+ sqlite3_bind_int(stmt, 8, data->shared_source);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_pOut(db_pOut* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pOut VALUES (%d, %d, '%s', '%s', '%d, %d', %d);",
- data->thisobj,
- data->index,
- data->name,
- data->type,
- data->type_guid[0],
- data->type_guid[1],
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(4, "INSERT INTO pOut VALUES (?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_int(stmt, 2, data->index);
+ sqlite3_bind_text(stmt, 3, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data->type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data->type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 6, data->belong_to);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_bIn(db_bIn* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO bIn VALUES (%d, %d, '%s', %d);",
- data->thisobj,
- data->index,
- data->name,
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(5, "INSERT INTO bIn VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_int(stmt, 2, data->index);
+ sqlite3_bind_text(stmt, 3, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 4, data->belong_to);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_bOut(db_bOut* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO bOut VALUES (%d, %d, '%s', %d);",
- data->thisobj,
- data->index,
- data->name,
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(6, "INSERT INTO bOut VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_int(stmt, 2, data->index);
+ sqlite3_bind_text(stmt, 3, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 4, data->belong_to);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_bLink(db_bLink* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO bLink VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d);",
- data->input,
- data->output,
- data->delay,
- data->input_obj,
- data->input_type,
- data->input_index,
- data->output_obj,
- data->output_type,
- data->output_index,
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(7, "INSERT INTO bLink VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->input);
+ sqlite3_bind_int(stmt, 2, data->output);
+ sqlite3_bind_int(stmt, 3, data->delay);
+ sqlite3_bind_int(stmt, 4, data->input_obj);
+ sqlite3_bind_int(stmt, 5, data->input_type);
+ sqlite3_bind_int(stmt, 6, data->input_index);
+ sqlite3_bind_int(stmt, 7, data->output_obj);
+ sqlite3_bind_int(stmt, 8, data->output_type);
+ sqlite3_bind_int(stmt, 9, data->output_index);
+ sqlite3_bind_int(stmt, 10, data->belong_to);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_pLocal(db_pLocal* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pLocal VALUES (%d, '%s', '%s', '%d, %d', %d, %d);",
- data->thisobj,
- data->name,
- data->type,
- data->type_guid[0],
- data->type_guid[1],
- data->is_setting,
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(8, "INSERT INTO pLocal VALUES (?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data->type.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data->type_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data->is_setting);
+ sqlite3_bind_int(stmt, 6, data->belong_to);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_pLink(db_pLink* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pLink VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);",
- data->input,
- data->output,
- data->input_obj,
- data->input_type,
- data->input_is_bb,
- data->input_index,
- data->output_obj,
- data->output_type,
- data->output_is_bb,
- data->output_index,
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(9, "INSERT INTO pLink VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->input);
+ sqlite3_bind_int(stmt, 2, data->output);
+ sqlite3_bind_int(stmt, 3, data->input_obj);
+ sqlite3_bind_int(stmt, 4, data->input_type);
+ sqlite3_bind_int(stmt, 5, data->input_is_bb);
+ sqlite3_bind_int(stmt, 6, data->input_index);
+ sqlite3_bind_int(stmt, 7, data->output_obj);
+ sqlite3_bind_int(stmt, 8, data->output_type);
+ sqlite3_bind_int(stmt, 9, data->output_is_bb);
+ sqlite3_bind_int(stmt, 10, data->output_index);
+ sqlite3_bind_int(stmt, 11, data->belong_to);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_pLocalData(db_pLocalData* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pLocalData VALUES ('%s', '%s', %d);",
- data->field,
- data->data,
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(10, "INSERT INTO pLocalData VALUES (?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_text(stmt, 1, data->field.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 2, data->data.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data->belong_to);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_pOper(db_pOper* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO pOper VALUES (%d, '%s', '%d, %d', %d);",
- data->thisobj,
- data->op,
- data->op_guid[0],
- data->op_guid[1],
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(11, "INSERT INTO pOper VALUES (?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->thisobj);
+ sqlite3_bind_text(stmt, 2, data->op.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data->op_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 4, data->belong_to);
+ sqlite3_step(stmt);
}
void scriptDatabase::write_eLink(db_eLink* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO eLink VALUES (%d, %d, %d, %d, %d);",
- data->export_obj,
- data->internal_obj,
- data->is_in,
- data->index,
- data->belong_to);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(12, "INSERT INTO eLink VALUES (?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->export_obj);
+ sqlite3_bind_int(stmt, 2, data->internal_obj);
+ sqlite3_bind_int(stmt, 3, data->is_in);
+ sqlite3_bind_int(stmt, 4, data->index);
+ sqlite3_bind_int(stmt, 5, data->belong_to);
+ sqlite3_step(stmt);
}
void envDatabase::write_envOp(db_envOp* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO op VALUES (%d, '%d,%d', '%d,%d', '%d,%d', '%d,%d', '%s', %d);",
- data->funcPtr,
- data->in1_guid[0],
- data->in1_guid[1],
- data->in2_guid[0],
- data->in2_guid[1],
- data->out_guid[0],
- data->out_guid[1],
- data->op_guid[0],
- data->op_guid[1],
- data->op_name,
- data->op_code);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(0, "INSERT INTO op VALUES (?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, (int)data->funcPtr);
+ sqlite3_bind_text(stmt, 2, data->in1_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data->in2_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data->out_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 5, data->op_guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 6, data->op_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 7, data->op_code);
+ sqlite3_step(stmt);
}
void envDatabase::write_envParam(db_envParam* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO param VALUES (%d, '%d,%d', '%d,%d', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%d,%d');",
- data->index,
- data->guid[0],
- data->guid[1],
- data->derived_from[0],
- data->derived_from[1],
- data->type_name,
- data->default_size,
- data->func_CreateDefault,
- data->func_Delete,
- data->func_SaveLoad,
- data->func_Check,
- data->func_Copy,
- data->func_String,
- data->func_UICreator,
- data->creator_dll_index,
- data->creator_plugin_index,
- data->dw_param,
- data->dw_flags,
- data->cid,
- data->saver_manager[0],
- data->saver_manager[1]);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(1, "INSERT INTO param VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->index);
+ sqlite3_bind_text(stmt, 2, data->guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 3, data->derived_from.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 4, data->type_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data->default_size);
+ sqlite3_bind_int(stmt, 6, (int)data->func_CreateDefault);
+ sqlite3_bind_int(stmt, 7, (int)data->func_Delete);
+ sqlite3_bind_int(stmt, 8, (int)data->func_SaveLoad);
+ sqlite3_bind_int(stmt, 9, (int)data->func_Check);
+ sqlite3_bind_int(stmt, 10, (int)data->func_Copy);
+ sqlite3_bind_int(stmt, 11, (int)data->func_String);
+ sqlite3_bind_int(stmt, 12, (int)data->func_UICreator);
+ sqlite3_bind_int(stmt, 13, data->creator_dll_index);
+ sqlite3_bind_int(stmt, 14, data->creator_plugin_index);
+ sqlite3_bind_int(stmt, 15, data->dw_param);
+ sqlite3_bind_int(stmt, 16, data->dw_flags);
+ sqlite3_bind_int(stmt, 17, data->cid);
+ sqlite3_bind_text(stmt, 18, data->saver_manager.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
}
void envDatabase::write_envMsg(db_envMsg* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO msg VALUES (%d, '%s');",
- data->index,
- data->name);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(2, "INSERT INTO msg VALUES (?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->index);
+ sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
}
void envDatabase::write_envAttr(db_envAttr* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO attr VALUES (%d, '%s', %d, '%s', %d, %d, %d, '%s');",
- data->index,
- data->name,
- data->category_index,
- data->category_name,
- data->flags,
- data->param_index,
- data->compatible_classid,
- data->default_value);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(3, "INSERT INTO attr VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->index);
+ sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data->category_index);
+ sqlite3_bind_text(stmt, 4, data->category_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data->flags);
+ sqlite3_bind_int(stmt, 6, data->param_index);
+ sqlite3_bind_int(stmt, 7, data->compatible_classid);
+ sqlite3_bind_text(stmt, 8, data->default_value.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_step(stmt);
}
void envDatabase::write_envPlugin(db_envPlugin* data) {
if (db == NULL) return;
- sprintf(commandStr, "INSERT INTO plugin VALUES (%d, '%s', %d, '%s', %d, %d, '%d,%d', '%s', '%s', '%s', %d, %d, %d);",
- data->dll_index,
- data->dll_name,
- data->plugin_index,
- data->category,
- data->active,
- data->needed_by_file,
- data->guid[0],
- data->guid[1],
- data->desc,
- data->author,
- data->summary,
- data->version,
- data->func_init,
- data->func_exit);
+ sqlite3_stmt* stmt = NULL;
+ tryGetStmt(4, "INSERT INTO plugin VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ sqlite3_reset(stmt);
- sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
+ sqlite3_bind_int(stmt, 1, data->dll_index);
+ sqlite3_bind_text(stmt, 2, data->dll_name.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 3, data->plugin_index);
+ sqlite3_bind_text(stmt, 4, data->category.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 5, data->active);
+ sqlite3_bind_int(stmt, 6, data->needed_by_file);
+ sqlite3_bind_text(stmt, 7, data->guid.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 8, data->desc.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 9, data->author.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_text(stmt, 10, data->summary.c_str(), -1, SQLITE_TRANSIENT);
+ sqlite3_bind_int(stmt, 11, data->version);
+ sqlite3_bind_int(stmt, 12, (int)data->func_init);
+ sqlite3_bind_int(stmt, 13, (int)data->func_exit);
+ sqlite3_step(stmt);
}
+#undef tryGetStmt
#pragma endregion
diff --git a/SuperScriptMaterializer/database.h b/SuperScriptMaterializer/database.h
index 250235b..a7f6024 100644
--- a/SuperScriptMaterializer/database.h
+++ b/SuperScriptMaterializer/database.h
@@ -3,6 +3,10 @@
#include
#include "stdafx.h"
+#include
+#include
+
+#define STRINGCACHE_SIZE 25565
typedef long EXPAND_CK_ID;
enum bLinkInputOutputType {
@@ -20,30 +24,30 @@ enum pLinkInputOutputType {
typedef struct {
EXPAND_CK_ID thisobj;
- char name[1024];
+ std::string name;
CK_BEHAVIOR_TYPE type;
- char proto_name[1024];
- CKDWORD proto_guid[2];
+ std::string proto_name;
+ std::string proto_guid;
CK_BEHAVIOR_FLAGS flags;
int priority;
CKDWORD version;
//pTarget, pIn, pOut, bIn, bOut
- char pin_count[128];
+ std::string pin_count;
EXPAND_CK_ID parent;
}dbCKBehavior;
typedef struct {
EXPAND_CK_ID thisobj;
- char host_name[1024];
+ std::string host_name;
int index;
EXPAND_CK_ID behavior;
}dbCKScript;
typedef struct {
EXPAND_CK_ID thisobj;
- char name[1024];
- char type[1024];
- CKDWORD type_guid[2];
+ std::string name;
+ std::string type;
+ std::string type_guid;
EXPAND_CK_ID belong_to;
EXPAND_CK_ID direct_source;
EXPAND_CK_ID shared_source;
@@ -52,9 +56,9 @@ typedef struct {
typedef struct {
EXPAND_CK_ID thisobj;
int index;
- char name[1024];
- char type[1024];
- CKDWORD type_guid[2];
+ std::string name;
+ std::string type;
+ std::string type_guid;
EXPAND_CK_ID belong_to;
EXPAND_CK_ID direct_source;
EXPAND_CK_ID shared_source;
@@ -63,16 +67,16 @@ typedef struct {
typedef struct {
EXPAND_CK_ID thisobj;
int index;
- char name[1024];
- char type[1024];
- CKDWORD type_guid[2];
+ std::string name;
+ std::string type;
+ std::string type_guid;
EXPAND_CK_ID belong_to;
}db_pOut;
typedef struct {
EXPAND_CK_ID thisobj;
int index;
- char name[1024];
+ std::string name;
EXPAND_CK_ID belong_to;
}db_bIO;
typedef db_bIO db_bIn;
@@ -95,16 +99,16 @@ typedef struct {
typedef struct {
EXPAND_CK_ID thisobj;
- char name[1024];
- char type[1024];
- CKDWORD type_guid[2];
+ std::string name;
+ std::string type;
+ std::string type_guid;
BOOL is_setting;
EXPAND_CK_ID belong_to;
}db_pLocal;
typedef struct {
- char field[1024];
- char data[1024];
+ std::string field;
+ std::string data;
EXPAND_CK_ID belong_to;
}db_pLocalData;
@@ -126,8 +130,8 @@ typedef struct {
typedef struct {
EXPAND_CK_ID thisobj;
- char op[1024];
- CKDWORD op_guid[2];
+ std::string op;
+ std::string op_guid;
EXPAND_CK_ID belong_to;
}db_pOper;
@@ -143,19 +147,19 @@ typedef struct {
typedef struct {
CK_PARAMETEROPERATION funcPtr;
- CKDWORD in1_guid[2];
- CKDWORD in2_guid[2];
- CKDWORD out_guid[2];
- CKDWORD op_guid[2];
- char op_name[1024];
+ std::string in1_guid;
+ std::string in2_guid;
+ std::string out_guid;
+ std::string op_guid;
+ std::string op_name;
CKOperationType op_code;
}db_envOp;
typedef struct {
CKParameterType index;
- CKDWORD guid[2];
- CKDWORD derived_from[2];
- char type_name[1024];
+ std::string guid;
+ std::string derived_from;
+ std::string type_name;
int default_size;
CK_PARAMETERCREATEDEFAULTFUNCTION func_CreateDefault;
CK_PARAMETERDELETEFUNCTION func_Delete;
@@ -169,36 +173,36 @@ typedef struct {
CKDWORD dw_param;
CKDWORD dw_flags;
CKDWORD cid;
- CKDWORD saver_manager[2];
+ std::string saver_manager;
}db_envParam;
typedef struct {
CKMessageType index;
- char name[1024];
+ std::string name;
}db_envMsg;
typedef struct {
CKAttributeType index;
- char name[1024];
+ std::string name;
CKAttributeCategory category_index;
- char category_name[1024];
+ std::string category_name;
CK_ATTRIBUT_FLAGS flags;
CKParameterType param_index;
CK_CLASSID compatible_classid;
- char default_value[1024];
+ std::string default_value;
}db_envAttr;
typedef struct {
int dll_index;
- char dll_name[1024];
+ std::string dll_name;
int plugin_index;
- char category[1024];
+ std::string category;
CKBOOL active;
CKBOOL needed_by_file;
- CKDWORD guid[2];
- char desc[1024];
- char author[1024];
- char summary[1024];
+ std::string guid;
+ std::string desc;
+ std::string author;
+ std::string summary;
DWORD version;
CK_INITINSTANCEFCT func_init;
CK_EXITINSTANCEFCT func_exit;
@@ -211,6 +215,7 @@ class dbScriptDataStructHelper {
void init(CKParameterManager* paramManager);
void dispose();
+ char* _stringCache;
CKParameterManager* _parameterManager;
dbCKBehavior* _dbCKBehavior;
dbCKScript* _dbCKScript;
@@ -232,6 +237,7 @@ class dbEnvDataStructHelper {
void init();
void dispose();
+ char* _stringCache;
db_envOp* _db_envOp;
db_envParam* _db_envParam;
db_envMsg* _db_envMsg;
@@ -250,8 +256,7 @@ class database {
virtual BOOL finalJob() { return TRUE; }
sqlite3* db;
- char* errmsg;
- char* commandStr;
+ std::vector* stmtCache;
};
class scriptDatabase : public database {
diff --git a/SuperScriptMaterializer/env_export.cpp b/SuperScriptMaterializer/env_export.cpp
index e7cc30f..5bdb654 100644
--- a/SuperScriptMaterializer/env_export.cpp
+++ b/SuperScriptMaterializer/env_export.cpp
@@ -2,6 +2,8 @@
//disable shit tip
#pragma warning(disable:26812)
+#define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
+
void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper) {
int count = parameterManager->GetParameterOperationCount();
CKOperationDesc* opList = NULL;
@@ -11,8 +13,8 @@ void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase
//fill basic data
helper->_db_envOp->op_code = i;
_guid = parameterManager->OperationCodeToGuid(i);
- cp_guid(helper->_db_envOp->op_guid, _guid);
- strcpy(helper->_db_envOp->op_name, parameterManager->OperationCodeToName(i));
+ copyGuid(_guid,helper->_db_envOp->op_guid);
+ helper->_db_envOp->op_name = parameterManager->OperationCodeToName(i);
//allocate mem
cacheListCount = parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, NULL);
@@ -24,9 +26,9 @@ void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase
parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, opList);
for (int j = 0; j < cacheListCount; j++) {
- cp_guid(helper->_db_envOp->in1_guid, opList[j].P1Guid);
- cp_guid(helper->_db_envOp->in2_guid, opList[j].P2Guid);
- cp_guid(helper->_db_envOp->out_guid, opList[j].ResGuid);
+ copyGuid(opList[j].P1Guid, helper->_db_envOp->in1_guid);
+ copyGuid(opList[j].P2Guid, helper->_db_envOp->in2_guid);
+ copyGuid(opList[j].ResGuid, helper->_db_envOp->out_guid);
helper->_db_envOp->funcPtr = opList[j].Fct;
db->write_envOp(helper->_db_envOp);
@@ -43,9 +45,9 @@ void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbE
desc = parameterManager->GetParameterTypeDescription(i);
helper->_db_envParam->index = desc->Index;
- cp_guid(helper->_db_envParam->guid, desc->Guid);
- cp_guid(helper->_db_envParam->derived_from, desc->DerivedFrom);
- strcpy(helper->_db_envParam->type_name, desc->TypeName.CStr());
+ copyGuid(desc->Guid, helper->_db_envParam->guid);
+ copyGuid(desc->DerivedFrom, helper->_db_envParam->derived_from);
+ helper->_db_envParam->type_name = desc->TypeName.CStr();
helper->_db_envParam->default_size = desc->DefaultSize;
helper->_db_envParam->func_CreateDefault = desc->CreateDefaultFunction;
helper->_db_envParam->func_Delete = desc->DeleteFunction;
@@ -65,7 +67,7 @@ void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbE
helper->_db_envParam->dw_param = desc->dwParam;
helper->_db_envParam->dw_flags = desc->dwFlags;
helper->_db_envParam->cid = desc->Cid;
- cp_guid(helper->_db_envParam->saver_manager, desc->Saver_Manager);
+ copyGuid(desc->Saver_Manager, helper->_db_envParam->saver_manager);
db->write_envParam(helper->_db_envParam);
}
@@ -75,7 +77,7 @@ void IterateMessage(CKMessageManager* msgManager, envDatabase* db, dbEnvDataStru
int count = msgManager->GetMessageTypeCount();
for (int i = 0; i < count; i++) {
helper->_db_envMsg->index = i;
- strcpy(helper->_db_envMsg->name, msgManager->GetMessageTypeName(i));
+ helper->_db_envMsg->name = msgManager->GetMessageTypeName(i);
db->write_envMsg(helper->_db_envMsg);
}
@@ -85,13 +87,13 @@ void IterateAttribute(CKAttributeManager* attrManager, envDatabase* db, dbEnvDat
int count = attrManager->GetAttributeCount();
for (int i = 0; i < count; i++) {
helper->_db_envAttr->index = i;
- strcpy(helper->_db_envAttr->name, attrManager->GetAttributeNameByType(i));
+ helper->_db_envAttr->name = attrManager->GetAttributeNameByType(i);
helper->_db_envAttr->category_index = attrManager->GetAttributeCategoryIndex(i);
- strcpy(helper->_db_envAttr->category_name, attrManager->GetAttributeCategory(i) != NULL ? attrManager->GetAttributeCategory(i) : "");
+ helper->_db_envAttr->category_name = attrManager->GetAttributeCategory(i) != NULL ? attrManager->GetAttributeCategory(i) : "";
helper->_db_envAttr->flags = attrManager->GetAttributeFlags(i);
helper->_db_envAttr->param_index = attrManager->GetAttributeParameterType(i);
helper->_db_envAttr->compatible_classid = attrManager->GetAttributeCompatibleClassId(i);
- strcpy(helper->_db_envAttr->default_value, attrManager->GetAttributeDefaultValue(i) != NULL ? attrManager->GetAttributeDefaultValue(i) : "");
+ helper->_db_envAttr->default_value = attrManager->GetAttributeDefaultValue(i) != NULL ? attrManager->GetAttributeDefaultValue(i) : "";
db->write_envAttr(helper->_db_envAttr);
}
@@ -100,20 +102,20 @@ void IterateAttribute(CKAttributeManager* attrManager, envDatabase* db, dbEnvDat
void IteratePlugin(CKPluginManager* plgManager, envDatabase* db, dbEnvDataStructHelper* helper) {
for (int i = 0; i <= 7; i++) {
int catCount = plgManager->GetPluginCount(i);
- strcpy(helper->_db_envPlugin->category, plgManager->GetCategoryName(i));
+ helper->_db_envPlugin->category = plgManager->GetCategoryName(i);
for (int j = 0; j < catCount; j++) {
CKPluginEntry* plgEntry = plgManager->GetPluginInfo(i, j);
helper->_db_envPlugin->dll_index = plgEntry->m_PluginDllIndex;
- strcpy(helper->_db_envPlugin->dll_name, plgManager->GetPluginDllInfo(plgEntry->m_PluginDllIndex)->m_DllFileName.CStr());
+ helper->_db_envPlugin->dll_name = plgManager->GetPluginDllInfo(plgEntry->m_PluginDllIndex)->m_DllFileName.CStr();
helper->_db_envPlugin->plugin_index = plgEntry->m_PositionInDll;
helper->_db_envPlugin->active = plgEntry->m_Active;
helper->_db_envPlugin->needed_by_file = plgEntry->m_NeededByFile;
CKPluginInfo* plgInfo = &(plgEntry->m_PluginInfo);
- cp_guid(helper->_db_envPlugin->guid, plgInfo->m_GUID);
- strcpy(helper->_db_envPlugin->desc, plgInfo->m_Description.CStr());
- strcpy(helper->_db_envPlugin->author, plgInfo->m_Author.CStr());
- strcpy(helper->_db_envPlugin->summary, plgInfo->m_Summary.CStr());
+ copyGuid(plgInfo->m_GUID, helper->_db_envPlugin->guid);
+ helper->_db_envPlugin->desc = plgInfo->m_Description.CStr();
+ helper->_db_envPlugin->author = plgInfo->m_Author.CStr();
+ helper->_db_envPlugin->summary = plgInfo->m_Summary.CStr();
helper->_db_envPlugin->version = plgInfo->m_Version;
helper->_db_envPlugin->func_init = plgInfo->m_InitInstanceFct;
helper->_db_envPlugin->func_exit = plgInfo->m_ExitInstanceFct;
diff --git a/SuperScriptMaterializer/env_export.h b/SuperScriptMaterializer/env_export.h
index d39ce31..3bf4d57 100644
--- a/SuperScriptMaterializer/env_export.h
+++ b/SuperScriptMaterializer/env_export.h
@@ -4,8 +4,6 @@
#include "stdafx.h"
#include "database.h"
-#define cp_guid(x,y) x[0]=y.d1;x[1]=y.d2
-
void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper);
void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper);
void IterateMessage(CKMessageManager* msgManager, envDatabase* db, dbEnvDataStructHelper* helper);
diff --git a/SuperScriptMaterializer/script_export.cpp b/SuperScriptMaterializer/script_export.cpp
index d550857..0221cc3 100644
--- a/SuperScriptMaterializer/script_export.cpp
+++ b/SuperScriptMaterializer/script_export.cpp
@@ -3,6 +3,7 @@
#pragma warning(disable:26812)
#define changeSuffix(a) prefix[endIndex]='\0';strcat(prefix,a)
+#define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
#pragma region inline func
@@ -33,7 +34,7 @@ inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDa
} else {
//pOper
helper->_db_pLink->input_index = 0;
-
+
}
}
}
@@ -73,16 +74,27 @@ inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDa
inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents) {
helper->_db_pTarget->thisobj = cache->GetID();
- strcpy(helper->_db_pTarget->name, cache->GetName());
- strcpy(helper->_db_pTarget->type, helper->_parameterManager->ParameterTypeToName(cache->GetType()));
- helper->_db_pTarget->type_guid[0] = cache->GetGUID().d1;
- helper->_db_pTarget->type_guid[1] = cache->GetGUID().d2;
+ helper->_db_pTarget->name = cache->GetName();
+ helper->_db_pTarget->type = helper->_parameterManager->ParameterTypeToName(cache->GetType());
+ copyGuid(cache->GetGUID(), helper->_db_pTarget->type_guid);
helper->_db_pTarget->belong_to = parents;
helper->_db_pTarget->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
helper->_db_pTarget->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
db->write_pTarget(helper->_db_pTarget);
+ //judge whether expoer parameter and write database
+ if (((CKBehavior*)ctx->GetObjectA(grandparents))->GetInputParameterPosition(cache) != -1) {
+ helper->_db_eLink->export_obj = cache->GetID();
+ helper->_db_eLink->internal_obj = parents;
+ helper->_db_eLink->is_in = TRUE;
+ helper->_db_eLink->index = -1;
+ helper->_db_eLink->belong_to = grandparents;
+
+ db->write_eLink(helper->_db_eLink);
+ return;
+ }
+
//=========try generate pLink
generate_pLink_in_pIn(ctx, cache, db, helper, parents, grandparents, -1, TRUE, TRUE);
}
@@ -90,12 +102,11 @@ inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* d
inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
helper->_db_pIn->thisobj = cache->GetID();
helper->_db_pIn->index = index;
- strcpy(helper->_db_pIn->name, cache->GetName());
+ helper->_db_pIn->name = cache->GetName();
CKParameterType vaildTypeChecker = cache->GetType();
- if (vaildTypeChecker != -1) strcpy(helper->_db_pIn->type, helper->_parameterManager->ParameterTypeToName(cache->GetType())); //known types
- else strcpy(helper->_db_pIn->type, "!!UNKNOW TYPE!!"); //unknow type
- helper->_db_pIn->type_guid[0] = cache->GetGUID().d1;
- helper->_db_pIn->type_guid[1] = cache->GetGUID().d2;
+ if (vaildTypeChecker != -1) helper->_db_pIn->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
+ else helper->_db_pIn->type = "!!UNKNOW TYPE!!"; //unknow type
+ copyGuid(cache->GetGUID(), helper->_db_pIn->type_guid);
helper->_db_pIn->belong_to = parents;
helper->_db_pIn->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
helper->_db_pIn->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
@@ -116,18 +127,17 @@ inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, d
//=========try generate pLink
generate_pLink_in_pIn(ctx, cache, db, helper, parents, grandparents, index, executedFromBB, FALSE);
-
+
}
inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
helper->_db_pOut->thisobj = cache->GetID();
helper->_db_pOut->index = index;
- strcpy(helper->_db_pOut->name, cache->GetName());
+ helper->_db_pOut->name = cache->GetName();
CKParameterType vaildTypeChecker = cache->GetType();
- if (vaildTypeChecker != -1) strcpy(helper->_db_pOut->type, helper->_parameterManager->ParameterTypeToName(cache->GetType())); //known types
- else strcpy(helper->_db_pOut->type, "!!UNKNOW TYPE!!"); //unknow type
- helper->_db_pOut->type_guid[0] = cache->GetGUID().d1;
- helper->_db_pOut->type_guid[1] = cache->GetGUID().d2;
+ if (vaildTypeChecker != -1) helper->_db_pOut->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
+ else helper->_db_pOut->type = "!!UNKNOW TYPE!!"; //unknow type
+ copyGuid(cache->GetGUID(), helper->_db_pOut->type_guid);
helper->_db_pOut->belong_to = parents;
db->write_pOut(helper->_db_pOut);
@@ -184,7 +194,7 @@ inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db,
inline void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
helper->_db_bIn->thisobj = cache->GetID();
helper->_db_bIn->index = index;
- strcpy(helper->_db_bIn->name, cache->GetName());
+ helper->_db_bIn->name = cache->GetName();
helper->_db_bIn->belong_to = parents;
db->write_bIn(helper->_db_bIn);
@@ -193,7 +203,7 @@ inline void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStruct
inline void proc_bOut(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
helper->_db_bOut->thisobj = cache->GetID();
helper->_db_bOut->index = index;
- strcpy(helper->_db_bOut->name, cache->GetName());
+ helper->_db_bOut->name = cache->GetName();
helper->_db_bOut->belong_to = parents;
db->write_bOut(helper->_db_bOut);
@@ -221,12 +231,11 @@ inline void proc_bLink(CKBehaviorLink* cache, scriptDatabase* db, dbScriptDataSt
inline void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting) {
helper->_db_pLocal->thisobj = cache->GetID();
- strcpy(helper->_db_pLocal->name, cache->GetName() ? cache->GetName() : "");
+ helper->_db_pLocal->name = cache->GetName() ? cache->GetName() : "";
CKParameterType vaildTypeChecker = cache->GetType();
- if (vaildTypeChecker != -1) strcpy(helper->_db_pLocal->type, helper->_parameterManager->ParameterTypeToName(cache->GetType())); //known types
- else strcpy(helper->_db_pLocal->type, "!!UNKNOW TYPE!!"); //unknow type
- helper->_db_pLocal->type_guid[0] = cache->GetGUID().d1;
- helper->_db_pLocal->type_guid[1] = cache->GetGUID().d2;
+ if (vaildTypeChecker != -1) helper->_db_pLocal->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
+ else helper->_db_pLocal->type = "!!UNKNOW TYPE!!"; //unknow type
+ copyGuid(cache->GetGUID(), helper->_db_pLocal->type_guid);
helper->_db_pLocal->is_setting = is_setting;
helper->_db_pLocal->belong_to = parents;
@@ -238,9 +247,8 @@ inline void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDat
inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
helper->_db_pOper->thisobj = cache->GetID();
- strcpy(helper->_db_pOper->op, helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid()));
- helper->_db_pOper->op_guid[0] = cache->GetOperationGuid().d1;
- helper->_db_pOper->op_guid[1] = cache->GetOperationGuid().d2;
+ helper->_db_pOper->op = helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid());
+ copyGuid(cache->GetOperationGuid(), helper->_db_pOper->op_guid);
helper->_db_pOper->belong_to = parents;
db->write_pOper(helper->_db_pOper);
@@ -254,8 +262,8 @@ inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDataba
//============================helper for pLocal data export
inline void helper_pLocalDataExport(const char* field, const char* data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
- strcpy(helper->_db_pLocalData->field, field);
- strcpy(helper->_db_pLocalData->data, data);
+ helper->_db_pLocalData->field = field;
+ helper->_db_pLocalData->data = data;
helper->_db_pLocalData->belong_to = parents;
db->write_pLocalData(helper->_db_pLocalData);
@@ -291,7 +299,7 @@ void IterateScript(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper*
beh = beobj->GetScript(j);
helper->_dbCKScript->thisobj = beobj->GetID();
- strcpy(helper->_dbCKScript->host_name, beobj->GetName());
+ helper->_dbCKScript->host_name = beobj->GetName();
helper->_dbCKScript->index = j;
helper->_dbCKScript->behavior = beh->GetID();
db->write_CKScript(helper->_dbCKScript);
@@ -305,21 +313,21 @@ void IterateScript(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper*
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
//write self data
helper->_dbCKBehavior->thisobj = bhv->GetID();
- strcpy(helper->_dbCKBehavior->name, bhv->GetName());
+ helper->_dbCKBehavior->name = bhv->GetName();
helper->_dbCKBehavior->type = bhv->GetType();
- strcpy(helper->_dbCKBehavior->proto_name, bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "");
- helper->_dbCKBehavior->proto_guid[0] = bhv->GetPrototypeGuid().d1;
- helper->_dbCKBehavior->proto_guid[1] = bhv->GetPrototypeGuid().d2;
+ helper->_dbCKBehavior->proto_name = bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "";
+ copyGuid(bhv->GetPrototypeGuid(), helper->_dbCKBehavior->proto_guid);
helper->_dbCKBehavior->flags = bhv->GetFlags();
helper->_dbCKBehavior->priority = bhv->GetPriority();
helper->_dbCKBehavior->version = bhv->GetVersion();
helper->_dbCKBehavior->parent = parents;
- sprintf(helper->_dbCKBehavior->pin_count, "%d,%d,%d,%d,%d",
+ sprintf(helper->_stringCache, "%d,%d,%d,%d,%d",
(bhv->IsUsingTarget() ? 1 : 0),
bhv->GetInputParameterCount(),
bhv->GetOutputParameterCount(),
bhv->GetInputCount(),
bhv->GetOutputCount());
+ helper->_dbCKBehavior->pin_count = helper->_stringCache;
db->write_CKBehavior(helper->_dbCKBehavior);
//write target
@@ -461,10 +469,10 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
if (t == CKPGUID_STRING) {
char* cptr = (char*)p->GetReadDataPtr(false);
int cc = p->GetDataSize();
- for (int i = 0; i < cc; i++)
- helper->_db_pLocalData->data[i] = cptr[i];
- helper->_db_pLocalData->data[cc] = '\0';
- strcpy(helper->_db_pLocalData->field, "str");
+
+ helper->_db_pLocalData->data.clear();
+ helper->_db_pLocalData->data.insert(0, cptr, 0, cc);
+ helper->_db_pLocalData->field = "str";
helper->_db_pLocalData->belong_to = p->GetID();
db->write_pLocalData(helper->_db_pLocalData);
return;
@@ -479,25 +487,21 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
char temp[4];
int cc = 0, rcc = 0, pos = 0;
rcc = cc = p->GetDataSize();
- if (rcc > 200) rcc = 200;
+ if (rcc > 1024) rcc = 1024;
+ helper->_db_pLocalData->data.clear();
for (int i = 0; i < rcc; i++) {
sprintf(temp, "%02X", cptr[i]);
- helper->_db_pLocalData->data[pos++] = '0';
- helper->_db_pLocalData->data[pos++] = 'x';
- helper->_db_pLocalData->data[pos++] = temp[0];
- helper->_db_pLocalData->data[pos++] = temp[1];
- helper->_db_pLocalData->data[pos++] = ',';
+
+ helper->_db_pLocalData->data += temp;
+ if (i != rcc - 1)
+ helper->_db_pLocalData->data += ", ";
}
- if (pos)
- helper->_db_pLocalData->data[--pos] = '\0';
- else
- helper->_db_pLocalData->data[0] = '\0';
if (rcc == cc)
- strcpy(helper->_db_pLocalData->field, "dump.data");
+ helper->_db_pLocalData->field = "dump.data";
else
- strcpy(helper->_db_pLocalData->field, "dump.partial_data");
+ helper->_db_pLocalData->field = "dump.partial_data";
helper->_db_pLocalData->belong_to = p->GetID();
db->write_pLocalData(helper->_db_pLocalData);
diff --git a/SuperScriptViewer/DecoratorCore.py b/SuperScriptViewer/DecoratorCore.py
index 3159f9c..3b5702f 100644
--- a/SuperScriptViewer/DecoratorCore.py
+++ b/SuperScriptViewer/DecoratorCore.py
@@ -2,6 +2,7 @@ import sqlite3
import DecoratorConstValue as dcv
import json
import CustomConfig
+import sys
def run():
exportDb = sqlite3.connect(CustomConfig.export_db)
@@ -21,11 +22,24 @@ def run():
# decorate each graph
print('Generating graph...')
currentGraphBlockCell = {}
+ percentageAll = len(graphList)
+ if percentageAll == 0:
+ percentageAll = 1
+ percentageNow = 0
+ percentageCache = 0
+ #debug
+ graphList=graphList[int(percentageAll*3/4):]
for i in graphList:
+ sys.stdout.write('\r[{}{}]{}%'.format(int(percentageCache / 5) * '#',(20 - int(percentageCache / 5)) * '=', percentageCache))
+ sys.stdout.flush()
+
currentGraphBlockCell.clear()
buildBlock(exportDb, decorateDb, i, currentGraphBlockCell)
graphPIO = buildCell(exportDb, decorateDb, i, currentGraphBlockCell)
buildLink(exportDb, decorateDb, i, currentGraphBlockCell, graphPIO)
+
+ percentageNow += 1
+ percentageCache = int(100 * percentageNow / percentageAll)
# export information
print('Generating info...')
@@ -398,7 +412,7 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
# query all links(don't need to consider export pIO, due to it will not add
# any shortcut)
- # !! the same if framework in pLink generator function !! SHARED
+ # !! the same if framework in pLink generator function !! SHARED
createdShortcut = set()
exCur.execute("SELECT * FROM pLink WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall():
@@ -420,7 +434,7 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
elif (i[3] == dcv.dbPLinkInputOutputType.PIN):
if i[2] == target:
- continue # ignore self pIn/pOut. it doesn't need any shortcut
+ continue # ignore self pIn/pOut. it doesn't need any shortcut
if i[2] not in blockSet:
if i[0] not in createdShortcut:
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.PIN)
@@ -461,7 +475,7 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
cache.lastIndex = i[5]
else:
if i[6] == target:
- continue # ignore self pIn/pOut. it doesn't need any shortcut
+ continue # ignore self pIn/pOut. it doesn't need any shortcut
if i[6] not in blockSet:
if i[1] not in createdShortcut:
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.POUT)
@@ -539,8 +553,13 @@ def buildLink(exDb, deDb, target, currentGraphBlockCell, graphPIO):
exCur = exDb.cursor()
deCur = deDb.cursor()
+ # prepare block set
+ blockSet = set()
+ for i in currentGraphBlockCell.keys():
+ blockSet.add(i)
+
# bLink
- exCur.execute("SELECT * FROM bLink WHERE [belong_to] == ?", (target, ))
+ exCur.execute("SELECT * FROM bLink WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall():
if i[3] == target:
(x1, y1) = computLinkBTerminal(i[0], 0, -1 ,currentGraphBlockCell)
@@ -567,7 +586,7 @@ def buildLink(exDb, deDb, target, currentGraphBlockCell, graphPIO):
(target, i[2], i[0], i[1], bStartObj, bEndObj, bStartType, bEndType, bStartIndex, bEndIndex, x1, y1, x2, y2))
# pLink
- # !! the same if framework in cell generator function !! SHARED
+ # !! the same if framework in cell generator function !! SHARED
exCur.execute("SELECT * FROM pLink WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall():
# analyse 5 chancee one by one
@@ -590,7 +609,11 @@ def buildLink(exDb, deDb, target, currentGraphBlockCell, graphPIO):
(target, -1, i[0], i[1], i[2], i[6], 0, 0, i[5], i[9], x1, y1, x2, y2))
else:
- (x1, y1) = computLinkPTerminal(i[2], 1, i[5], currentGraphBlockCell)
+ if i[2] in blockSet: # process protencial pOut(shortcut) (because plocal input/input_obj
+ # output/output_obj is same, so don't need add for them)
+ (x1, y1) = computLinkPTerminal(i[2], 1, i[5], currentGraphBlockCell)
+ else:
+ (x1, y1) = computLinkPTerminal(i[0], 1, i[5], currentGraphBlockCell)
(x2, y2) = computLinkPTerminal(i[6], 0, i[9], currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[6], 1, 0, i[5], i[9], x1, y1, x2, y2))
@@ -627,7 +650,9 @@ def computLinkBTerminal(obj, xtype, index, currentGraphBlockCell):
cache.y if index == -1 else (cache.y + dcv.BB_BOFFSET + index * (dcv.BB_PBSIZE + dcv.BB_BSPAN)))
def computLinkPTerminal(obj, ytype, index, currentGraphBlockCell):
- # ytype is not database type. it have the same meaning of LinkBTerminal, indicating the position. 0 is keep origin position(for pIn and pTarget), 1 is consider height(for pOut)
+ # ytype is not database type. it have the same meaning of LinkBTerminal,
+ # indicating the position. 0 is keep origin position(for pIn and pTarget),
+ # 1 is consider height(for pOut)
cache = currentGraphBlockCell[obj]
return (cache.x if index == -1 else (cache.x + dcv.BB_POFFSET + index * (dcv.BB_PBSIZE + dcv.BB_PSPAN)),
cache.y if ytype == 0 else (cache.y + cache.h - dcv.BB_PBSIZE))
diff --git a/SuperScriptViewer/ServerCore.py b/SuperScriptViewer/ServerCore.py
index 47d6f60..e139171 100644
--- a/SuperScriptViewer/ServerCore.py
+++ b/SuperScriptViewer/ServerCore.py
@@ -104,8 +104,8 @@ def viewerHandle(scriptPath):
gWidth = width,
gHeight = height,
hamburgerHistory = hamburger,
- static_css = url_for('static', filename='site.css'),
- static_js = url_for('static', filename='site.js'),
+ static_css = url_for('static', filename='viewer.css'),
+ static_js = url_for('static', filename='viewer.js'),
hamburgerCurrent = currentHamburger,
blocks = dbBlocks,
cells = dbCells,
diff --git a/SuperScriptViewer/SuperScriptViewer.py b/SuperScriptViewer/SuperScriptViewer.py
index 7cdbeec..1436297 100644
--- a/SuperScriptViewer/SuperScriptViewer.py
+++ b/SuperScriptViewer/SuperScriptViewer.py
@@ -9,11 +9,11 @@ try:
opts, args = getopt.getopt(sys.argv, "hi:o:e:f")
except getopt.GetoptError:
print('Wrong arguments!')
- print('test.py -i -o -e -f')
+ print('python SuperScriptViewer.py -i -o -e -f')
sys.exit(1)
for opt, arg in opts:
if opt == '-h':
- print('test.py -i -o -e -f')
+ print('python SuperScriptViewer.py -i -o -e -f')
sys.exit(0)
elif opt == '-i':
CustomConfig.export_db = arg
diff --git a/SuperScriptViewer/static/site.css b/SuperScriptViewer/static/viewer.css
similarity index 100%
rename from SuperScriptViewer/static/site.css
rename to SuperScriptViewer/static/viewer.css
diff --git a/SuperScriptViewer/static/site.js b/SuperScriptViewer/static/viewer.js
similarity index 100%
rename from SuperScriptViewer/static/site.js
rename to SuperScriptViewer/static/viewer.js
diff --git a/SuperScriptViewer/templates/about.html b/SuperScriptViewer/templates/about.html
index a09c6ff..aa02c70 100644
--- a/SuperScriptViewer/templates/about.html
+++ b/SuperScriptViewer/templates/about.html
@@ -16,6 +16,8 @@ So, let we crack all scripts and destroy close-source illusion.
Web interface is powered by Flask.
Ancestor projects: BearKidsTeam/VirtoolsScriptDeobfuscation and BearKidsTeam/Script-Materializer.
Thank chirs241097 and 2jjy.
+
+Current Super Script Materializer version: 1.0