/** * @brief Callback for subsystem failures. Depending on the severity, we may try to * recover, or we may shut the entire engine down and exit. */ static void Error(err_t err, const char *msg) { if (quetoo.debug_mask & DEBUG_BREAKPOINT) { SDL_TriggerBreakpoint(); } Print(va("^1%s\n", msg)); if (err == ERROR_DROP && !jmp_set) { err = ERROR_FATAL; } switch (err) { case ERROR_DROP: Sv_ShutdownServer(msg); Cl_Disconnect(); quetoo.recursive_error = false; longjmp(env, err); break; case ERROR_FATAL: default: Sys_Backtrace(); Shutdown(msg); exit(err); break; } }
/** * @brief Prints the specified message with a colored accent. */ static void Warn(const char *msg) { if (quetoo.debug_mask & DEBUG_BREAKPOINT) { SDL_TriggerBreakpoint(); } Print(va("^3%s", msg)); }
void testRefCountPtr() { LOG_INFO("About to test RefCountPtr"); { LOG_INFO("Simple Test"); int * testInt = new int(5); RefCountPtr<int> testPtr(testInt); LOG_INFO("Should be allocated with 1 reference"); SDL_TriggerBreakpoint(); } LOG_INFO("Should be freed"); SDL_TriggerBreakpoint(); { LOG_INFO("Multi reference Test"); int * testInt = new int(10); RefCountPtr<int> testPtr(testInt); RefCountPtr<int> testPtr2 = testPtr; LOG_INFO("Should have 2 references"); SDL_TriggerBreakpoint(); testPtr.reset(); LOG_INFO("Should have 1 references"); SDL_TriggerBreakpoint(); testPtr = testPtr2; LOG_INFO("Should have 2 references"); SDL_TriggerBreakpoint(); } LOG_INFO("Should be freed"); SDL_TriggerBreakpoint(); { LOG_INFO("PtrRoot Test"); int * testInt = new int(20); RefCountPtrRoot<int>* testRoot = new RefCountPtrRoot<int>(testInt, false, new TestPtrHelper<int>()); int * testInt2 = new int(40); RefCountPtrRoot<int>* testRoot2 = new RefCountPtrRoot<int>(testInt2, false, new TestPtrHelper<int>()); RefCountPtr<int> testPtr(testRoot); LOG_INFO("Should have 1 references"); SDL_TriggerBreakpoint(); RefCountPtr<int> testPtr2 = testPtr; LOG_INFO("Should have 2 references"); SDL_TriggerBreakpoint(); testPtr = RefCountPtr<int>(testRoot2); LOG_INFO("Should have 1 references"); SDL_TriggerBreakpoint(); testPtr.reset(); LOG_INFO("Should have 0 references"); SDL_TriggerBreakpoint(); testPtr2.reset(); LOG_INFO("Should have 0 references"); SDL_TriggerBreakpoint(); } LOG_INFO("Should be freed"); SDL_TriggerBreakpoint(); }
virtual inline void onNonZeroReferences() { LOG_INFO("On Non Zero References"); SDL_TriggerBreakpoint(); PtrHelper<T>::onNonZeroReferences(); }