Hello guys, i use c++ nodes with a simple mysql connection for save all the game data in a database. But when the game perform the c++ node ,it work , but the game do an 2 ~ 5 secs freeze.
void UMySQL_Blueprint_Nodes::PerformSelectQuery(TArray<FString> DatabaseInfo, FString Query, TArray<FString>& QueryResult, bool& completed)
{
MYSQL mysql;
MYSQL_ROW row;
MYSQL_RES *result;
unsigned int num_fields;
unsigned int i;
mysql_init(&mysql);
if (!mysql_real_connect(&mysql, TCHAR_TO_ANSI(*DatabaseInfo[0]), TCHAR_TO_ANSI(*DatabaseInfo[1]), TCHAR_TO_ANSI(*DatabaseInfo[2]), TCHAR_TO_ANSI(*DatabaseInfo[3]), 7777, NULL, 0))
{
//fprintf(stderr, "Failed to connect to database: Error: %s
",
//mysql_error(&mysql));
QueryResult.Add(TEXT("error1 Failed to connect to database "));
QueryResult.Emplace(TEXT("error"));
completed = false;
}
else
{
if (mysql_query(&mysql, TCHAR_TO_ANSI(*Query)))
{
//here goes the error message <!-- s:o --><img src=\"{SMILIES_PATH}/icon_surprised.gif\" alt=\":o\" title=\"Surprised\"><!-- s:o -->)
QueryResult.Add(TEXT("erro2 Query error"));
QueryResult.Emplace(TEXT(""));
completed = false;
}
else
{
result = mysql_store_result(&mysql);
num_fields = mysql_num_fields(result);
while ((row = mysql_fetch_row(result)) != NULL)
{
unsigned long *lengths;
lengths = mysql_fetch_lengths(result);
for (i = 0; i < num_fields; i++)
{
//printf("%.*s] ", (int)lengths*, row* ? row* : "NULL");
QueryResult.Emplace(row*);
}
}
completed = true;
mysql_close(&mysql);
}
}
}
Is there a way to execute the c++ node in a background without freeze the game ?