Skip to content

Commit

Permalink
Remove obsolete urarlib (#64)
Browse files Browse the repository at this point in the history
* started removing the code

* removed globals
  • Loading branch information
Mia75owo authored Nov 12, 2023
1 parent ea5b1ce commit bd18060
Show file tree
Hide file tree
Showing 49 changed files with 6 additions and 5,378 deletions.
2 changes: 0 additions & 2 deletions Hurrican/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,6 @@ IF(DISABLE_MEMPOOLING)
ENDIF(DISABLE_MEMPOOLING)

# TODO add options
# Use the Unrarlib library, for support of packing of data files
# add_definitions(-DUSE_UNRARLIB)
# ETC1 texture compression support
# add_definitions(-DUSE_ETC1)
# PVRTC texture compression suppor
Expand Down
23 changes: 0 additions & 23 deletions Hurrican/src/DX8Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#include "DX8Graphics.hpp"
#include "Gameplay.hpp"

#ifdef USE_UNRARLIB
#include "unrarlib.h"
#endif

#include <string>

// DKS - Added these includes temporarily so LoadFont() could output character widths to
Expand Down Expand Up @@ -143,8 +139,6 @@ bool DirectGraphicsFont::LoadFont(const char *Filename,
//
image_t image;
std::string fullpath;
char *pData;
unsigned long Size;

if (CommandLineParams.RunOwnLevelList == true)
{
Expand Down Expand Up @@ -177,23 +171,6 @@ bool DirectGraphicsFont::LoadFont(const char *Filename,
}
}

#if defined(USE_UNRARLIB)
if (image.data == nullptr)
{
if (urarlib_get(&pData, &Size, Filename, RARFILENAME, convertText(RARFILEPASSWORD)) != false)
{
if (!loadImageSDL(image, nullptr, pData, Size))
delete [] image.data;
free(pData);
Protokoll << "Error in LoadFont(): loadImageSDL() returned error loading " << Filename << " from buffer" << std::endl;
GameRunning = false;
return false;
}
free(pData);
}
}
#endif // USE_UNRARLIB

if (image.data == nullptr) {
Protokoll << "Error in LoadFont(): image.data is NULL" << std::endl;
GameRunning = false;
Expand Down
48 changes: 3 additions & 45 deletions Hurrican/src/DX8Sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ namespace fs = std::filesystem;
#include "Player.hpp"
#include "Timer.hpp"

#ifdef USE_UNRARLIB
#include "unrarlib.h"
#endif

constexpr int MIXRATE = 48000;

//---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -303,10 +299,6 @@ void SoundManagerClass::LoadSong(const std::string &filename, int nr, bool loop
UnloadSong(nr);
}

bool fromrar = false;
char *pData = nullptr;
// DKS - Changed from unsigned int to unsigned long to fix unrarlib compilation error:
unsigned long buf_size = 0;
std::string fullpath;

// Zuerst checken, ob sich der Song in einem MOD-Ordner befindet
Expand All @@ -322,29 +314,15 @@ void SoundManagerClass::LoadSong(const std::string &filename, int nr, bool loop
if (fs::exists(fullpath) && fs::is_regular_file(fullpath))
goto loadfile;

#if defined(USE_UNRARLIB)
// Auch nicht? Dann ist es hoffentlich im RAR file
if (urarlib_get(&pData, &buf_size, filename.c_str(), RARFILENAME, convertText(RARFILEPASSWORD)) == false) {
Protokoll << "\n-> Error loading song file " << filename << " from Archive !" << std::endl;
return;
} else
fromrar = true;
#else
Protokoll << "\n-> Error: Could not locate song file " << fullpath << std::endl;
GameRunning = false;
return;
#endif // USE_UNRARLIB

loadfile:
// DKS - Added loop boolean to specify if the song plays looped or not:
songs[nr].looped = loop;

if (fromrar) {
songs[nr].data = MUSIC_LoadSongEx(pData, 0, buf_size, FSOUND_LOADMEMORY, nullptr, 0);
free(pData);
} else {
songs[nr].data = MUSIC_LoadSong(fullpath.c_str());
}
songs[nr].data = MUSIC_LoadSong(fullpath.c_str());

// Fehler beim Laden ?
//
Expand Down Expand Up @@ -583,10 +561,6 @@ void SoundManagerClass::LoadWave(const std::string &filename, int nr, bool loope
if (!GameRunning)
return;

bool fromrar = false;
char *pData = nullptr;
// DKS - Changed from unsigned int to unsigned long to fix unrarlib compilation error:
unsigned long buf_size = 0;
std::string fullpath;

if (sounds[nr].data)
Expand All @@ -606,30 +580,14 @@ void SoundManagerClass::LoadWave(const std::string &filename, int nr, bool loope
if (fs::exists(fullpath) && fs::is_regular_file(fullpath))
goto loadfile;

#if defined(USE_UNRARLIB)
// Auch nicht? Dann ist es hoffentlich im RAR file
if (urarlib_get(&pData, &buf_size, filename.c_str(), RARFILENAME, convertText(RARFILEPASSWORD)) == false) {
Protokoll << "\n-> Error loading " << filename << " from Archive !" << std::endl;
GameRunning = false;
return;
} else
fromrar = true;
#else
Protokoll << "\n-> Error: could not find WAV file " << fullpath << std::endl;
GameRunning = false;
return;
#endif // USE_UNRARLIB

loadfile:

if (fromrar) {
sounds[nr].data = SOUND_Sample_Load(
nr, pData, (looped ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF) | FSOUND_LOADMEMORY, 0, buf_size);
free(pData);
} else {
sounds[nr].data =
SOUND_Sample_Load(nr, fullpath.c_str(), (looped ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF), 0, 0);
}
sounds[nr].data =
SOUND_Sample_Load(nr, fullpath.c_str(), (looped ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF), 0, 0);

// Fehler beim Laden ?
if (!sounds[nr].data)
Expand Down
34 changes: 1 addition & 33 deletions Hurrican/src/DX8Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#include "Logdatei.hpp"
#include "Main.hpp"

#ifdef USE_UNRARLIB
#include "unrarlib.h"
#endif

extern bool GameRunning; // Läuft das Spiel noch ?

// --------------------------------------------------------------------------------------
Expand Down Expand Up @@ -84,14 +80,11 @@ bool DirectGraphicsSprite::LoadImage(const char *Filename, int xs, int ys, int x
if(GameRunning == false)
return false;

bool fromrar;
HRESULT hresult;
char *pData;
char Temp[256];
#if defined(USE_PVRTC) || defined(USE_ETC1)
char compresstex[256];
#endif
unsigned long Size;
#if defined(PLATFORM_SDL)
()hresult;

Expand All @@ -102,8 +95,6 @@ bool DirectGraphicsSprite::LoadImage(const char *Filename, int xs, int ys, int x
delete_texture( itsTexture );
itsTexture = 0;

fromrar = false;

// Zuerst checken, ob sich die Grafik in einem MOD-Ordner befindet
if (CommandLineParams.RunOwnLevelList == true)
{
Expand Down Expand Up @@ -158,36 +149,13 @@ bool DirectGraphicsSprite::LoadImage(const char *Filename, int xs, int ys, int x
if (FileExists(Temp))
goto loadfile;

#if defined(USE_UNRARLIB)
// Auch nicht? Dann ist es hoffentlich im RAR file

if (urarlib_get(&pData, &Size, Filename, RARFILENAME, convertText(RARFILEPASSWORD)) == false)
{
Protokoll << "\n-> Error loading " << Filename << " from Archive !" << std::endl;
GameRunning = false;
return false;
}
else
fromrar = true;
#else
Protokoll << "\n-> Error loading " << Temp << "!" << std::endl;
GameRunning = false;
return false;
#endif // USE_UNRARLIB


loadfile:

// normal von Platte laden?
if (fromrar == false)
{
itsTexture = LoadTexture( Temp, dims, 0 );
}
else
{
itsTexture = LoadTexture( pData, dims, Size );
free(pData);
}
itsTexture = LoadTexture( Temp, dims, 0 );

// Grösse setzen
itsXSize = (float)dims.w;
Expand Down
24 changes: 0 additions & 24 deletions Hurrican/src/DX8Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#include <string>
namespace fs = std::filesystem;

#ifdef USE_UNRARLIB
#include "unrarlib.h"
#endif

const std::string TexturesystemClass::scalefactors_filename("scalefactors.txt");

// --------------------------------------------------------------------------------------
Expand Down Expand Up @@ -215,26 +211,6 @@ bool TexturesystemClass::LoadTextureFromFile(const std::string &filename, Textur
if (fs::exists(fullpath) && fs::is_regular_file(fullpath))
goto loadfile;

#if defined(USE_UNRARLIB)
// Are we using unrarlib to read all game data from a single RAR archive?
void *buf_data = nullptr; // Memory buffer file is read into, if using unrarlib
unsigned long buf_size = 0; // Size of memory buffer file is read into, if using unrarlib
if (fs::exists(RARFILENAME) && fs::is_regular_file(RARFILENAME) &&
urarlib_get(&buf_data, &buf_size, filename.c_str(), RARFILENAME, convertText(RARFILEPASSWORD)) &&
buf_data != nullptr) {
// Load the texture from the image that is now in buf_data[]
success = SDL_LoadTexture(nullptr, nullptr, buf_data, buf_size, th);
if (buf_data)
free(buf_data);

if (success) {
goto loaded;
} else {
Protokoll << "Error loading texture " << filename << " from archive " << RARFILENAME << std::endl;
Protokoll << "->Trying elsewhere.." << std::endl;
}
}
#endif // USE_UNRARLIB
loadfile:
// Load the texture from disk:
success = SDL_LoadTexture(path, filename, nullptr, 0, th);
Expand Down
3 changes: 0 additions & 3 deletions Hurrican/src/Globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ constexpr float MAX_ENERGY = 100.0f; // Maximalwert für die Spielerenerg
constexpr float MAX_ARMOUR = 200.0f; // Maximalwert für das Rad
constexpr int DIAMONDS_FOR_EXTRALIFE = 50; // Diamanten die man für 200 Zeiteinheiten

#define RARFILENAME "Hurrican.dat"
#define RARFILEPASSWORD "+/#(%,,/"

#if defined(__AROS__)
# define TEMP_FILE_PREFIX "T:"
#else
Expand Down
4 changes: 0 additions & 4 deletions Hurrican/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ namespace fs = std::filesystem;
#include "Partikelsystem.hpp"
#include "Projectiles.hpp"

#ifdef USE_UNRARLIB
#include "unrarlib.h"
#endif

#if defined(ANDROID)
#include <android/log.h>
#endif
Expand Down
13 changes: 2 additions & 11 deletions Hurrican/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ DEFINES += -DUSE_INDEXED_BATCH
####### C++ exceptions can be turned off, reducing unnecessary code bloat and speed-hit:
#USE_NO_EXCEPTIONS := yes

####### Use the Unrarlib library, for support of packing of data files:
#USE_UNRARLIB := yes

# *** END OPTIONAL DEFINES ***


Expand Down Expand Up @@ -283,12 +280,6 @@ DEFINES += -DUSE_NO_EXCEPTIONS
endif
endif

ifeq ($(USE_UNRARLIB),yes)
DEFINES += -DUSE_UNRARLIB
INCLUDES += -I./unrarlib040/unrarlib
UNRAR_FILES := unrarlib040/unrarlib/unrarlib
endif

ifeq ($(USE_EGL),yes)
EGL_FILES := SDLPort/eglport
endif
Expand Down Expand Up @@ -507,7 +498,7 @@ FILES :=Boss_BigFish \
stdafx \
tracealloc

ALL_FILES := $(FILES) $(SDL_FILES) $(UNRAR_FILES) $(EGL_FILES) $(GL_FILES) $(FBO_FILES)
ALL_FILES := $(FILES) $(SDL_FILES) $(EGL_FILES) $(GL_FILES) $(FBO_FILES)

ALL_OBJS := $(addsuffix .o, $(ALL_FILES))

Expand All @@ -523,4 +514,4 @@ $(EXE) : $(ALL_OBJS)
.PHONY : clean

clean :
$(RM) *.o SDLPort/*.o unrarlib040/unrarlib/*.o $(EXE)
$(RM) *.o SDLPort/*.o $(EXE)
5 changes: 0 additions & 5 deletions Hurrican/src/SDLPort/SDL_fmod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,7 @@ MUSIC_MODULE *MUSIC_LoadSongEx(const char *filename,
unsigned int mode,
const int *samplelist,
int samplelistnum) {
// TODO Only need for unrar, but this will require cache the music file to disk
#if defined(USE_OPENMPT)
return NULL;
#else
return NULL;
#endif
}

// DKS - Added default parameter to specify if a song should loop ('gameover.it' and 'stageclear.it' songs shouldn't):
Expand Down
Loading

0 comments on commit bd18060

Please sign in to comment.