void OpenGLRenderer::beforeResize(bool wasOrIsFullscreen) { #if ARX_PLATFORM == ARX_PLATFORM_LINUX || ARX_PLATFORM == ARX_PLATFORM_BSD // No re-initialization needed ARX_UNUSED(wasOrIsFullscreen); #else if(!isInitialized()) { return; } #if ARX_PLATFORM == ARX_PLATFORM_WIN32 if(!wasOrIsFullscreen) { return; } #else // By default, always reinit to avoid issues on untested platforms ARX_UNUSED(wasOrIsFullscreen); #endif shutdown(); #endif }
static void ARX_GLAPIENTRY callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * message, const void * userParam) { ARX_UNUSED(length); ARX_UNUSED(userParam); std::ostringstream buffer; const GLchar * end = message + std::strlen(message); while(end != message && (*(end - 1) == '\r' || *(end - 1) == '\n')) { end--; } buffer << sourceToString(source) << " " << typeToString(type) << " #"<< id << ": "; buffer.write(message, end - message); switch(severity) { case GL_DEBUG_SEVERITY_HIGH_ARB: LogError << buffer.str(); break; case GL_DEBUG_SEVERITY_MEDIUM_ARB: LogWarning << buffer.str(); break; case GL_DEBUG_SEVERITY_LOW_ARB: LogInfo << buffer.str(); break; default: break; } }
void CriticalErrorDialog::log(const Source & file, int line, Logger::LogLevel level, const std::string & str) { ARX_UNUSED(file), ARX_UNUSED(line); if(level == Logger::Critical && errorString.empty()) { errorString = str; } }
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow) { ARX_UNUSED(hInstance); ARX_UNUSED(hPrevInstance); ARX_UNUSED(lpCmdLine); ARX_UNUSED(nCmdShow); WindowsMain init; return utf8_main(init.argc, init.argv); }
bool CrashHandler::setNamedVariable(const std::string & name, const std::string & value) { #ifdef HAVE_CRASHHANDLER if(!isInitialized()) { return false; } return gCrashHandlerImpl->setNamedVariable(name, value); #else ARX_UNUSED(name), ARX_UNUSED(value); return false; #endif }
int main(int argc, char *argv[]) { ARX_UNUSED(argc); ARX_UNUSED(argv); CppUnit::TextTestRunner runner; runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cout, "%f:%l ")); runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); runner.run(""); CppUnit::TestResultCollector & result = runner.result(); return result.wasSuccessful() ? EXIT_SUCCESS : EXIT_FAILURE; }
bool ErrorReport::GetCrashDump(const fs::path & fileName) { #if ARX_PLATFORM == ARX_PLATFORM_WIN32 bool bHaveDump = false; if(fs::exists(m_pCrashInfo->miniDumpTmpFile)) { fs::path fullPath = m_ReportFolder / fileName; if(fs::rename(m_pCrashInfo->miniDumpTmpFile, fullPath)) { AddFile(fullPath); bHaveDump = true; } } return bHaveDump; #else // ARX_PLATFORM != ARX_PLATFORM_WIN32 ARX_UNUSED(fileName); // TODO: Write core dump to // fs::path fullPath = m_ReportFolder / fileName; return getCrashDescription(); #endif }
void MassIncinerateSpell::Update(float timeDelta) { ARX_UNUSED(timeDelta); if(ValidIONum(m_caster)) { ARX_SOUND_RefreshPosition(m_snd_loop, entities[m_caster]->pos); } }
void Thread::setPriority(Priority priority) { arx_assert(priority >= Lowest && priority <= Highest); BOOL ret = SetThreadPriority(thread, windowsThreadPriorities[priority - Lowest]); arx_assert(ret); ARX_UNUSED(ret); }
bool getSystemConfiguration(const std::string & name, std::string & result) { #ifdef ARX_HAVE_WINAPI if(getRegistryValue(HKEY_CURRENT_USER, name, result)) { return true; } if(getRegistryValue(HKEY_LOCAL_MACHINE, name, result)) { return true; } #else ARX_UNUSED(name), ARX_UNUSED(result); #endif return false; }
void ScreenshotWidget::paintEvent(QPaintEvent * event) { ARX_UNUSED(event); QPainter p(this); p.setRenderHint(QPainter::SmoothPixmapTransform); QPixmap scaledPixmap = m_pixmap.scaled(size(), Qt::KeepAspectRatio); p.drawPixmap(0, 0, scaledPixmap); }
void onChangedRenderer(int pos, const std::string & str) { ARX_UNUSED(str); switch(pos) { case 0: config.window.framework = "auto"; break; case 1: config.window.framework = "SDL"; break; default: config.window.framework = "auto"; break; } }
static EERIE_3DOBJ * TheoToEerie_Fast(const res::path & texpath, const res::path & file, bool pbox) { EERIE_3DOBJ * ret = ARX_FTL_Load(file); if(ret) { if(pbox) { EERIE_PHYSICS_BOX_Create(ret); } return ret; } #if !BUILD_EDIT_LOADSAVE ARX_UNUSED(texpath); #else ret = GetExistingEerie(file); if(ret) { ret = Eerie_Copy(ret); } if(!ret) { size_t size = 0; char * adr = resources->readAlloc(file, size); if(!adr) { LogWarning << "Object not found: " << file; return NULL; } ret = TheoToEerie(adr, size, texpath, file); if(!ret) { free(adr); return NULL; } EERIE_OBJECT_CenterObjectCoordinates(ret); free(adr); } CreateNeighbours(ret); EERIEOBJECT_AddClothesData(ret); KillNeighbours(ret); if(ret->cdata) { EERIE_COLLISION_SPHERES_Create(ret); // Must be out of the Neighbours zone } if(pbox) { EERIE_PHYSICS_BOX_Create(ret); } ARX_FTL_Save(fs::paths.user / file.string(), ret); #endif // BUILD_EDIT_LOADSAVE return ret; }
void CrashHandler::unregisterCrashCallback(CrashCallback crashCallback) { #ifdef HAVE_CRASHHANDLER if(!isInitialized()) { return; } gCrashHandlerImpl->unregisterCrashCallback(crashCallback); #else ARX_UNUSED(crashCallback); #endif }
bool Win32Window::initialize(const std::string & title, Vec2i size, bool fullscreen, unsigned depth) { ARX_UNUSED(depth); if(!registerWindowClass()) { LogError << "Failed to register the Win32 window class"; return false; } DWORD windowStyle = fullscreen ? (WS_POPUP | WS_VISIBLE) : WS_OVERLAPPEDWINDOW; DWORD windowExtendedStyle = WS_EX_APPWINDOW; RECT rcWnd; SetRect(&rcWnd, 0, 0, size.x, size.y); BOOL hasMenu = GetMenu(m_hWnd) != NULL; if(AdjustWindowRectEx(&rcWnd, windowStyle, hasMenu, windowExtendedStyle) != TRUE) { LogError << "AdjustWindowRectEx() failed"; return false; } // Bound the window size to the desktop HWND hWndDesktop = GetDesktopWindow(); RECT rcDesktop; GetWindowRect(hWndDesktop, &rcDesktop); LONG maxWidth = rcDesktop.right - rcDesktop.left; LONG maxHeight = rcDesktop.bottom - rcDesktop.top; LONG wndWidth = rcWnd.right - rcWnd.left; LONG wndHeight = rcWnd.bottom - rcWnd.top; wndWidth = std::min(wndWidth, maxWidth); wndHeight = std::min(wndHeight, maxHeight); // Create a window using our window class. m_hWnd = CreateWindowEx(windowExtendedStyle, m_WindowClass.lpszClassName, "", windowStyle, CW_USEDEFAULT, CW_USEDEFAULT, wndWidth, wndHeight, 0, NULL, (HINSTANCE)GetModuleHandle(NULL), this); if(!m_hWnd) { LogError << "Couldn't create window"; return false; } if(SetWindowText(m_hWnd, title.c_str()) == TRUE) { title_ = title; } else { LogWarning << "Couldn't change the window's title"; } ShowWindow(m_hWnd, SW_SHOW); isVisible_ = true; isFullscreen_ = fullscreen; size_ = size; return true; }
bool CrashHandler::setReportLocation(const fs::path & location) { #ifdef HAVE_CRASHHANDLER if(!isInitialized()) { return false; } return gCrashHandlerImpl->setReportLocation(location); #else ARX_UNUSED(location); return false; #endif }
bool CrashHandler::deleteOldReports(size_t nbReportsToKeep) { #ifdef HAVE_CRASHHANDLER if(!isInitialized()) { return false; } return gCrashHandlerImpl->deleteOldReports(nbReportsToKeep); #else ARX_UNUSED(nbReportsToKeep); return false; #endif }
static mode_t dirstat(void * handle, void * entry) { arx_assert(entry != NULL); fs::path file = ITERATOR_HANDLE(handle)->path / reinterpret_cast<dirent *>(entry)->d_name; struct stat buf; int ret = stat(file.string().c_str(), &buf); arx_assert_msg(ret == 0, "stat failed: %d", ret); ARX_UNUSED(ret); return buf.st_mode; }
bool CrashHandler::addAttachedFile(const fs::path & file) { #ifdef HAVE_CRASHHANDLER if(!isInitialized()) { return false; } return gCrashHandlerImpl->addAttachedFile(file); #else ARX_UNUSED(file); return false; #endif }
int SDLCALL SDL2Window::eventFilter(void * userdata, SDL_Event * event) { ARX_UNUSED(userdata); // TODO support multiple windows! if(s_mainWindow && event->type == SDL_QUIT) { return (s_mainWindow->onClose()) ? 1 : 0; } return 1; }
void Lock::lock() { pthread_mutex_lock(&mutex); while(locked) { int rc = pthread_cond_wait(&cond, &mutex); arx_assert(rc == 0); ARX_UNUSED(rc); } locked = true; pthread_mutex_unlock(&mutex); }
void MagicSightSpell::Update(float timeDelta) { ARX_UNUSED(timeDelta); if(m_caster == PlayerEntityHandle) { Vec3f pos; ARX_PLAYER_FrontPos(&pos); ARX_SOUND_RefreshPosition(m_snd_loop, pos); if(subj.focal > IMPROVED_FOCAL) subj.focal -= DEC_FOCAL; } }
static mode_t dirstat(void * handle, void * entry) { arx_assert(entry != NULL); int fd = dirfd(DIR_HANDLE(handle)); arx_assert(fd != -1); const char * name = reinterpret_cast<dirent *>(entry)->d_name; struct stat buf; int ret = fstatat(fd, name, &buf, 0); arx_assert_msg(ret == 0, "fstatat failed: %d", ret); ARX_UNUSED(ret); return buf.st_mode; }
void ColdProtectionSpell::Update(float timeDelta) { ARX_UNUSED(timeDelta); if(ValidIONum(m_target)) { Entity *io = entities[m_target]; io->halo.flags = HALO_ACTIVE; io->halo.color = Color3f(0.2f, 0.2f, 0.45f); io->halo.radius = 45.f; } ARX_SOUND_RefreshPosition(m_snd_loop, entities[m_target]->pos); }
static int xmessageCommand(DialogType type, const std::string & message, const std::string & title) { ARX_UNUSED(title); std::vector<const char *> command; command.push_back("xmessage"); xmessageButtons(command, type); command.push_back(message.c_str()); command.push_back(NULL); return platform::run(&command[0]); }
void onChangedResolution(int pos, const std::string & str) { ARX_UNUSED(pos); if(str == AUTO_RESOLUTION_STRING) { newWidth = newHeight = 0; } else { std::stringstream ss(str); int iX = config.video.resolution.x; int iY = config.video.resolution.y; char tmp; ss >> iX >> tmp >> iY; newWidth = iX; newHeight = iY; } }
void ErrorReportDialog::onShowFileContent(const QItemSelection& newSelection, const QItemSelection & oldSelection) { ARX_UNUSED(oldSelection); const QModelIndexList selectedIndexes = newSelection.indexes(); if(selectedIndexes.empty()) return; const QModelIndex selectedIndex = selectedIndexes.at(0); if(!selectedIndex.isValid()) return; fs::path fileName = m_errorReport.GetAttachedFiles()[selectedIndex.row()].path; QString ext = fileName.ext().c_str(); if(ext == ".txt" || ext == ".log" || ext == ".ini" || ext == ".xml") { QFile textFile(fileName.string().c_str()); textFile.open(QIODevice::ReadOnly | QIODevice::Text); QByteArray data; data = textFile.readAll(); ui->fileViewText->setText(QString::fromUtf8(data)); ui->stackedFileViews->setCurrentIndex(0); } else if(ext == ".jpg" || ext == ".jpeg" || ext == ".bmp" || ext == ".png" || ext == ".gif") { m_fileViewImage.load(fileName.string().c_str()); ui->stackedFileViews->setCurrentIndex(1); } else { QFile binaryFile(fileName.string().c_str()); binaryFile.open(QIODevice::ReadOnly); if(binaryFile.size() > 20 * 1024 * 1024) { ui->stackedFileViews->setCurrentIndex(3); return; } QByteArray data; data = binaryFile.readAll(); m_fileViewHex.setData(data); ui->stackedFileViews->setCurrentIndex(2); } }
void TeleportSpell::Update(float timeDelta) { ARX_UNUSED(timeDelta); const unsigned long tim = arxtime.now_ul(); float TELEPORT = (float)(((float)tim-(float)m_timcreation)/(float)m_duration); if(LASTTELEPORT < 0.5f && TELEPORT >= 0.5f) { Vec3f pos = lastteleport; lastteleport = player.pos; player.pos = pos; LASTTELEPORT = 32.f; ARX_SOUND_PlaySFX(SND_SPELL_TELEPORTED, &player.pos); } else { LASTTELEPORT = TELEPORT; } }
static bool is_fd_disabled(int fd) { ARX_UNUSED(fd); // Disable the console log backend if output is redirected to /dev/null #ifdef ARX_HAVE_READLINK static const char * names[] = { NULL, "/proc/self/fd/1", "/proc/self/fd/2" }; char path[64]; ssize_t len = readlink(names[fd], path, ARRAY_SIZE(path)); if(len == 9 && !memcmp(path, "/dev/null", 9)) { return true; } else if(len == -1 && errno == ENOENT) { return true; } #endif return false; }
// Obtain the right savegame paths for the platform // XP is "%USERPROFILE%\My Documents\My Games" // Vista and up : "%USERPROFILE%\Saved Games" void defineSystemDirectories(const char * argv0) { ARX_UNUSED(argv0); std::string strPath; DWORD winver = GetVersion(); // Vista and up if((DWORD)(LOBYTE(LOWORD(winver))) >= 6) { // Don't hardlink with SHGetKnownFolderPath to allow the game to start on XP too! typedef HRESULT (WINAPI * PSHGetKnownFolderPath)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR* ppszPath); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); PSHGetKnownFolderPath GetKnownFolderPath = (PSHGetKnownFolderPath)GetProcAddress(GetModuleHandleA("shell32.dll"), "SHGetKnownFolderPath"); const GUID FOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}}; LPWSTR wszPath = NULL; HRESULT hr = GetKnownFolderPath(FOLDERID_SavedGames, kfFlagCreate | kfFlagNoAlias, NULL, &wszPath); if(SUCCEEDED(hr)) { strPath = ws2s(wszPath); } CoTaskMemFree(wszPath); CoUninitialize(); } else if((DWORD)(LOBYTE(LOWORD(winver))) == 5) { // XP CHAR szPath[MAX_PATH]; HRESULT hr = SHGetFolderPathA(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, szPath); if(SUCCEEDED(hr)) { strPath = szPath; strPath += "\\My Games"; } } else { arx_assert_msg(false, "Unsupported windows version (below WinXP)"); } if(!strPath.empty()) { SetEnvironmentVariable("FOLDERID_SavedGames", strPath.c_str()); } }