เอกสาร Steamworks
การรายงานข้อผิดพลาดบน Steam
หมายเหตุ: การรายงานข้อผิดพลาดของ Steam จะรองรับเฉพาะแอปพลิเคชัน Windows 32 บิต เท่านั้น

ภาพรวม

หากมีการใช้งานการรายงานข้อผิดพลาด Steam ทาง Steam ก็จะอัปโหลดมินิดัมป์ของข้อผิดพลาดโดยอัตโนมัติ หลังจากโทรว์ข้อผิดพลาดแบบเดียวกันออกมา 10 ครั้ง

คุณสามารถดูรายละเอียดของการแครชแต่ละครั้งได้ที่หน้า การรายงานข้อผิดพลาด ของส่วนแบ็กเอนด์ของพันธมิตร Steamworks

จะจัดเก็บมินิดัมป์เอาไว้ในเครื่องคอมพิวเตอร์ใช้งานก่อนเสมอ ก่อนที่จะอัพโหลดขึ้นไปยัง Steam ถ้าว่าคุณต้องการจะเข้าไปดูรายละเอียดในนั้นโดยตรง ให้ไปที่ไฟล์ดังกล่าวในไดเรกทอรีติดตั้งของเกม

วิธีการใช้งาน

การรายงานข้อผิดพลาดของ Steam นั้นสามารถใช้งานได้ง่ายมาก หากคุณได้ใช้งาน Structured Exception Handling อยู่แล้ว

คุณจะต้องฮุคฟังก์ชัน _set_se_translator ของ Win 32 ที่จะเรียกฟังก์ชันที่คุณสร้างขึ้นมาเพื่อจัดการมินิดัมป์ ในฟังก์ชันดังกล่าว คุณจะสามารถใช้งาน SteamAPI_SetMiniDumpComment และ SteamAPI_WriteMiniDump เพื่อแจ้งให้กับ Steam ได้รับทราบถึงการแครชที่เกิดขึ้นได้

เช่น

#ifdef _WIN32 #include <Windows.h> void MiniDumpFunction( unsigned int nExceptionCode, EXCEPTION_POINTERS *pException ) { // You can build and set an arbitrary comment to embed in the minidump here, // maybe you want to put what level the user was playing, how many players on the server, // how much memory is free, etc... SteamAPI_SetMiniDumpComment( "Minidump comment: SteamworksExample.exe/n" ); // The 0 here is a build ID, we don't set it SteamAPI_WriteMiniDump( nExceptionCode, pException, 0 ); } int RealMain( HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow ) { __debugbreak(); return 0; } int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { // All we do here is call the real main function after setting up our se translator // this allows us to catch exceptions and report errors to Steam. // // Note that you must set your compiler flags correctly to enable structured exception // handling in order for this particular setup method to work. if ( IsDebuggerPresent() ) { // We don't want to mask exceptions (or report them to Steam!) when debugging. // If you would like to step through the exception handler, attach a debugger // after running the game outside of the debugger. return RealMain( lpCmdLine, hInstance, nCmdShow ); } _set_se_translator( MiniDumpFunction ); try // this try block allows the SE translator to work { return RealMain( hInstance, lpCmdLine, nCmdShow ); } catch( ... ) { return -1; } } #endif

สิ่งที่ต้องทำล่วงหน้า

API การรายงานความผิดพลาดนั้นให้การรองรับเฉพาะแอปพลิเคชันประเภท 32 บิตที่ใช้งานบน Windows เท่านั้น