separate stream sdl rwops into their own header
this allows us to avoid globally including SDL.hmaster
parent
9bc4942489
commit
085e61148f
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "command.hh"
|
#include "command.hh"
|
||||||
|
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
#include <sauerlib/encoding.hh>
|
#include <sauerlib/encoding.hh>
|
||||||
|
|
||||||
#include <shared/igame.hh>
|
#include <shared/igame.hh>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <shared/command.hh>
|
#include <shared/command.hh>
|
||||||
#include <shared/igame.hh>
|
#include <shared/igame.hh>
|
||||||
|
#include <shared/rwops.hh>
|
||||||
|
|
||||||
#include "command.hh" // identflags
|
#include "command.hh" // identflags
|
||||||
#include "console.hh" /* conoutf */
|
#include "console.hh" /* conoutf */
|
||||||
|
@ -1479,7 +1480,7 @@ static SDL_Surface *loadsurface(const char *name)
|
||||||
stream *z = openzipfile(name, "rb");
|
stream *z = openzipfile(name, "rb");
|
||||||
if(z)
|
if(z)
|
||||||
{
|
{
|
||||||
SDL_RWops *rw = z->rwops();
|
SDL_RWops *rw = stream_rwops(z);
|
||||||
if(rw)
|
if(rw)
|
||||||
{
|
{
|
||||||
const char *ext = strrchr(name, '.');
|
const char *ext = strrchr(name, '.');
|
||||||
|
@ -3869,12 +3870,12 @@ static void saveimage(const char *filename, int format, ImageData &image, bool f
|
||||||
switch(format) {
|
switch(format) {
|
||||||
case IMG_JPG:
|
case IMG_JPG:
|
||||||
#if SDL_IMAGE_VERSION_ATLEAST(2, 0, 2)
|
#if SDL_IMAGE_VERSION_ATLEAST(2, 0, 2)
|
||||||
IMG_SaveJPG_RW(s, f->rwops(), 1, screenshotquality);
|
IMG_SaveJPG_RW(s, stream_rwops(f), 1, screenshotquality);
|
||||||
#else
|
#else
|
||||||
conoutf(CON_ERROR, "JPG screenshot support requires SDL_image 2.0.2");
|
conoutf(CON_ERROR, "JPG screenshot support requires SDL_image 2.0.2");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default: SDL_SaveBMP_RW(s, f->rwops(), 1); break;
|
default: SDL_SaveBMP_RW(s, stream_rwops(f), 1); break;
|
||||||
}
|
}
|
||||||
delete f;
|
delete f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <SDL.h>
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
typedef unsigned char uchar;
|
typedef unsigned char uchar;
|
||||||
|
@ -1211,10 +1210,6 @@ struct stream
|
||||||
template<class T> T get() { T n; return read(&n, sizeof(n)) == sizeof(n) ? n : 0; }
|
template<class T> T get() { T n; return read(&n, sizeof(n)) == sizeof(n) ? n : 0; }
|
||||||
template<class T> T getlil() { return lilswap(get<T>()); }
|
template<class T> T getlil() { return lilswap(get<T>()); }
|
||||||
template<class T> T getbig() { return bigswap(get<T>()); }
|
template<class T> T getbig() { return bigswap(get<T>()); }
|
||||||
|
|
||||||
#ifndef STANDALONE
|
|
||||||
SDL_RWops *rwops();
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef SHARED_RWOPS_HH
|
||||||
|
#define SHARED_RWOPS_HH
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "tools.hh"
|
||||||
|
|
||||||
|
SDL_RWops *stream_rwops(stream *s);
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,5 +1,7 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <sauerlib/encoding.hh>
|
#include <sauerlib/encoding.hh>
|
||||||
|
|
||||||
#include "command.hh"
|
#include "command.hh"
|
||||||
|
@ -566,11 +568,11 @@ static int rwopsclose(SDL_RWops *rw)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_RWops *stream::rwops()
|
SDL_RWops *stream_rwops(stream *s)
|
||||||
{
|
{
|
||||||
SDL_RWops *rw = SDL_AllocRW();
|
SDL_RWops *rw = SDL_AllocRW();
|
||||||
if(!rw) return nullptr;
|
if(!rw) return nullptr;
|
||||||
rw->hidden.unknown.data1 = this;
|
rw->hidden.unknown.data1 = s;
|
||||||
rw->seek = rwopsseek;
|
rw->seek = rwopsseek;
|
||||||
rw->read = rwopsread;
|
rw->read = rwopsread;
|
||||||
rw->write = rwopswrite;
|
rw->write = rwopswrite;
|
||||||
|
|
Loading…
Reference in New Issue