космитические изменения и обновление oneshot.conf

This commit is contained in:
DepressedTWM 2026-05-19 08:27:52 +04:00
parent 8fce0cdc18
commit acbac0b959
28 changed files with 152 additions and 336 deletions

View file

@ -15,6 +15,9 @@
#
# fullscreen=false
# Display current FPS in Window title
# (default: disabled)
# printFPS=false
# Preserve game screen aspect ratio,
# as opposed to stretch-to-fill
@ -24,7 +27,7 @@
# 16:9 support
# EXPEREMENTAL!
#
# (default: disabled)
# EnableSixteenByNine=false
# Apply linear interpolation when game screen

View file

@ -32,7 +32,6 @@ struct Config{
bool debugMode;
bool screenMode;
bool printFPS;
bool fullscreen;
bool fixedAspectRatio;
bool smoothScaling;

View file

@ -33,17 +33,14 @@
/* A cheap replacement for qDebug() */
class Debug
{
class Debug{
public:
Debug()
{
Debug(){
buf << std::boolalpha;
}
template<typename T>
Debug &operator<<(const T &t)
{
Debug &operator<<(const T &t){
buf << t;
buf << " ";
@ -51,16 +48,14 @@ public:
}
template<typename T>
Debug &operator<<(const std::vector<T> &v)
{
Debug &operator<<(const std::vector<T> &v){
for (size_t i = 0; i < v.size(); ++i)
buf << v[i] << " ";
return *this;
}
~Debug()
{
~Debug(){
#ifdef __ANDROID__
__android_log_write(ANDROID_LOG_DEBUG, "mkxp", buf.str().c_str());
#else

View file

@ -34,8 +34,7 @@
#include <sigc++/connection.h>
// #include <sigc++2.0/sigc++/connection.h>
class Disposable
{
class Disposable{
public:
Disposable()
: disposed(false),
@ -44,13 +43,11 @@ public:
shState->graphics().addDisposable(this);
}
virtual ~Disposable()
{
virtual ~Disposable(){
shState->graphics().remDisposable(this);
}
void dispose()
{
void dispose(){
if (disposed)
return;
@ -59,16 +56,14 @@ public:
wasDisposed();
}
bool isDisposed() const
{
bool isDisposed() const{
return disposed;
}
sigc::signal<void> wasDisposed;
protected:
void guardDisposed() const
{
void guardDisposed() const{
if (isDisposed())
throw Exception(Exception::RGSSError,
"disposed %s", klassName());
@ -85,9 +80,7 @@ private:
};
template<class C>
inline bool
nullOrDisposed(const C *d)
{
inline bool nullOrDisposed(const C *d){
if (!d)
return true;

View file

@ -26,8 +26,7 @@
#include <SDL3/SDL_rect.h>
struct Vec2
{
struct Vec2{
float x, y;
Vec2()
@ -38,14 +37,12 @@ struct Vec2
: x(x), y(y)
{}
bool operator==(const Vec2 &other) const
{
bool operator==(const Vec2 &other) const{
return (x == other.x && y == other.y);
}
};
struct Vec4
{
struct Vec4{
float x, y, z, w;
Vec4()
@ -56,19 +53,16 @@ struct Vec4
: x(x), y(y), z(z), w(w)
{}
bool operator==(const Vec4 &other) const
{
bool operator==(const Vec4 &other) const{
return (x == other.x && y == other.y && z == other.z && w == other.w);
}
bool xyzNotNull() const
{
bool xyzNotNull() const{
return (x != 0.0f || y != 0.0f || z != 0.0f);
}
};
struct Vec2i
{
struct Vec2i{
int x, y;
Vec2i()
@ -83,138 +77,114 @@ struct Vec2i
: x(xy), y(xy)
{}
bool operator==(const Vec2i &other) const
{
bool operator==(const Vec2i &other) const{
return x == other.x && y == other.y;
}
bool operator!=(const Vec2i &other) const
{
bool operator!=(const Vec2i &other) const{
return !(*this == other);
}
Vec2i &operator+=(const Vec2i &value)
{
Vec2i &operator+=(const Vec2i &value){
x += value.x;
y += value.y;
return *this;
}
Vec2i &operator-=(const Vec2i &value)
{
Vec2i &operator-=(const Vec2i &value){
x -= value.x;
y -= value.y;
return *this;
}
Vec2i operator+(const Vec2i &value) const
{
Vec2i operator+(const Vec2i &value) const{
return Vec2i(x + value.x, y + value.y);
}
Vec2i operator-(const Vec2i &value) const
{
Vec2i operator-(const Vec2i &value) const{
return Vec2i(x - value.x, y - value.y);
}
template<typename T>
Vec2i operator*(T value) const
{
Vec2i operator*(T value) const{
return Vec2i(x * value, y * value);
}
template<typename T>
Vec2i operator/(T value) const
{
Vec2i operator/(T value) const{
return Vec2i(x / value, y / value);
}
Vec2i operator%(int value) const
{
Vec2i operator%(int value) const{
return Vec2i(x % value, y % value);
}
Vec2i operator&(unsigned value) const
{
Vec2i operator&(unsigned value) const{
return Vec2i(x & value, y & value);
}
Vec2i operator-() const
{
Vec2i operator-() const{
return Vec2i(-x, -y);
}
Vec2i operator!() const
{
Vec2i operator!() const{
return Vec2i(!x, !y);
}
operator Vec2() const
{
operator Vec2() const{
return Vec2(x, y);
}
};
struct IntRect : SDL_Rect
{
IntRect()
{
struct IntRect : SDL_Rect{
IntRect(){
x = y = w = h = 0;
}
IntRect(int x, int y, int w, int h)
{
IntRect(int x, int y, int w, int h){
this->x = x;
this->y = y;
this->w = w;
this->h = h;
}
IntRect(const Vec2i &pos, const Vec2i &size)
{
IntRect(const Vec2i &pos, const Vec2i &size){
x = pos.x;
y = pos.y;
w = size.x;
h = size.y;
}
bool operator==(const IntRect &other) const
{
bool operator==(const IntRect &other) const{
return (x == other.x && y == other.y &&
w == other.w && h == other.h);
}
bool operator!=(const IntRect &other) const
{
bool operator!=(const IntRect &other) const{
return !(*this == other);
}
Vec2i pos() const
{
Vec2i pos() const{
return Vec2i(x, y);
}
Vec2i size() const
{
Vec2i size() const{
return Vec2i(w, h);
}
void setPos(const Vec2i &value)
{
void setPos(const Vec2i &value){
x = value.x;
y = value.y;
}
void setSize(const Vec2i &value)
{
void setSize(const Vec2i &value){
w = value.x;
h = value.y;
}
bool encloses(const IntRect &o) const
{
bool encloses(const IntRect &o) const{
return (x <= o.x &&
y <= o.y &&
x+w >= o.x+o.w &&
@ -224,8 +194,7 @@ struct IntRect : SDL_Rect
struct StaticRect { float x, y, w, h; };
struct FloatRect
{
struct FloatRect{
float x, y, w, h;
FloatRect()
@ -244,8 +213,7 @@ struct FloatRect
: x(r.x), y(r.y), w(r.w), h(r.h)
{}
operator IntRect() const
{
operator IntRect() const{
return IntRect(x, y, w, h);
}
@ -254,16 +222,14 @@ struct FloatRect
Vec2 topRight() const { return Vec2(x+w, y); }
Vec2 bottomRight() const { return Vec2(x+w, y+h); }
FloatRect hFlipped() const
{
FloatRect hFlipped() const{
return FloatRect(x+w, y, -w, h);
}
};
/* Value between 0 and 255 with internal
* normalized representation */
struct NormValue
{
struct NormValue{
int unNorm;
float norm;
@ -277,19 +243,16 @@ struct NormValue
norm(unNorm / 255.0f)
{}
void operator =(int value)
{
void operator =(int value){
unNorm = clamp(value, 0, 255);
norm = unNorm / 255.0f;
}
bool operator ==(int value) const
{
bool operator ==(int value) const{
return unNorm == clamp(value, 0, 255);
}
operator int() const
{
operator int() const{
return unNorm;
}
};

View file

@ -29,8 +29,7 @@
struct SDL_Color;
enum BlendType
{
enum BlendType{
BlendKeepDestAlpha = -1,
BlendNormal = 0,
@ -38,8 +37,7 @@ enum BlendType
BlendSubstraction = 2
};
struct Color : public Serializable
{
struct Color : public Serializable{
Color()
: red(0), green(0), blue(0), alpha(0)
{}
@ -74,8 +72,7 @@ struct Color : public Serializable
void updateInternal();
void updateExternal();
bool hasEffect() const
{
bool hasEffect() const{
return (alpha != 0);
}
@ -91,8 +88,7 @@ struct Color : public Serializable
Vec4 norm;
};
struct Tone : public Serializable
{
struct Tone : public Serializable{
Tone()
: red(0), green(0), blue(0), gray(0)
{}
@ -125,8 +121,7 @@ struct Tone : public Serializable
/* Internal */
void updateInternal();
bool hasEffect() const
{
bool hasEffect() const{
return ((int)red != 0 ||
(int)green != 0 ||
(int)blue != 0 ||
@ -146,8 +141,7 @@ struct Tone : public Serializable
sigc::signal<void> valueChanged;
};
struct Rect : public Serializable
{
struct Rect : public Serializable{
Rect()
: x(0), y(0), width(0), height(0)
{}
@ -182,13 +176,11 @@ struct Rect : public Serializable
static Rect *deserialize(const char *data, int len);
/* Internal */
FloatRect toFloatRect() const
{
FloatRect toFloatRect() const{
return FloatRect(x, y, width, height);
}
IntRect toIntRect()
{
IntRect toIntRect(){
return IntRect(x, y, width, height);
}
@ -215,8 +207,7 @@ struct Rect : public Serializable
* without memory leakage.
* This can be removed at a later point when no testing directly
* from C++ is needed anymore. */
struct EtcTemps
{
struct EtcTemps{
Color color;
Tone tone;
Rect rect;

View file

@ -472,14 +472,10 @@ void EventThread::process(RGSSThreadData &rtData){
break;
case UPDATE_FPS :
if (rtData.config.printFPS)
Debug() << "FPS:" << event.user.code;
if (!fps.sendUpdates)
break;
snprintf(buffer, sizeof(buffer), "%s - %d FPS",
rtData.config.windowTitle.c_str(), event.user.code);
snprintf(buffer, sizeof(buffer), "%s - %d FPS", rtData.config.windowTitle.c_str(), event.user.code);
/* Updating the window title in fullscreen
* mode seems to cause flickering */

View file

@ -46,37 +46,31 @@ union SDL_Event;
#define MAX_FINGERS 4
class EventThread
{
class EventThread{
public:
struct ControllerState
{
struct ControllerState{
int axes[SDL_GAMEPAD_AXIS_COUNT];
bool buttons[SDL_GAMEPAD_BUTTON_COUNT];
};
struct JoyState
{
struct JoyState{
int axes[256];
uint8_t hats[256];
bool buttons[256];
};
struct MouseState
{
struct MouseState{
int x, y;
bool inWindow;
bool buttons[32];
};
struct FingerState
{
struct FingerState{
bool down;
int x, y;
};
struct TouchState
{
struct TouchState{
FingerState fingers[MAX_FINGERS];
};
@ -123,8 +117,7 @@ private:
bool showCursor;
AtomicFlag msgBoxDone;
struct
{
struct{
uint64_t lastFrame;
uint64_t displayCounter;
AtomicFlag sendUpdates;
@ -138,21 +131,18 @@ private:
/* Used to asynchronously inform the RGSS thread
* about certain value changes */
template<typename T>
struct UnidirMessage
{
struct UnidirMessage{
UnidirMessage()
: mutex(SDL_CreateMutex()),
current(T())
{}
~UnidirMessage()
{
~UnidirMessage(){
SDL_DestroyMutex(mutex);
}
/* Done from the sending side */
void post(const T &value)
{
void post(const T &value){
SDL_LockMutex(mutex);
changed.set();
@ -162,8 +152,7 @@ struct UnidirMessage
}
/* Done from the receiving side */
bool poll(T &out) const
{
bool poll(T &out) const{
if (!changed)
return false;
@ -178,8 +167,7 @@ struct UnidirMessage
}
/* Done from either */
void get(T &out) const
{
void get(T &out) const{
SDL_LockMutex(mutex);
out = current;
SDL_UnlockMutex(mutex);
@ -191,8 +179,7 @@ private:
T current;
};
struct SyncPoint
{
struct SyncPoint{
/* Used by eventFilter to control sleep/wakeup */
void haltThreads();
void resumeThreads();
@ -205,8 +192,7 @@ struct SyncPoint
void passSecondarySync();
private:
struct Util
{
struct Util{
Util();
~Util();
@ -224,8 +210,7 @@ private:
Util secondSync;
};
struct RGSSThreadData
{
struct RGSSThreadData{
/* Main thread sets this to request RGSS thread to terminate */
AtomicFlag rqTerm;
/* In response, RGSS thread sets this to confirm

View file

@ -26,10 +26,8 @@
#include <stdio.h>
#include <stdarg.h>
struct Exception
{
enum Type
{
struct Exception{
enum Type{
RGSSError,
NoFileError,
IOError,

View file

@ -25,8 +25,7 @@
#include "etc.h"
#include "etc-internal.h"
class Flashable
{
class Flashable{
public:
Flashable()
: flashColor(0, 0, 0, 0),
@ -36,8 +35,7 @@ public:
virtual ~Flashable() {}
void flash(const Vec4 *color, int duration)
{
void flash(const Vec4 *color, int duration){
if (duration < 1)
return;
@ -45,8 +43,7 @@ public:
this->duration = duration;
counter = 0;
if (!color)
{
if (!color){
emptyFlashFlag = true;
return;
}
@ -55,13 +52,11 @@ public:
flashAlpha = flashColor.w;
}
virtual void update()
{
virtual void update(){
if (!flashing)
return;
if (++counter > duration)
{
if (++counter > duration){
/* Flash finished. Cleanup */
flashColor = Vec4(0, 0, 0, 0);
flashing = false;

View file

@ -48,16 +48,8 @@ struct GLDebugLoggerPrivate{
}
};
static void APIENTRY arbDebugFunc(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
const GLchar* message,
const void* userParam)
{
GLDebugLoggerPrivate *p =
static_cast<GLDebugLoggerPrivate*>(const_cast<void*>(userParam));
static void APIENTRY arbDebugFunc(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) {
GLDebugLoggerPrivate *p = static_cast<GLDebugLoggerPrivate*>(const_cast<void*>(userParam));
(void) source;
(void) type;

View file

@ -33,23 +33,19 @@ typedef uint16_t index_t;
#define INDEX_T_MAX std::numeric_limits<index_t>::max()
#define _GL_INDEX_TYPE GL_UNSIGNED_SHORT
struct GlobalIBO
{
struct GlobalIBO{
IBO::ID ibo;
std::vector<index_t> buffer;
GlobalIBO()
{
GlobalIBO(){
ibo = IBO::gen();
}
~GlobalIBO()
{
~GlobalIBO(){
IBO::del(ibo);
}
void ensureSize(size_t quadCount)
{
void ensureSize(size_t quadCount){
assert(quadCount*6 < INDEX_T_MAX);
if (buffer.size() >= quadCount*6)
@ -58,8 +54,7 @@ struct GlobalIBO
size_t startInd = buffer.size() / 6;
buffer.reserve(quadCount*6);
for (size_t i = startInd; i < quadCount; ++i)
{
for (size_t i = startInd; i < quadCount; ++i){
static const index_t indTemp[] = { 0, 1, 2, 2, 3, 0 };
for (size_t j = 0; j < 6; ++j)

View file

@ -256,8 +256,7 @@ static const int mapToIndex[] = {
static elementsN(mapToIndex);
static const Input::ButtonCode dirs[] =
{ Input::Down, Input::Left, Input::Right, Input::Up };
static const Input::ButtonCode dirs[] = { Input::Down, Input::Left, Input::Right, Input::Up };
static const int dirFlags[] = {
1 << Input::Down,

View file

@ -17,8 +17,7 @@ public:
Read,
} Mode;
Pipe()
{
Pipe(){
#ifdef _WIN32
handle = NULL;
#else
@ -46,8 +45,7 @@ public:
filename = std::string(P_tmpdir) + "/" + name;
#endif
if (mode == Read)
{
if (mode == Read){
#ifdef _WIN32
handle = CreateFileA(
filename.c_str(),
@ -98,8 +96,7 @@ public:
#ifdef _WIN32
OVERLAPPED overlapped;
memset(&overlapped, 0, sizeof(overlapped));
if (!ReadFile(handle, buf, 1, NULL, &overlapped))
{
if (!ReadFile(handle, buf, 1, NULL, &overlapped)){
if (GetLastError() == ERROR_IO_PENDING)
CancelIo(handle);
return false;
@ -118,8 +115,7 @@ public:
#endif
}
bool isOpen()
{
bool isOpen(){
#ifdef _WIN32
return handle != NULL;
#else

View file

@ -82,8 +82,7 @@ static bool readUint32(PHYSFS_Io *io, uint32_t &result){
#define IO_READ(io, dest, size) (io->read(io, dest, size) == size)
static inline uint32_t
advanceMagic(uint32_t &magic) {
static inline uint32_t advanceMagic(uint32_t &magic) {
uint32_t old = magic;
magic = magic * 7 + 3;
@ -91,8 +90,7 @@ advanceMagic(uint32_t &magic) {
return old;
}
static PHYSFS_sint64
RGSS_ioRead(PHYSFS_Io *self, void *buffer, PHYSFS_uint64 len) {
static PHYSFS_sint64 RGSS_ioRead(PHYSFS_Io *self, void *buffer, PHYSFS_uint64 len) {
RGSS_entryHandle *entry = static_cast<RGSS_entryHandle*>(self->opaque);
PHYSFS_Io *io = entry->io;
@ -183,8 +181,7 @@ RGSS_ioRead(PHYSFS_Io *self, void *buffer, PHYSFS_uint64 len) {
return toRead;
}
static int
RGSS_ioSeek(PHYSFS_Io *self, PHYSFS_uint64 offset){
static int RGSS_ioSeek(PHYSFS_Io *self, PHYSFS_uint64 offset){
RGSS_entryHandle *entry = static_cast<RGSS_entryHandle*>(self->opaque);
if (offset == entry->currentOffset)
@ -213,23 +210,19 @@ RGSS_ioSeek(PHYSFS_Io *self, PHYSFS_uint64 offset){
return 1;
}
static PHYSFS_sint64
RGSS_ioTell(PHYSFS_Io *self){
static PHYSFS_sint64 RGSS_ioTell(PHYSFS_Io *self){
const RGSS_entryHandle *entry = static_cast<RGSS_entryHandle*>(self->opaque);
return entry->currentOffset;
}
static PHYSFS_sint64
RGSS_ioLength(PHYSFS_Io *self)
{
static PHYSFS_sint64 RGSS_ioLength(PHYSFS_Io *self){
const RGSS_entryHandle *entry = static_cast<RGSS_entryHandle*>(self->opaque);
return entry->data.size;
}
static PHYSFS_Io*
RGSS_ioDuplicate(PHYSFS_Io *self){
static PHYSFS_Io* RGSS_ioDuplicate(PHYSFS_Io *self){
const RGSS_entryHandle *entry = static_cast<RGSS_entryHandle*>(self->opaque);
RGSS_entryHandle *entryDup = new RGSS_entryHandle(*entry);
@ -240,8 +233,7 @@ RGSS_ioDuplicate(PHYSFS_Io *self){
return dup;
}
static void
RGSS_ioDestroy(PHYSFS_Io *self){
static void RGSS_ioDestroy(PHYSFS_Io *self){
RGSS_entryHandle *entry = static_cast<RGSS_entryHandle*>(self->opaque);
delete entry;
@ -262,13 +254,9 @@ static const PHYSFS_Io RGSS_IoTemplate ={
RGSS_ioDestroy
};
static void
processDirectories(RGSS_archiveData *data, BoostSet<std::string> &topLevel,
char *nameBuf, uint32_t nameLen)
{
static void processDirectories(RGSS_archiveData *data, BoostSet<std::string> &topLevel, char *nameBuf, uint32_t nameLen){
/* Check for top level entries */
for (uint32_t i = 0; i < nameLen; ++i)
{
for (uint32_t i = 0; i < nameLen; ++i){
bool slash = nameBuf[i] == '/';
if (!slash && i+1 < nameLen)
continue;
@ -297,8 +285,7 @@ processDirectories(RGSS_archiveData *data, BoostSet<std::string> &topLevel,
}
}
static bool
verifyHeader(PHYSFS_Io *io, char version){
static bool verifyHeader(PHYSFS_Io *io, char version){
char header[8];
if (!IO_READ(io, header, sizeof(header)))
@ -313,8 +300,7 @@ verifyHeader(PHYSFS_Io *io, char version){
return true;
}
static void*
RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite, int *claimed){
static void* RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite, int *claimed){
if (forWrite)
return NULL;
@ -371,11 +357,7 @@ RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite, int *claimed){
return data;
}
static PHYSFS_EnumerateCallbackResult
RGSS_enumerateFiles(void *opaque, const char *dirname,
PHYSFS_EnumerateCallback cb,
const char *origdir, void *callbackdata)
{
static PHYSFS_EnumerateCallbackResult RGSS_enumerateFiles(void *opaque, const char *dirname, PHYSFS_EnumerateCallback cb, const char *origdir, void *callbackdata) {
RGSS_archiveData *data = static_cast<RGSS_archiveData*>(opaque);
std::string _dirname(dirname);
@ -392,8 +374,7 @@ RGSS_enumerateFiles(void *opaque, const char *dirname,
return PHYSFS_ENUM_OK;
}
static PHYSFS_Io*
RGSS_openRead(void *opaque, const char *filename){
static PHYSFS_Io* RGSS_openRead(void *opaque, const char *filename){
RGSS_archiveData *data = static_cast<RGSS_archiveData*>(opaque);
if (!data->entryHash.contains(filename))
@ -410,8 +391,7 @@ RGSS_openRead(void *opaque, const char *filename){
return io;
}
static int
RGSS_stat(void *opaque, const char *filename, PHYSFS_Stat *stat){
static int RGSS_stat(void *opaque, const char *filename, PHYSFS_Stat *stat){
RGSS_archiveData *data = static_cast<RGSS_archiveData*>(opaque);
bool hasFile = data->entryHash.contains(filename);
@ -440,20 +420,17 @@ RGSS_stat(void *opaque, const char *filename, PHYSFS_Stat *stat){
return 1;
}
static void
RGSS_closeArchive(void *opaque){
static void RGSS_closeArchive(void *opaque){
RGSS_archiveData *data = static_cast<RGSS_archiveData*>(opaque);
delete data;
}
static PHYSFS_Io*
RGSS_noop1(void*, const char*){
static PHYSFS_Io* RGSS_noop1(void*, const char*){
return 0;
}
static int
RGSS_noop2(void*, const char*){
static int RGSS_noop2(void*, const char*){
return 0;
}
@ -497,8 +474,7 @@ const PHYSFS_Archiver RGSS2_Archiver = {
RGSS_closeArchive
};
static bool
readUint32AndXor(PHYSFS_Io *io, uint32_t &result, uint32_t key){
static bool readUint32AndXor(PHYSFS_Io *io, uint32_t &result, uint32_t key){
if (!readUint32(io, result))
return false;
@ -507,8 +483,7 @@ readUint32AndXor(PHYSFS_Io *io, uint32_t &result, uint32_t key){
return true;
}
static void*
RGSS3_openArchive(PHYSFS_Io *io, const char *, int forWrite, int *claimed){
static void* RGSS3_openArchive(PHYSFS_Io *io, const char *, int forWrite, int *claimed){
if (forWrite)
return NULL;

View file

@ -14,7 +14,7 @@
static void showInitError(const std::string &msg){
Debug() << msg;
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OneShot: sunshine", msg.c_str(), 0);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Sunshine Error", msg.c_str(), 0);
}
static bool readMessage(Pipe &ipc, char *buf, size_t size){

View file

@ -108,10 +108,6 @@ struct SDLSoundSource : ALDataSource{
}
};
ALDataSource *createSDLSource(SDL_IOStream &ops,
const char *extension,
uint32_t maxBufSize,
bool looped)
{
ALDataSource *createSDLSource(SDL_IOStream &ops, const char *extension, uint32_t maxBufSize, bool looped) {
return new SDLSoundSource(ops, extension, maxBufSize, looped);
}

View file

@ -31,8 +31,7 @@
#error "Non little endian systems not supported"
#endif
static inline int32_t
readInt32(const char **dataP){
static inline int32_t readInt32(const char **dataP){
int32_t result;
memcpy(&result, *dataP, 4);
@ -41,8 +40,7 @@ readInt32(const char **dataP){
return result;
}
static inline double
readDouble(const char **dataP){
static inline double readDouble(const char **dataP){
double result;
memcpy(&result, *dataP, 8);
@ -51,14 +49,12 @@ readDouble(const char **dataP){
return result;
}
static inline void
writeInt32(char **dataP, int32_t value){
static inline void writeInt32(char **dataP, int32_t value){
memcpy(*dataP, &value, 4);
*dataP += 4;
}
static inline void
writeDouble(char **dataP, double value){
static inline void writeDouble(char **dataP, double value){
memcpy(*dataP, &value, 8);
*dataP += 8;
}

View file

@ -388,9 +388,7 @@ struct SettingsMenuPrivate{
SDL_FillSurfaceRect(surf, 0, SDL_MapSurfaceRGBA(surf, grey, grey, grey, 255));
}
void fillRect(SDL_Surface *surf,
int x, int y, int w, int h,
uint8_t r, uint8_t g, uint8_t b){
void fillRect(SDL_Surface *surf, int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b){
SDL_Rect rect = { drawOff.x+x, drawOff.y+y, w, h };
SDL_FillSurfaceRect(surf, &rect, SDL_MapSurfaceRGB(surf, r, g, b));
}
@ -415,9 +413,7 @@ struct SettingsMenuPrivate{
fillRect(surf, r, g, b, x-width/2, y, width, length);
}
void strokeRect(SDL_Surface *surf, uint8_t grey,
int x, int y, int w, int h,
int lineW){
void strokeRect(SDL_Surface *surf, uint8_t grey, int x, int y, int w, int h, int lineW){
strokeLineH(surf, grey, x, y, w, lineW);
strokeLineH(surf, grey, x, y+h, w, lineW);
@ -425,18 +421,14 @@ struct SettingsMenuPrivate{
strokeLineV(surf, grey, x+w, y, h, lineW);
}
void strokeRectInner(SDL_Surface *surf,
int x, int y, int w, int h, int lineW,
uint8_t r, uint8_t g, uint8_t b){
void strokeRectInner(SDL_Surface *surf, int x, int y, int w, int h, int lineW, uint8_t r, uint8_t g, uint8_t b){
fillRect(surf, x, y, w, lineW, r, g, b);
fillRect(surf, x, y+h-lineW, w, lineW, r, g, b);
fillRect(surf, x, y, lineW, h, r, g, b);
fillRect(surf, x+w-lineW, y, lineW, h, r, g ,b);
}
void strokeRectInner(SDL_Surface *surf, uint8_t grey,
int x, int y, int w, int h,
int lineW){
void strokeRectInner(SDL_Surface *surf, uint8_t grey, int x, int y, int w, int h, int lineW){
strokeRectInner(surf, x, y, w, h, lineW, grey, grey, grey);
}
@ -460,10 +452,7 @@ struct SettingsMenuPrivate{
}
/* Horizontally centered */
void blitTextSurf(SDL_Surface *surf, int x, int y,
int alignW, SDL_Surface *txtSurf,
Justification just)
{
void blitTextSurf(SDL_Surface *surf, int x, int y, int alignW, SDL_Surface *txtSurf, Justification just){
SDL_Rect dstRect;
dstRect.x = drawOff.x;
dstRect.y = drawOff.y + y - txtSurf->h / 2;
@ -581,9 +570,7 @@ struct SettingsMenuPrivate{
if (state == AwaitingInput){
char buf[64];
snprintf(buf, sizeof(buf), findtext(TRSTR_KEYBIND_KEYPROMPT,
"Press key or joystick button for \"%s\""),
captureName);
snprintf(buf, sizeof(buf), findtext(TRSTR_KEYBIND_KEYPROMPT, "Press key or joystick button for \"%s\""), captureName);
drawOff = Vec2i();
@ -622,8 +609,7 @@ struct SettingsMenuPrivate{
Widget *w = 0;
for (size_t i = 0; i < widgets.size(); ++i)
if (widgets[i]->hit(x, y))
{
if (widgets[i]->hit(x, y)){
w = widgets[i];
break;
}
@ -653,8 +639,7 @@ struct SettingsMenuPrivate{
Widget *w = findWidget(e.x, e.y);
if (w != hovered)
{
if (w != hovered){
if (hovered)
hovered->leave();
hovered = w;
@ -1002,8 +987,7 @@ SettingsMenu::SettingsMenu(RGSSThreadData &rtData){
const int bWidgetY = winSize.y - layoutH*bWidgetH - 48;
for (int y = 0; y < (int)(layoutH); ++y)
for (int x = 0; x < (int)(layoutW); ++x)
{
for (int x = 0; x < (int)(layoutW); ++x){
int i = x*layoutH+y;
BindingWidget w(i, p, IntRect(x*bWidgetW, bWidgetY+y*bWidgetH,
bWidgetW, bWidgetH));

View file

@ -137,11 +137,7 @@ static void setupShaderSource(GLuint shader, GLenum type,
gl.ShaderSource(shader, i, shaderSrc, shaderSrcSize);
}
void Shader::init(const unsigned char *vert, int vertSize,
const unsigned char *frag, int fragSize,
const char *vertName, const char *fragName,
const char *programName)
{
void Shader::init(const unsigned char *vert, int vertSize, const unsigned char *frag, int fragSize, const char *vertName, const char *fragName, const char *programName) {
GLint success;
/* Compile vertex shader */
@ -152,9 +148,7 @@ void Shader::init(const unsigned char *vert, int vertSize,
if (!success){
printShaderLog(vertShader);
throw Exception(Exception::MKXPError,
"GLSL: An error occured while compiling vertex shader '%s' in program '%s'",
vertName, programName);
throw Exception(Exception::MKXPError, "GLSL: An error occured while compiling vertex shader '%s' in program '%s'", vertName, programName);
}
/* Compile fragment shader */
@ -165,9 +159,7 @@ void Shader::init(const unsigned char *vert, int vertSize,
if (!success){
printShaderLog(fragShader);
throw Exception(Exception::MKXPError,
"GLSL: An error occured while compiling fragment shader '%s' in program '%s'",
fragName, programName);
throw Exception(Exception::MKXPError, "GLSL: An error occured while compiling fragment shader '%s' in program '%s'", fragName, programName);
}
/* Link shader program */
@ -184,9 +176,7 @@ void Shader::init(const unsigned char *vert, int vertSize,
if (!success){
printProgramLog(program);
throw Exception(Exception::MKXPError,
"GLSL: An error occured while linking program '%s' (vertex '%s', fragment '%s')",
programName, vertName, fragName);
throw Exception(Exception::MKXPError, "GLSL: An error occured while linking program '%s' (vertex '%s', fragment '%s')", programName, vertName, fragName);
}
}
@ -219,8 +209,7 @@ void ShaderBase::GLProjMat::apply(const Vec2i &value) {
const float b = 2.f / value.y;
const float c = -2.f;
GLfloat mat[16] =
{
GLfloat mat[16] = {
a, 0, 0, 0,
0, b, 0, 0,
0, 0, c, 0,

View file

@ -67,8 +67,7 @@ struct SoundBuffer{
}
private:
~SoundBuffer()
{
~SoundBuffer(){
AL::Buffer::del(alBuffer);
}
};
@ -112,10 +111,7 @@ SoundEmitter::~SoundEmitter(){
SoundBuffer::deref(iter->second);
}
void SoundEmitter::play(const std::string &filename,
int volume,
int pitch)
{
void SoundEmitter::play(const std::string &filename, int volume, int pitch) {
float _volume = clamp<int>(volume, 0, 100) / 100.0f;
float _pitch = clamp<int>(pitch, 50, 150) / 100.0f;

View file

@ -126,9 +126,7 @@ struct SpritePrivate{
return;
/* Calculate effective (normalized) bush depth */
float texBushDepth = (bushDepth / trans.getScale().y) -
(srcRect->y + srcRect->height) +
bitmap->height();
float texBushDepth = (bushDepth / trans.getScale().y) - (srcRect->y + srcRect->height) + bitmap->height();
efBushDepth = 1.0f - texBushDepth / bitmap->height();
}
@ -157,8 +155,7 @@ struct SpritePrivate{
/* Cut old connection */
srcRectCon.disconnect();
/* Create new one */
srcRectCon = srcRect->valueChanged.connect
(sigc::mem_fun(this, &SpritePrivate::onSrcRectChange));
srcRectCon = srcRect->valueChanged.connect(sigc::mem_fun(this, &SpritePrivate::onSrcRectChange));
}
void updateVisibility(){
@ -355,8 +352,7 @@ void Sprite::setY(int value){
p->trans.setPosition(Vec2(getX(), value));
if (rgssVer >= 2)
{
if (rgssVer >= 2){
p->wave.dirty = true;
setSpriteY(value);
}

View file

@ -46,8 +46,7 @@ int16_t Table::get(int x, int y, int z) const{
void Table::set(int16_t value, int x, int y, int z){
if (x < 0 || x >= xs
|| y < 0 || y >= ys
|| z < 0 || z >= zs)
{
|| z < 0 || z >= zs){
return;
}

View file

@ -82,10 +82,7 @@ TexPool::TexPool(uint32_t maxMemSize){
TexPool::~TexPool(){
std::list<TEXFBO>::iterator iter;
for (iter = p->priorityQueue.begin();
iter != p->priorityQueue.end();
++iter)
{
for (iter = p->priorityQueue.begin(); iter != p->priorityQueue.end(); ++iter) {
TEXFBO obj = *iter;
TEXFBO::fini(obj);
--p->objCount;
@ -120,9 +117,7 @@ TEXFBO TexPool::request(int width, int height){
int maxSize = glState.caps.maxTexSize;
if (width > maxSize || height > maxSize)
throw Exception(Exception::MKXPError,
"Texture dimensions [%d, %d] exceed hardware capabilities",
width, height);
throw Exception(Exception::MKXPError, "Texture dimensions [%d, %d] exceed hardware capabilities", width, height);
/* Nope, create it instead */
TEXFBO::init(cnode.obj);

View file

@ -45,14 +45,11 @@ static inline int wrap(int value, int range){
}
static inline Vec2i wrap(const Vec2i &value, int range){
return Vec2i(wrap(value.x, range),
wrap(value.y, range));
return Vec2i(wrap(value.x, range), wrap(value.y, range));
}
static inline int16_t tableGetWrapped(const Table &t, int x, int y, int z = 0){
return t.get(wrap(x, t.xSize()),
wrap(y, t.ySize()),
z);
return t.get(wrap(x, t.xSize()), wrap(y, t.ySize()), z);
}
/* Calculate the tile x/y on which this pixel x/y lies */

View file

@ -400,8 +400,7 @@ struct TilemapPrivate {
atlas.size = TileAtlas::minSize(atlas.efTilesetH, glState.caps.maxTexSize);
if (atlas.size.x < 0)
throw Exception(Exception::MKXPError,
"Cannot allocate big enough texture for tileset atlas");
throw Exception(Exception::MKXPError, "Cannot allocate big enough texture for tileset atlas");
}
void updateAutotileInfo(){
@ -792,8 +791,7 @@ struct TilemapPrivate {
ZLayer *prev = elem.zlayers[0];
prev->finiUpdateZ(0);
for (size_t i = 1; i < elem.activeLayers; ++i)
{
for (size_t i = 1; i < elem.activeLayers; ++i){
ZLayer *layer = elem.zlayers[i];
layer->finiUpdateZ(prev);
prev = layer;
@ -1006,12 +1004,10 @@ void Tilemap::Autotiles::set(int i, Bitmap *bitmap){
p->invalidateAtlasContents();
p->autotilesCon[i].disconnect();
p->autotilesCon[i] = bitmap->modified.connect
(sigc::mem_fun(p, &TilemapPrivate::invalidateAtlasContents));
p->autotilesCon[i] = bitmap->modified.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateAtlasContents));
p->autotilesDispCon[i].disconnect();
p->autotilesDispCon[i] = bitmap->wasDisposed.connect
(sigc::mem_fun(p, &TilemapPrivate::invalidateAtlasContents));
p->autotilesDispCon[i] = bitmap->wasDisposed.connect(sigc::mem_fun(p, &TilemapPrivate::invalidateAtlasContents));
p->updateAutotileInfo();
}

View file

@ -49,8 +49,7 @@ static inline T clamp(T value, T min, T max){
return value;
}
static inline int
findNextPow2(int start){
static inline int findNextPow2(int start){
int i = 1;
while (i < start)
i <<= 1;

View file

@ -80,8 +80,7 @@ struct VorbisSource : ALDataSource{
if (error){
SDL_CloseIO(&src);
throw Exception(Exception::MKXPError,
"Vorbisfile: Cannot read ogg file");
throw Exception(Exception::MKXPError, "Vorbisfile: Cannot read ogg file");
}
/* Extract bitstream info */
@ -91,8 +90,7 @@ struct VorbisSource : ALDataSource{
if (info.channels > 2){
ov_clear(&vf);
SDL_CloseIO(&src);
throw Exception(Exception::MKXPError,
"Cannot handle audio with more than 2 channels");
throw Exception(Exception::MKXPError, "Cannot handle audio with more than 2 channels");
}
info.alFormat = chooseALFormat(sizeof(int16_t), info.channels);