Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib-src/enigma-core/ecl_video.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,16 @@ ecl::Screen *ecl::Screen::get_instance() {

ecl::Screen::Screen(SDL_Window *window, int surface_w, int surface_h)
: m_window(window),
m_surface(Surface::make_surface(
SDL_CreateRGBSurface(0, surface_w, surface_h, 32, 0xff0000, 0xff00, 0xff, 0xff000000),
NO_ALPHA)),
m_sdlsurface(m_surface->get_surface()),
update_all_p(false) {
m_surface.reset(Surface::make_surface(
SDL_CreateRGBSurface(0, surface_w, surface_h, 32, 0xff0000, 0xff00, 0xff, 0xff000000),
NO_ALPHA));
m_sdlsurface = m_surface->get_surface();
assert(m_window);
assert(m_surface);
assert(m_instance == 0);
m_instance = this;
m_scaler = new ecl::Scaler(m_surface->get_surface(), NULL, SDL_GetWindowSurface(m_window));
m_scaler = std::make_unique<ecl::Scaler>(m_surface->get_surface(), nullptr, SDL_GetWindowSurface(m_window));
}

ecl::Screen::~Screen() {
Expand Down Expand Up @@ -750,6 +750,6 @@ Surface *ecl::MakeSurface(void *data, int w, int h, int bipp, int pitch, const R
}

void ecl::BlitScaled(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect, ScalerMode mode) {
Scaler* scaler = new Scaler(src, srcrect, dst, mode);
scaler->blit_scaled(src, srcrect, dst, dstrect);
Scaler scaler{src, srcrect, dst, mode};
scaler.blit_scaled(src, srcrect, dst, dstrect);
}
7 changes: 4 additions & 3 deletions lib-src/enigma-core/ecl_video.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define ECL_VIDEO_HH_INCLUDED

#include "ecl_geom.hh"
#include <memory>

#include "SDL.h"

Expand Down Expand Up @@ -248,7 +249,7 @@ public:
/* ---------- Accessors ---------- */

SDL_Window *window() const { return m_window; }
Surface *get_surface() const { return m_surface; }
Surface *get_surface() const { return m_surface.get(); }

Rect size() const;
int width() const;
Expand All @@ -267,15 +268,15 @@ private:
static Screen *m_instance;

SDL_Window *m_window;
Surface *m_surface;
std::unique_ptr<Surface> m_surface;
SDL_Surface *m_sdlsurface;
RectList m_dirtyrects;
bool update_all_p;

Screen(const Screen &);
Screen &operator=(const Screen &);

Scaler *m_scaler;
std::unique_ptr<Scaler> m_scaler;
};

/* -------------------- Graphics primitives -------------------- */
Expand Down
8 changes: 4 additions & 4 deletions src/gui/InfoMenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ namespace enigma { namespace gui {
numPages = process_infotext(false);

but_ok = new StaticTextButton(N_("Ok"), this);
pgup = new ImageButton("ic-up", "ic-up1", this);
pgdown = new ImageButton("ic-down", "ic-down1", this);

add(but_ok, Rect(vminfo.width-(vshrink?80:130), vminfo.height-(vshrink?30:60), vshrink?70:110, vshrink?20:40));
if (numPages > pInfo[vminfo.tt].columnsPerPage) {
pgup = new ImageButton("ic-up", "ic-up1", this);
pgdown = new ImageButton("ic-down", "ic-down1", this);
add(pgup, Rect(vminfo.width-(vshrink?15:30), vminfo.height/2, vshrink?10:20, vshrink?25:50));
add(pgdown, Rect(vminfo.width-(vshrink?15:30), vminfo.height/2 +(vshrink?35:70), vshrink?10:20, vshrink?25:50));
}
Expand Down Expand Up @@ -119,12 +119,12 @@ namespace enigma { namespace gui {
void InfoMenu::on_action (gui::Widget *w) {
if (w == but_ok) {
Menu::quit();
} else if (w == pgup) {
} else if (pgup && w == pgup) {
if (curPage > 0) {
curPage--;
invalidate_all();
}
} else if (w == pgdown) {
} else if (pgdown && w == pgdown) {
if (curPage < numPages - 1) {
curPage++;
invalidate_all();
Expand Down
6 changes: 3 additions & 3 deletions src/gui/InfoMenu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ namespace enigma { namespace gui {
const char **info;
int curPage;
int numPages;
Widget *but_ok;
Widget *pgup;
Widget *pgdown;
Widget *but_ok = nullptr;
Widget *pgup = nullptr;
Widget *pgdown = nullptr;
ecl::GC *current_gc;

int process_infotext(bool render);
Expand Down
9 changes: 6 additions & 3 deletions src/gui/LevelPackMenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,16 @@ namespace enigma { namespace gui {
}
if (but_tutorial2 != NULL) {
remove_child(but_tutorial2);
delete but_tutorial1;
delete but_tutorial2;
but_tutorial2 = NULL;
}

for (auto it = tutorialLines.begin(); it != tutorialLines.end(); it++)
if (*it != NULL)
for (auto it = tutorialLines.begin(); it != tutorialLines.end(); it++) {
if (*it != NULL) {
remove_child(*it);
delete *it;
}
}
tutorialLines.clear();

packButtons.clear();
Expand Down
22 changes: 14 additions & 8 deletions src/lev/PersistentIndex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace enigma { namespace lev {

PersistentIndex * PersistentIndex::historyIndex = NULL;
std::vector<std::shared_ptr<PersistentIndex> > PersistentIndex::indexCandidates;
std::vector<std::unique_ptr<PersistentIndex> > PersistentIndex::persistentIndices;

void PersistentIndex::checkCandidate(std::string thePackPath, bool systemOnly, bool userOwned,
bool isAuto, bool isSystemCross, bool isUserCross, double defaultLocation,
Expand Down Expand Up @@ -151,6 +152,11 @@ namespace enigma { namespace lev {
}
}

void PersistentIndex::registerIndex(std::unique_ptr<PersistentIndex> index) {
Index::registerIndex(index.get());
persistentIndices.push_back(std::move(index));
}

void PersistentIndex::registerPersistentIndices(bool onlySystemIndices) {
DirIter * dirIter;
DirEntry dirEntry;
Expand Down Expand Up @@ -221,20 +227,18 @@ namespace enigma { namespace lev {

// register index free auto folder
// this needs to be done prior history registration to avoid outdated proxies
PersistentIndex * autoIndex = new PersistentIndex("auto", false, true, true,
std::unique_ptr<PersistentIndex> autoIndex = std::make_unique<PersistentIndex>("auto", false, true, true,
INDEX_AUTO_PACK_LOCATION, INDEX_AUTO_PACK_NAME, INDEX_STD_FILENAME,
INDEX_AUTO_PACK_DESCRIPTION);
autoIndex->isEditable = false;
Index::registerIndex(autoIndex);
PersistentIndex::registerIndex(std::move(autoIndex));

// register team auto not yet registered new files
PersistentIndex * teamautoIndex = new PersistentIndex("team_test_new_api", false, true, true,
std::unique_ptr<PersistentIndex> teamautoIndex = std::make_unique<PersistentIndex>("team_test_new_api", false, true, true,
75000, "test_new_api");
if (teamautoIndex->size() > 0) {
teamautoIndex->isEditable = false;
Index::registerIndex(teamautoIndex);
} else {
delete teamautoIndex;
PersistentIndex::registerIndex(std::move(teamautoIndex));
}

// UserPath: register dirs and zips with xml-indices excl auto
Expand Down Expand Up @@ -601,6 +605,7 @@ namespace enigma { namespace lev {
// Must be called before XMLPlatformUtils::terminate
void PersistentIndex::shutdown() {
indexCandidates.clear();
persistentIndices.clear();
}

std::string PersistentIndex::getPackPath() {
Expand Down Expand Up @@ -1210,7 +1215,7 @@ namespace enigma { namespace lev {
std::string indexString;
is >> indexString;
std::stringstream indexStream(indexString);
Index::registerIndex(new PersistentIndex(indexStream, dir, false, indexName));
PersistentIndex::registerIndex(std::make_unique<PersistentIndex>(indexStream, dir, false, indexName));
} catch (const XLevelPackInit &e) {
Log << e.get_string() << "\n";
}
Expand Down Expand Up @@ -1246,7 +1251,8 @@ namespace enigma { namespace lev {
indexName = line;

// check if already loaded
Index::registerIndex(new PersistentIndex(inflatedContent, dir, true, indexName));
PersistentIndex::registerIndex(std::make_unique<PersistentIndex>(
inflatedContent, dir, true, indexName));
} else {
throw XLevelPackInit ("Invalid level pack: " + indexName);
}
Expand Down
2 changes: 2 additions & 0 deletions src/lev/PersistentIndex.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace enigma { namespace lev {
class PersistentIndex : public Index {
public:
static void registerPersistentIndices(bool onlySystemIndices);
static void registerIndex(std::unique_ptr<PersistentIndex> index);
static PersistentIndex * historyIndex;
static void addCurrentToHistory();
static void shutdown();
Expand Down Expand Up @@ -127,6 +128,7 @@ namespace enigma { namespace lev {
std::string indexUrl;
private:
static std::vector<std::shared_ptr<PersistentIndex> > indexCandidates;
static std::vector<std::unique_ptr<PersistentIndex> > persistentIndices;
std::string absIndexPath;
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc;
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *infoElem;
Expand Down
3 changes: 2 additions & 1 deletion src/stones/ShogunStone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#include "world.hh"

namespace enigma {
ShogunStone::ShogunStone(int holes) : Stone () {
ShogunStone::ShogunStone(int holes) :
Stone (), subShogun(nullptr), superShogun(nullptr) {
objFlags |= holes << 24;
}

Expand Down