소스 검색

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
Lemongrass3110 2 년 전
부모
커밋
e4e4ba1af0
2개의 변경된 파일35개의 추가작업 그리고 6개의 파일을 삭제
  1. 18 3
      src/web/charconfig_controller.cpp
  2. 17 3
      src/web/userconfig_controller.cpp

+ 18 - 3
src/web/charconfig_controller.cpp

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

+ 17 - 3
src/web/userconfig_controller.cpp

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