Rename RWops static constructors

This commit is contained in:
Alexander van Gessel 2017-09-21 11:16:28 +02:00
parent 61e8904995
commit a9c5924eb7
5 changed files with 12 additions and 12 deletions

View file

@ -39,8 +39,8 @@ using scoped_ostream = std::unique_ptr<std::ostream>;
typedef std::unique_ptr<SDL_RWops, void(*)(SDL_RWops*)> rwops_ptr;
rwops_ptr read_RWops(const std::string &path);
rwops_ptr write_RWops(const std::string &path);
rwops_ptr make_read_RWops(const std::string &path);
rwops_ptr make_write_RWops(const std::string &path);
/** An exception object used when an IO error occurs */
struct io_exception : public game::error {

View file

@ -39,7 +39,7 @@ static size_t SDLCALL ofs_write(struct SDL_RWops *context, const void *ptr, size
static int SDLCALL ifs_close(struct SDL_RWops *context);
static int SDLCALL ofs_close(struct SDL_RWops *context);
rwops_ptr read_RWops(const std::string &path) {
rwops_ptr make_read_RWops(const std::string &path) {
rwops_ptr rw(SDL_AllocRW(), &SDL_FreeRW);
rw->size = &ifs_size;
@ -52,7 +52,7 @@ rwops_ptr read_RWops(const std::string &path) {
scoped_istream ifs = istream_file(path);
if(!ifs) {
ERR_FS << "read_RWops: istream_file returned NULL on " << path << '\n';
ERR_FS << "make_read_RWops: istream_file returned NULL on " << path << '\n';
rw.reset();
return rw;
}
@ -61,7 +61,7 @@ rwops_ptr read_RWops(const std::string &path) {
return rw;
}
rwops_ptr write_RWops(const std::string &path) {
rwops_ptr make_write_RWops(const std::string &path) {
rwops_ptr rw(SDL_AllocRW(), &SDL_FreeRW);
rw->size = &ofs_size;
@ -74,7 +74,7 @@ rwops_ptr write_RWops(const std::string &path) {
scoped_ostream ofs = ostream_file(path);
if(!ofs) {
ERR_FS << "write_RWops: ostream_file returned NULL on " << path << '\n';
ERR_FS << "make_write_RWops: ostream_file returned NULL on " << path << '\n';
rw.reset();
return rw;
}

View file

@ -184,7 +184,7 @@ static TTF_Font* open_font_impl(const std::string & fname, int size) {
}
}
filesystem::rwops_ptr rwops = filesystem::read_RWops(name);
filesystem::rwops_ptr rwops = filesystem::make_read_RWops(name);
TTF_Font* font = TTF_OpenFontRW(rwops.release(), true, size); // SDL takes ownership of rwops
if(font == nullptr) {
ERR_FT << "Failed opening font: '" << fname << "'\n";

View file

@ -513,7 +513,7 @@ static std::string get_localized_path(const std::string& file, const std::string
// Load overlay image and compose it with the original surface.
static void add_localized_overlay(const std::string& ovr_file, surface& orig_surf)
{
filesystem::rwops_ptr rwops = filesystem::read_RWops(ovr_file);
filesystem::rwops_ptr rwops = filesystem::make_read_RWops(ovr_file);
surface ovr_surf = IMG_Load_RW(rwops.release(), true); // SDL takes ownership of rwops
if(ovr_surf.null()) {
return;
@ -537,7 +537,7 @@ static surface load_image_file(const image::locator& loc)
if(!loc_location.empty()) {
location = loc_location;
}
filesystem::rwops_ptr rwops = filesystem::read_RWops(location);
filesystem::rwops_ptr rwops = filesystem::make_read_RWops(location);
res = IMG_Load_RW(rwops.release(), true); // SDL takes ownership of rwops
// If there was no standalone localized image, check if there is an overlay.
if(!res.null() && loc_location.empty()) {
@ -1217,7 +1217,7 @@ bool save_image(const surface& surf, const std::string& filename)
LOG_DP << "Writing a png image to " << filename << std::endl;
surface tmp = SDL_PNGFormatAlpha(surf.get());
const int err = SDL_SavePNG_RW(tmp, filesystem::write_RWops(filename).release(), 1); //1 means SDL takes ownership of the RWops
const int err = SDL_SavePNG_RW(tmp, filesystem::make_write_RWops(filename).release(), 1); //1 means SDL takes ownership of the RWops
return err == 0;
}
#endif

View file

@ -601,7 +601,7 @@ static void play_new_music()
if(itor == music_cache.end()) {
LOG_AUDIO << "attempting to insert track '" << filename << "' into cache\n";
filesystem::rwops_ptr rwops = filesystem::read_RWops(filename);
filesystem::rwops_ptr rwops = filesystem::make_read_RWops(filename);
// SDL takes ownership of rwops
const std::shared_ptr<Mix_Music> music(Mix_LoadMUSType_RW(rwops.release(), MUS_NONE, true), &Mix_FreeMusic);
@ -882,7 +882,7 @@ static Mix_Chunk* load_chunk(const std::string& file, channel_group group)
const std::string& filename = filesystem::get_binary_file_location("sounds", file);
if(!filename.empty()) {
filesystem::rwops_ptr rwops = filesystem::read_RWops(filename);
filesystem::rwops_ptr rwops = filesystem::make_read_RWops(filename);
temp_chunk.set_data(Mix_LoadWAV_RW(rwops.release(), true)); // SDL takes ownership of rwops
} else {
ERR_AUDIO << "Could not load sound file '" << file << "'." << std::endl;