Removed a debug message in web-server (#7305)

Fixes #7194
If a character/account logs in the first time, we silently store the default configuration in the foreseen tables now.
Fixes the problem that the client does not call account configuration save in newer versions and therefore always triggers the debug message.

Thanks to @idk-whoami
This commit is contained in:
Lemongrass3110 2022-10-12 21:44:03 +02:00 committed by GitHub
parent e28fb93f1e
commit e4e4ba1af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 6 deletions

View File

@ -133,10 +133,25 @@ HANDLER_FUNC(charconfig_load) {
}
if (SqlStmt_NumRows(stmt) <= 0) {
SqlStmt_Free(stmt);
ShowDebug("[AccountID: %d, CharID: %d, World: \"%s\"] Not found in table, sending new info.\n", account_id, char_id, world_name);
std::string data = "{\"Type\": 1}";
if( SQL_SUCCESS != SqlStmt_Prepare( stmt, "INSERT INTO `%s` (`account_id`, `char_id`, `world_name`, `data`) VALUES (?, ?, ?, ?)", char_configs_table ) ||
SQL_SUCCESS != SqlStmt_BindParam( stmt, 0, SQLDT_INT, &account_id, sizeof( account_id ) ) ||
SQL_SUCCESS != SqlStmt_BindParam( stmt, 1, SQLDT_INT, &char_id, sizeof( char_id ) ) ||
SQL_SUCCESS != SqlStmt_BindParam( stmt, 2, SQLDT_STRING, (void*)world_name, strlen( world_name ) ) ||
SQL_SUCCESS != SqlStmt_BindParam( stmt, 3, SQLDT_STRING, (void*)data.c_str(), strlen( data.c_str() ) ) ||
SQL_SUCCESS != SqlStmt_Execute( stmt ) ){
SqlStmt_ShowDebug( stmt );
SqlStmt_Free( stmt );
sl.unlock();
res.status = HTTP_BAD_REQUEST;
res.set_content( "Error", "text/plain" );
return;
}
SqlStmt_Free( stmt );
sl.unlock();
res.set_content("{\"Type\": 1}", "application/json");
res.set_content( data, "application/json" );
return;
}

View File

@ -129,10 +129,24 @@ HANDLER_FUNC(userconfig_load) {
}
if (SqlStmt_NumRows(stmt) <= 0) {
SqlStmt_Free(stmt);
ShowDebug("[AccountID: %d, World: \"%s\"] Not found in table, sending new info.\n", account_id, world_name);
std::string data = "{\"Type\": 1}";
if( SQL_SUCCESS != SqlStmt_Prepare( stmt, "INSERT INTO `%s` (`account_id`, `world_name`, `data`) VALUES (?, ?, ?)", user_configs_table ) ||
SQL_SUCCESS != SqlStmt_BindParam( stmt, 0, SQLDT_INT, &account_id, sizeof( account_id ) ) ||
SQL_SUCCESS != SqlStmt_BindParam( stmt, 1, SQLDT_STRING, (void *)world_name, strlen( world_name ) ) ||
SQL_SUCCESS != SqlStmt_BindParam( stmt, 2, SQLDT_STRING, (void *)data.c_str(), strlen( data.c_str() ) ) ||
SQL_SUCCESS != SqlStmt_Execute( stmt ) ){
SqlStmt_ShowDebug( stmt );
SqlStmt_Free( stmt );
sl.unlock();
res.status = HTTP_BAD_REQUEST;
res.set_content( "Error", "text/plain" );
return;
}
SqlStmt_Free( stmt );
sl.unlock();
res.set_content("{\"Type\": 1}", "application/json");
res.set_content( data, "application/json" );
return;
}