rodecomp/Source/Contents/Configuration/GraphicsConfiguration.h
ragnarok-clanker e168b4e4a6 Restore translation-unit ownership and publish verified source corrections
Owner-authorized source migration: 31 helper-only translation units were merged into their callers or existing inline headers; both build manifests updated. Includes the preserved source payload, Lua configuration matching wowdecomp, and exact malloca expansion without diagnostic pragmas.

449 native units compiled locally and 449 staged units compiled by the pinned server toolchain. No previously byte-matched function regressed. Compiler mapping diagnostics remain recorded as needs_cleanup, not accepted or peer-confirmed. Existing independent review records are preserved. README.md is intentionally unchanged.
2026-10-25 15:42:21 +00:00

91 lines
2.9 KiB
C++

#ifndef RAGNAROK_SOURCE_CONTENTS_CONFIGURATION_GRAPHICSCONFIGURATION_H
#define RAGNAROK_SOURCE_CONTENTS_CONFIGURATION_GRAPHICSCONFIGURATION_H
#include "Contents/Configuration/OptionWriter.h"
#include "Contents/Configuration/ScriptOptions.h"
#include "Render/RenderAdapter.h"
#include "Script/LuaScript.h"
#include <algorithm>
#include <windows.h>
struct GraphicsConfiguration {
GUID drawGuid;
GUID renderGuid;
int fullscreen;
int width;
int height;
int bitsPerPixel;
int oldWidth;
int oldHeight;
int reset;
int backend;
GUID deviceGuid;
char deviceName[32];
void Load(LuaScript& script, ScriptOptions& options, int& screenWidth, int& screenHeight);
AdapterConfiguration Adapter() const;
void Save(OptionWriter& output) const;
};
// INLINED
inline void GraphicsConfiguration::Load(LuaScript& script, ScriptOptions& options, int& screenWidth, int& screenHeight) {
const int resetPolicy = std::max(script.GlobalInteger("RenderSystemReset"), 0);
const int backendPolicy = std::max(script.GlobalInteger("RenderSystemDefault"), 0);
this->reset = options.Integer("RenderSystemReset", 1);
if (this->reset != resetPolicy) {
this->backend = backendPolicy;
this->reset = resetPolicy;
} else {
this->backend = options.Integer("RENDERSYSTEM", backendPolicy);
}
this->deviceGuid = options.Guid("DX9DEVICEID", GUID{});
const std::string name = options.String("DX9DEVICENAME", "");
strncpy_s(this->deviceName, sizeof(this->deviceName), name.c_str(), _TRUNCATE);
this->fullscreen = options.Integer("ISFULLSCREENMODE", 0);
this->width = options.Integer("WIDTH", 1024);
this->height = options.Integer("HEIGHT", 768);
this->oldWidth = options.Integer("OLD_WIDTH", 0);
this->oldHeight = options.Integer("OLD_HEIGHT", 0);
if (static_cast<unsigned>(this->height) < 664) {
this->width = 1024;
this->height = 768;
}
screenWidth = this->width;
screenHeight = this->height;
this->bitsPerPixel = options.Integer("BITPERPIXEL", 16);
OSVERSIONINFOA version{};
version.dwOSVersionInfoSize = sizeof(version);
GetVersionExA(&version);
if (version.dwMajorVersion >= 6 && version.dwMinorVersion >= 2) {
this->bitsPerPixel = 32;
}
}
inline AdapterConfiguration GraphicsConfiguration::Adapter() const {
return {this->backend, this->drawGuid, this->renderGuid, this->deviceGuid, this->deviceName};
}
// INLINED
inline void GraphicsConfiguration::Save(OptionWriter& output) const {
output.Integer("RenderSystemReset", this->reset);
output.Integer("RENDERSYSTEM", this->backend);
output.Guid("DX9DEVICEID", this->deviceGuid);
output.String("DX9DEVICENAME", this->deviceName);
output.Integer("ISFULLSCREENMODE", this->fullscreen);
output.Integer("WIDTH", this->width);
output.Integer("HEIGHT", this->height);
output.Integer("OLD_WIDTH", this->width);
output.Integer("OLD_HEIGHT", this->height);
output.Integer("BITPERPIXEL", this->bitsPerPixel);
}
#endif