From 820e87f2bcdbd63e6451b7bebe475004ed9cd12d Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Fri, 3 Apr 2020 16:10:53 +0800 Subject: [PATCH] enhance something --- SuperScriptMaterializer/database.cpp | 5 ++- SuperScriptMaterializer/database.h | 2 + SuperScriptMaterializer/script_export.cpp | 53 +++++++++++++++++++---- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/SuperScriptMaterializer/database.cpp b/SuperScriptMaterializer/database.cpp index 48f64b5..44883cd 100644 --- a/SuperScriptMaterializer/database.cpp +++ b/SuperScriptMaterializer/database.cpp @@ -58,7 +58,7 @@ void database::open(const char* file) { NULL, NULL, &errmsg); if (result != SQLITE_OK) goto fail; 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, 'parent' INTEGER);", + "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); if (result != SQLITE_OK) goto fail; result = sqlite3_exec(db, @@ -133,7 +133,7 @@ void database::close() { void database::write_CKBehavior(dbCKBehavior* data) { if (db == NULL) return; - sprintf(commandStr, "INSERT INTO behavior VALUES (%d, '%s', %d, '%s', '%d, %d', %d, %d, %d, %d);", + sprintf(commandStr, "INSERT INTO behavior VALUES (%d, '%s', %d, '%s', '%d, %d', %d, %d, %d, '%s', %d);", data->thisobj, data->name, data->type, @@ -143,6 +143,7 @@ void database::write_CKBehavior(dbCKBehavior* data) { data->flags, data->priority, data->version, + data->pin_count, data->parent); sqlite3_exec(db, commandStr, NULL, NULL, &errmsg); diff --git a/SuperScriptMaterializer/database.h b/SuperScriptMaterializer/database.h index 4bb6c58..5eea5fd 100644 --- a/SuperScriptMaterializer/database.h +++ b/SuperScriptMaterializer/database.h @@ -17,6 +17,8 @@ typedef struct dbCKBehavior { CK_BEHAVIOR_FLAGS flags; int priority; CKDWORD version; + //pTarget, pIn, pOut, bIn, bOut + char pin_count[128]; EXPAND_CK_ID parent; }; diff --git a/SuperScriptMaterializer/script_export.cpp b/SuperScriptMaterializer/script_export.cpp index 6f0ddb9..9d32738 100644 --- a/SuperScriptMaterializer/script_export.cpp +++ b/SuperScriptMaterializer/script_export.cpp @@ -186,6 +186,12 @@ void IterateBehavior(CKBehavior* bhv, database* db, dbDataStructHelper* helper, helper->_dbCKBehavior->priority = bhv->GetPriority(); helper->_dbCKBehavior->version = bhv->GetVersion(); helper->_dbCKBehavior->parent = parents; + sprintf(helper->_dbCKBehavior->pin_count, "%d, %d, %d, %d, %d", + (bhv->IsUsingTarget() ? 1 : 0), + bhv->GetInputParameterCount(), + bhv->GetOutputParameterCount(), + bhv->GetInputCount(), + bhv->GetOutputCount()); db->write_CKBehavior(helper->_dbCKBehavior); //write target @@ -222,7 +228,7 @@ void IterateBehavior(CKBehavior* bhv, database* db, dbDataStructHelper* helper, } void IteratepLocalData(CKParameterLocal* p, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) { - CKGUID t = p->GetGUID(); + CKGUID t = p->GetGUID(); BOOL unknowType = FALSE; if (t.d1 & t.d2) unknowType = TRUE; @@ -324,20 +330,51 @@ void IteratepLocalData(CKParameterLocal* p, database* db, dbDataStructHelper* he } return; } + 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->belong_to = p->GetID(); + db->write_pLocalData(helper->_db_pLocalData); + return; + } unknowType = TRUE; //if it gets here, we have no idea what it really is. so simply dump it. //buffer-like - if (unknowType || t == CKPGUID_VOIDBUF || t == CKPGUID_STRING || t == CKPGUID_SHADER || t == CKPGUID_TECHNIQUE || t == CKPGUID_PASS) { - 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, "dump-data"); + if (unknowType || t == CKPGUID_VOIDBUF || t == CKPGUID_SHADER || t == CKPGUID_TECHNIQUE || t == CKPGUID_PASS) { + //dump data + unsigned char* cptr = (unsigned char*)p->GetReadDataPtr(false); + char temp[4]; + int cc = 0, rcc = 0, pos = 0; + rcc = cc = p->GetDataSize(); + if (rcc > 200) rcc = 200; + + 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++] = ','; + } + 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"); + else + strcpy(helper->_db_pLocalData->field, "dump.partial_data"); helper->_db_pLocalData->belong_to = p->GetID(); db->write_pLocalData(helper->_db_pLocalData); + //dump data length + helper_pLocalDataExport("dump.length", (long)cc, db, helper, parents); return; } }