This commit is contained in:
DepressedTWM 2026-08-07 16:19:56 +04:00
parent a458573a84
commit 4a62b9551b
3 changed files with 110 additions and 191 deletions

View file

@ -48,3 +48,4 @@ glstate Alpha calculation fix backported from MKXP
Added VALUE support in debugwriter.h Added VALUE support in debugwriter.h
When STATIC build option is enabled, enable static libc++ and libgcc When STATIC build option is enabled, enable static libc++ and libgcc
CPU specific optimizations moved to separated Toolchanin files CPU specific optimizations moved to separated Toolchanin files
Documents path search code rewrited to crossplatform SDL functions.

View file

@ -662,7 +662,7 @@ void EventThread::notifyFrame(){
fps.displayCounter = 0; fps.displayCounter = 0;
fps.immFiniFlag.clear(); fps.immFiniFlag.clear();
int32_t avgFPS = fps.acc / fps.accDiv; int32_t avgFPS = fps.accDiv;
fps.acc = fps.accDiv = 0; fps.acc = fps.accDiv = 0;
SDL_Event event; SDL_Event event;

View file

@ -1,9 +1,4 @@
#include "oneshot.h" #include "oneshot.h"
/******************
* HERE BE DRAGONS
******************/
#include "eventthread.h" #include "eventthread.h"
#include "debugwriter.h" #include "debugwriter.h"
#include "bitmap.h" #include "bitmap.h"
@ -17,37 +12,36 @@
#include <SDL3/SDL_messagebox.h> #include <SDL3/SDL_messagebox.h>
#include <SDL3/SDL_filesystem.h> #include <SDL3/SDL_filesystem.h>
// OS-Specific code // OS-Specific code
#if defined(_WIN32) #if windows
#define SECURITY_WIN32 #define SECURITY_WIN32
#include <windows.h> #include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include <security.h> #include <security.h>
#include <secext.h> #include <secext.h>
#include <shlobj.h> #include <shlobj.h>
#elif defined(__APPLE__) #elif apple
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <pwd.h> #include <pwd.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <dispatch/dispatch.h> #include <dispatch/dispatch.h>
#elif unix_like #elif unix_like
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <pwd.h> #include <pwd.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include "xdg-user-dir-lookup.h" #include "xdg-user-dir-lookup.h"
#else #else
#error "Operating system not detected or unsupported." #error "Operating system not detected or unsupported."
#endif #endif
const Config conf; const Config conf;
#define DEF_SCREEN_W conf.defScreenW #define DEF_SCREEN_W conf.defScreenW
#define DEF_SCREEN_H conf.defScreenH #define DEF_SCREEN_H conf.defScreenH
struct OneshotPrivate struct OneshotPrivate{
{
// Main SDL window // Main SDL window
SDL_Window *window; SDL_Window *window;
@ -80,16 +74,14 @@ struct OneshotPrivate
{ {
} }
~OneshotPrivate() ~OneshotPrivate(){
{
SDL_DestroyMutex(winMutex); SDL_DestroyMutex(winMutex);
} }
}; };
// OS-SPECIFIC FUNCTIONS // OS-SPECIFIC FUNCTIONS
#if unix_like #if unix_like
struct linux_DialogData struct linux_DialogData{
{
// Input // Input
int type; int type;
const char *body; const char *body;
@ -99,14 +91,12 @@ struct linux_DialogData
bool result; bool result;
}; };
static int linux_dialog(void *rawData) static int linux_dialog(void *rawData){
{
linux_DialogData *data = reinterpret_cast<linux_DialogData *>(rawData); linux_DialogData *data = reinterpret_cast<linux_DialogData *>(rawData);
// Determine correct flags // Determine correct flags
GtkMessageType gtktype; GtkMessageType gtktype;
GtkButtonsType gtkbuttons = GTK_BUTTONS_OK; GtkButtonsType gtkbuttons = GTK_BUTTONS_OK;
switch (data->type) switch (data->type){
{
case Oneshot::MSG_INFO: case Oneshot::MSG_INFO:
gtktype = GTK_MESSAGE_INFO; gtktype = GTK_MESSAGE_INFO;
break; break;
@ -137,14 +127,12 @@ static int linux_dialog(void *rawData)
return 0; return 0;
} }
#elif defined _WIN32 #elif windows
/* Convert WCHAR pointer to std::string */ /* Convert WCHAR pointer to std::string */
static std::string w32_fromWide(const WCHAR *ustr) static std::string w32_fromWide(const WCHAR *ustr){
{
std::string result; std::string result;
int size = WideCharToMultiByte(CP_UTF8, 0, ustr, -1, 0, 0, 0, 0); int size = WideCharToMultiByte(CP_UTF8, 0, ustr, -1, 0, 0, 0, 0);
if (size > 0) if (size > 0){
{
CHAR *str = new CHAR[size]; CHAR *str = new CHAR[size];
if (WideCharToMultiByte(CP_UTF8, 0, ustr, -1, str, size, 0, 0) == size) if (WideCharToMultiByte(CP_UTF8, 0, ustr, -1, str, size, 0, 0) == size)
result = str; result = str;
@ -153,13 +141,10 @@ static std::string w32_fromWide(const WCHAR *ustr)
return result; return result;
} }
/* Convert WCHAR pointer from const char* */ /* Convert WCHAR pointer from const char* */
static WCHAR *w32_toWide(const char *str) static WCHAR *w32_toWide(const char *str){
{ if (str){
if (str)
{
int size = MultiByteToWideChar(CP_UTF8, 0, str, -1, 0, 0); int size = MultiByteToWideChar(CP_UTF8, 0, str, -1, 0, 0);
if (size > 0) if (size > 0){
{
WCHAR *ustr = new WCHAR[size]; WCHAR *ustr = new WCHAR[size];
if (MultiByteToWideChar(CP_UTF8, 0, str, -1, ustr, size) == size) if (MultiByteToWideChar(CP_UTF8, 0, str, -1, ustr, size) == size)
return ustr; return ustr;
@ -174,8 +159,7 @@ static WCHAR *w32_toWide(const char *str)
} }
#endif #endif
Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData) Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData){
{
p = new OneshotPrivate(); p = new OneshotPrivate();
p->window = threadData.window; p->window = threadData.window;
p->savePath = threadData.config.commonDataPath.substr(0, threadData.config.commonDataPath.size() - 1); p->savePath = threadData.config.commonDataPath.substr(0, threadData.config.commonDataPath.size() - 1);
@ -187,18 +171,19 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData)
p->obscuredNeedToUpdate = false; p->obscuredNeedToUpdate = false;
p->allowExit = true; p->allowExit = true;
p->exiting = false; p->exiting = false;
#ifdef _WIN32 #ifdef windows
p->os = "windows"; p->os = "windows";
#elif __APPLE__ #elif apple
p->os = "macos"; p->os = "macos";
#elif unix_like #elif unix_like
//TODO: FIX IT
p->os = "linux"; p->os = "linux";
#endif #endif
/******************** /********************
* USERNAME/DOCS PATH * USERNAME/DOCS PATH
********************/ ********************/
#if defined _WIN32 #if windows
// Get language code // Get language code
WCHAR wlang[9]; WCHAR wlang[9];
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, wlang, sizeof(wlang) / sizeof(WCHAR)); GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, wlang, sizeof(wlang) / sizeof(WCHAR));
@ -209,86 +194,71 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData)
// Get user's name // Get user's name
ULONG size = 0; ULONG size = 0;
GetUserNameEx(NameDisplay, 0, &size); GetUserNameEx(NameDisplay, 0, &size);
if (GetLastError() == ERROR_MORE_DATA) if (GetLastError() == ERROR_MORE_DATA){
{
// Get their full (display) name // Get their full (display) name
WCHAR *name = new WCHAR[size]; WCHAR *name = new WCHAR[size];
GetUserNameEx(NameDisplay, name, &size); GetUserNameEx(NameDisplay, name, &size);
p->userName = w32_fromWide(name); p->userName = w32_fromWide(name);
delete[] name; delete[] name;
} }else{
else
{
// Get their login name // Get their login name
DWORD size2 = 0; DWORD size2 = 0;
GetUserName(0, &size2); GetUserName(0, &size2);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){
{
WCHAR *name = new WCHAR[size2]; WCHAR *name = new WCHAR[size2];
GetUserName(name, &size2); GetUserName(name, &size2);
p->userName = w32_fromWide(name); p->userName = w32_fromWide(name);
delete[] name; delete[] name;
} }
} }
// Get documents path
WCHAR path[MAX_PATH];
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path);
p->docsPath = w32_fromWide(path);
p->gamePath = p->docsPath + "\\My Games";
p->journal = "_______.exe"; p->journal = "_______.exe";
#else #else
// Get language code // Get language code
const char *lc_all = SDL_getenv("LC_ALL"); const char *lc_all = SDL_getenv("LC_ALL");
const char *lang = SDL_getenv("LANG"); const char *lang = SDL_getenv("LANG");
const char *code = (lc_all ? lc_all : lang); const char *code = (lc_all ? lc_all : lang);
if (code) if (code){
{
// find first dot, copy language code // find first dot, copy language code
int end = 0; int end = 0;
for (; code[end] && code[end] != '.'; ++end) for (; code[end] && code[end] != '.'; ++end){}
{
}
p->lang = std::string(code, end); p->lang = std::string(code, end);
} }
else else
p->lang = "en"; p->lang = "en";
// Get user's name // Get user's name
#ifdef OS_OSX #ifdef apple
struct passwd *pwd = getpwuid(geteuid()); struct passwd *pwd = getpwuid(geteuid());
#elif unix_like #elif unix_like
struct passwd *pwd = getpwuid(getuid()); struct passwd *pwd = getpwuid(getuid());
#endif #endif
if (pwd) if (pwd){
{ if (pwd->pw_gecos && pwd->pw_gecos[0] && pwd->pw_gecos[0] != ','){
if (pwd->pw_gecos && pwd->pw_gecos[0] && pwd->pw_gecos[0] != ',')
{
// Get the user's full name // Get the user's full name
int comma = 0; int comma = 0;
for (; pwd->pw_gecos[comma] && pwd->pw_gecos[comma] != ','; ++comma) for (; pwd->pw_gecos[comma] && pwd->pw_gecos[comma] != ','; ++comma){}
{
}
p->userName = std::string(pwd->pw_gecos, comma); p->userName = std::string(pwd->pw_gecos, comma);
} }
else else
p->userName = pwd->pw_name; p->userName = pwd->pw_name;
} }
// Get documents path #ifdef apple
#ifdef __APPLE__
std::string path = std::string(SDL_getenv("HOME")) + "/Documents";
p->docsPath = path.c_str();
p->gamePath = path.c_str();
p->journal = "_______.app"; p->journal = "_______.app";
#elif unix_like #elif unix_like
char *path = xdg_user_dir_lookup("DOCUMENTS");
p->docsPath = path;
p->gamePath = path;
p->journal = "_______"; p->journal = "_______";
#endif #endif
#endif #endif
// Get documents path
const char* path = SDL_GetUserFolder(SDL_FOLDER_DOCUMENTS);
p->docsPath = path;
#ifdef windows
p->gamePath = path "\\My Games";
#else
p->gamePath = path;
#endif
Debug() << "[oneshot] Game path :" << p->gamePath; Debug() << "[oneshot] Game path :" << p->gamePath;
Debug() << "[oneshot] Docs path :" << p->docsPath; Debug() << "[oneshot] Docs path :" << p->docsPath;
@ -296,46 +266,29 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData)
char const *xdg_current_desktop = SDL_getenv("XDG_CURRENT_DESKTOP"); char const *xdg_current_desktop = SDL_getenv("XDG_CURRENT_DESKTOP");
gtk_init(0, 0); gtk_init(0, 0);
if (xdg_current_desktop == NULL) if (xdg_current_desktop == NULL){
{
desktopEnv = "nope"; desktopEnv = "nope";
} }else{
else
{
std::string desktop(xdg_current_desktop); std::string desktop(xdg_current_desktop);
std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::SDL_tolower); std::transform(desktop.begin(), desktop.end(), desktop.begin(), ::SDL_tolower);
if (desktop.find("cinnamon") != std::string::npos) if (desktop.find("cinnamon") != std::string::npos){
{
desktopEnv = "cinnamon"; desktopEnv = "cinnamon";
} }else if (
else if (
desktop.find("gnome") != std::string::npos || desktop.find("gnome") != std::string::npos ||
desktop.find("unity") != std::string::npos) desktop.find("unity") != std::string::npos)
{ {
desktopEnv = "gnome"; desktopEnv = "gnome";
} }else if (desktop.find("mate") != std::string::npos){
else if (desktop.find("mate") != std::string::npos)
{
desktopEnv = "mate"; desktopEnv = "mate";
} }else if (desktop.find("xfce") != std::string::npos){
else if (desktop.find("xfce") != std::string::npos)
{
desktopEnv = "xfce"; desktopEnv = "xfce";
} }else if (desktop.find("kde") != std::string::npos){
else if (desktop.find("kde") != std::string::npos)
{
desktopEnv = "kde"; desktopEnv = "kde";
} }else if (desktop.find("lxde") != std::string::npos){
else if (desktop.find("lxde") != std::string::npos)
{
desktopEnv = "lxde"; desktopEnv = "lxde";
} }else if (desktop.find("lxqt") != std::string::npos){
else if (desktop.find("lxqt") != std::string::npos)
{
desktopEnv = "lxqt"; desktopEnv = "lxqt";
} }else if (desktop.find("deepin") != std::string::npos){
else if (desktop.find("deepin") != std::string::npos)
{
desktopEnv = "deepin"; desktopEnv = "deepin";
} }
} }
@ -346,7 +299,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData)
/******** /********
* MISC * MISC
********/ ********/
#if defined _WIN32 #if windows
// Get windows version // Get windows version
OSVERSIONINFOW version; OSVERSIONINFOW version;
ZeroMemory(&version, sizeof(version)); ZeroMemory(&version, sizeof(version));
@ -355,106 +308,82 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData)
#endif #endif
} }
Oneshot::~Oneshot() Oneshot::~Oneshot(){
{
delete p; delete p;
} }
const std::string &Oneshot::os() const const std::string &Oneshot::os() const{
{
return p->os; return p->os;
} }
const std::string &Oneshot::lang() const const std::string &Oneshot::lang() const{
{
return p->lang; return p->lang;
} }
const std::string &Oneshot::userName() const const std::string &Oneshot::userName() const{
{
return p->userName; return p->userName;
} }
const std::string &Oneshot::savePath() const const std::string &Oneshot::savePath() const{
{
return p->savePath; return p->savePath;
} }
const std::string &Oneshot::docsPath() const const std::string &Oneshot::docsPath() const{
{
return p->docsPath; return p->docsPath;
} }
const std::string &Oneshot::gamePath() const const std::string &Oneshot::gamePath() const{
{
return p->gamePath; return p->gamePath;
} }
const std::string &Oneshot::journal() const const std::string &Oneshot::journal() const{
{
return p->journal; return p->journal;
} }
const std::vector<uint8_t> &Oneshot::obscuredMap() const const std::vector<uint8_t> &Oneshot::obscuredMap() const{
{
return p->obscuredMap; return p->obscuredMap;
} }
bool Oneshot::obscuredCleared() const bool Oneshot::obscuredCleared() const{
{
return p->obscuredCleared; return p->obscuredCleared;
} }
bool Oneshot::exiting() const bool Oneshot::exiting() const{
{
return p->exiting; return p->exiting;
} }
bool Oneshot::allowExit() const bool Oneshot::allowExit() const{
{
return p->allowExit; return p->allowExit;
} }
void Oneshot::setYesNo(const char *yes, const char *no) void Oneshot::setYesNo(const char *yes, const char *no){
{
p->txtYes = yes; p->txtYes = yes;
p->txtNo = no; p->txtNo = no;
} }
void Oneshot::setExiting(bool exiting) void Oneshot::setExiting(bool exiting){
{ if (p->exiting != exiting){
if (p->exiting != exiting)
{
p->exiting = exiting; p->exiting = exiting;
if (exiting) if (exiting){
{
threadData.exiting.set(); threadData.exiting.set();
} }else{
else
{
threadData.exiting.clear(); threadData.exiting.clear();
} }
} }
} }
void Oneshot::setAllowExit(bool allowExit) void Oneshot::setAllowExit(bool allowExit){
{ if (p->allowExit != allowExit){
if (p->allowExit != allowExit)
{
p->allowExit = allowExit; p->allowExit = allowExit;
if (allowExit) if (allowExit){
{
threadData.allowExit.set(); threadData.allowExit.set();
} }else{
else
{
threadData.allowExit.clear(); threadData.allowExit.clear();
} }
} }
} }
bool Oneshot::msgbox(int type, const char *body, const char *title) bool Oneshot::msgbox(int type, const char *body, const char *title){
{
if (!title) if (!title)
title = ""; title = "";
#ifdef unix_like #ifdef unix_like
@ -478,38 +407,36 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
data.colorScheme = 0; data.colorScheme = 0;
data.title = title; data.title = title;
data.message = body; data.message = body;
#ifdef _WIN32 #ifdef windows
DWORD sound; DWORD sound;
#endif #endif
// Set type // Set type
switch (type) switch (type){
{
case MSG_INFO: case MSG_INFO:
case MSG_YESNO: case MSG_YESNO:
default: default:
data.flags = SDL_MESSAGEBOX_INFORMATION; data.flags = SDL_MESSAGEBOX_INFORMATION;
#ifdef _WIN32 #ifdef windows
sound = SND_ALIAS_SYSTEMQUESTION; sound = SND_ALIAS_SYSTEMQUESTION;
#endif #endif
break; break;
case MSG_WARN: case MSG_WARN:
data.flags = SDL_MESSAGEBOX_WARNING; data.flags = SDL_MESSAGEBOX_WARNING;
#ifdef _WIN32 #ifdef windows
sound = SND_ALIAS_SYSTEMEXCLAMATION; sound = SND_ALIAS_SYSTEMEXCLAMATION;
#endif #endif
break; break;
case MSG_ERR: case MSG_ERR:
data.flags = SDL_MESSAGEBOX_WARNING; data.flags = SDL_MESSAGEBOX_WARNING;
#ifdef _WIN32 #ifdef windows
sound = SND_ALIAS_SYSTEMASTERISK; sound = SND_ALIAS_SYSTEMASTERISK;
#endif #endif
break; break;
} }
// Set buttons // Set buttons
switch (type) switch (type){
{
case MSG_INFO: case MSG_INFO:
case MSG_WARN: case MSG_WARN:
case MSG_ERR: case MSG_ERR:
@ -524,12 +451,12 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
} }
// Show messagebox // Show messagebox
#ifdef _WIN32 #ifdef windows
PlaySoundW(MAKEINTRESOURCEW(sound), NULL, SND_ALIAS_ID | SND_ASYNC); PlaySoundW(MAKEINTRESOURCEW(sound), NULL, SND_ALIAS_ID | SND_ASYNC);
#endif #endif
int button; int button;
#ifdef __APPLE__ #ifdef apple
int *btn = &button; int *btn = &button;
// Message boxes and UI changes must be performed from the main thread on macOS Mojave and above. // Message boxes and UI changes must be performed from the main thread on macOS Mojave and above.
@ -543,11 +470,10 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
#endif #endif
return button ? true : false; return button ? true : false;
#endif // #ifdef OS_LINUX #endif
} }
std::string Oneshot::textinput(const char *prompt, int char_limit, const char *fontName) std::string Oneshot::textinput(const char *prompt, int char_limit, const char *fontName){
{
std::vector<std::string> *fontNames = new std::vector<std::string>(); std::vector<std::string> *fontNames = new std::vector<std::string>();
fontNames->push_back(fontName); fontNames->push_back(fontName);
fontNames->push_back("VL Gothic"); fontNames->push_back("VL Gothic");
@ -568,10 +494,8 @@ std::string Oneshot::textinput(const char *prompt, int char_limit, const char *f
SDL_StartTextInput(this->p->window); SDL_StartTextInput(this->p->window);
// Main loop // Main loop
while (threadData.acceptingTextInput) while (threadData.acceptingTextInput){
{ if (inputTextPrev != threadData.inputText){
if (inputTextPrev != threadData.inputText)
{
inputBmp->clear(); inputBmp->clear();
inputBmp->drawText(DEF_SCREEN_W / 2, DEF_SCREEN_H / 2, DEF_SCREEN_W, DEF_SCREEN_H, threadData.inputText.c_str(), 1); inputBmp->drawText(DEF_SCREEN_W / 2, DEF_SCREEN_H / 2, DEF_SCREEN_W, DEF_SCREEN_H, threadData.inputText.c_str(), 1);
inputTextPrev = threadData.inputText; inputTextPrev = threadData.inputText;
@ -594,8 +518,7 @@ void Oneshot::updateObscuredSize(int winW, int winH){
p->obscuredMap.resize(p->winW * p->winH, 255); p->obscuredMap.resize(p->winW * p->winH, 255);
} }
void Oneshot::updateObscured(int winX, int winY) void Oneshot::updateObscured(int winX, int winY){
{
SDL_LockMutex(p->winMutex); SDL_LockMutex(p->winMutex);
p->winX = winX; p->winX = winX;
p->winY = winY; p->winY = winY;
@ -619,13 +542,12 @@ void Oneshot::updateObscured(int winX, int winY)
int num_displays; int num_displays;
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays); SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
if (!displays) if (!displays)
printf("SDL_GetDisplays failed (oneshot.cpp)\n"); Debug() << "SDL_GetDisplays failed (oneshot.cpp)";
// Update obscured map and texture for window portion offscreen // Update obscured map and texture for window portion offscreen
for (int i = 0, max = num_displays; i < max; ++i) for (int i = 0, max = num_displays; i < max; ++i){
{
SDL_Rect bounds; SDL_Rect bounds;
if (!SDL_GetDisplayBounds(displays[i], &bounds)) if (!SDL_GetDisplayBounds(displays[i], &bounds))
printf("SDL_GetDisplayBounds failed (oneshot.cpp)\n"); Debug() << "SDL_GetDisplayBounds failed (oneshot.cpp)";
// Get intersection of window and the screen // Get intersection of window and the screen
SDL_Rect intersect; SDL_Rect intersect;
@ -639,8 +561,7 @@ void Oneshot::updateObscured(int winX, int winY)
if (intersect.x == 0 && intersect.y == 0 && intersect.w == conf.defScreenW && intersect.h == conf.defScreenH) if (intersect.x == 0 && intersect.y == 0 && intersect.w == conf.defScreenW && intersect.h == conf.defScreenH)
return; return;
for (int y = intersect.y; y < intersect.y + intersect.h; ++y) for (int y = intersect.y; y < intersect.y + intersect.h; ++y){
{
int start = y * p->winW + intersect.x; int start = y * p->winW + intersect.x;
std::fill(obscuredFrame.begin() + start, obscuredFrame.begin() + (start + intersect.w), false); std::fill(obscuredFrame.begin() + start, obscuredFrame.begin() + (start + intersect.w), false);
} }
@ -651,10 +572,8 @@ void Oneshot::updateObscured(int winX, int winY)
// to make to the texture // to make to the texture
bool needsUpdate = false; bool needsUpdate = false;
bool cleared = true; bool cleared = true;
for (size_t i = 0; i < obscuredFrame.size(); ++i) for (size_t i = 0; i < obscuredFrame.size(); ++i){
{ if (obscuredFrame[i]){
if (obscuredFrame[i])
{
p->obscuredMap[i] = 0; p->obscuredMap[i] = 0;
needsUpdate = true; needsUpdate = true;
} }
@ -669,8 +588,7 @@ void Oneshot::updateObscured(int winX, int winY)
obscuredDirty = true; obscuredDirty = true;
} }
void Oneshot::resetObscured() void Oneshot::resetObscured(){
{
std::fill(p->obscuredMap.begin(), p->obscuredMap.end(), 255); std::fill(p->obscuredMap.begin(), p->obscuredMap.end(), 255);
obscuredDirty = true; obscuredDirty = true;
p->obscuredCleared = false; p->obscuredCleared = false;