diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 2 | ||||
-rw-r--r-- | src/engine.cpp | 9 | ||||
-rw-r--r-- | src/game.cpp | 3 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 1 | ||||
-rw-r--r-- | src/gui/char_select.h | 61 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 3 | ||||
-rw-r--r-- | src/gui/char_server.h | 3 | ||||
-rw-r--r-- | src/gui/chargedialog.cpp | 6 | ||||
-rw-r--r-- | src/gui/chargedialog.h | 7 | ||||
-rw-r--r-- | src/gui/chat.cpp | 6 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/login.h | 3 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup.h | 34 | ||||
-rw-r--r-- | src/gui/status.cpp | 4 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/updatewindow.h | 3 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/map.cpp | 2 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 4 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 8 | ||||
-rw-r--r-- | src/resources/itemmanager.cpp | 18 | ||||
-rw-r--r-- | src/resources/itemmanager.h | 2 | ||||
-rw-r--r-- | src/sound.cpp | 4 |
24 files changed, 117 insertions, 77 deletions
diff --git a/src/being.cpp b/src/being.cpp index ee9ff117..59284787 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -40,6 +40,7 @@ #include "net/protocol.h" #include "resources/resourcemanager.h" +#include "resources/image.h" extern Being* autoTarget; extern std::map<int, Spriteset*> monsterset; @@ -86,6 +87,7 @@ Being* createBeing(unsigned int id, unsigned short job, Map *map) logger->error("Unable to load monster.png"); } else { monsterset[being->job - 1002] = new Spriteset(monsterbitmap, 60, 60); + monsterbitmap->decRef(); } } diff --git a/src/engine.cpp b/src/engine.cpp index 0209fbbc..c5bd9f10 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -176,7 +176,13 @@ Engine::Engine(): Engine::~Engine() { // Delete sprite sets - //delete monsterset; + std::map<int, Spriteset*>::iterator i; + for (i = monsterset.begin(); i != monsterset.end(); i++) + { + delete (*i).second; + } + monsterset.clear(); + delete npcset; delete emotionset; delete weaponset; @@ -185,6 +191,7 @@ Engine::~Engine() attackTarget->decRef(); delete itemDb; + delete debugInfo; } Map *Engine::getCurrentMap() diff --git a/src/game.cpp b/src/game.cpp index 164eab55..f2c68e24 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -415,6 +415,9 @@ void do_exit() delete tiledMap; destroyGuiWindows(); close_session(); + + delete inventory; + delete player_node; if (joypad != NULL) { diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 9834dcf6..0c03a6b0 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -46,7 +46,6 @@ #include "../net/protocol.h" - CharSelectDialog::CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m): ConfirmDialog(m, "Confirm", "Are you sure you want to delete this character?"), diff --git a/src/gui/char_select.h b/src/gui/char_select.h index c4aac4b9..3751a440 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -29,16 +29,35 @@ #include "../guichanfwd.h" +#include <SDL_events.h> + class PlayerBox; struct PLAYER_INFO; -struct SDL_KeyboardEvent; /** * Character selection dialog. * * \ingroup Interface */ -class CharSelectDialog : public Window, public gcn::ActionListener { +class CharSelectDialog : public Window, public gcn::ActionListener +{ + public: + /** + * Constructor. + */ + CharSelectDialog(); + + /** + * Destructor. + */ + ~CharSelectDialog(); + + void action(const std::string& eventId); + + void setPlayerInfo(PLAYER_INFO* pi); + + void logic(); + private: gcn::Button *selectButton; gcn::Button *cancelButton; @@ -73,31 +92,30 @@ class CharSelectDialog : public Window, public gcn::ActionListener { private: CharSelectDialog *master; }; +}; +/** + * Character creation dialog. + * + * \ingroup GUI + */ +class CharCreateDialog : public Window, public gcn::ActionListener +{ public: /** * Constructor. */ - CharSelectDialog(); + CharCreateDialog(Window *parent = NULL); /** * Destructor. */ - ~CharSelectDialog(); + ~CharCreateDialog(); void action(const std::string& eventId); - void setPlayerInfo(PLAYER_INFO* pi); - - void logic(); -}; + std::string getName(); -/** - * Character creation dialog. - * - * \ingroup GUI - */ -class CharCreateDialog : public Window, public gcn::ActionListener { private: gcn::TextField *nameField; gcn::Label *nameLabel; @@ -117,21 +135,6 @@ class CharCreateDialog : public Window, public gcn::ActionListener { * info. */ void serverCharCreate(); - - public: - /** - * Constructor. - */ - CharCreateDialog(Window *parent = NULL); - - /** - * Destructor. - */ - ~CharCreateDialog(); - - void action(const std::string& eventId); - - std::string getName(); }; void charSelectInputHandler(SDL_KeyboardEvent *keyEvent); diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index c368727b..5c371469 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -177,6 +177,9 @@ void server_char_server(int serverIndex) { char_info[i] = new PLAYER_INFO; + char_info[i]->totalWeight = 0; + char_info[i]->maxWeight = 0; + char_info[i]->lastAttackTime = 0; char_info[i]->id = msg.readLong(); char_info[i]->xp = msg.readLong(); char_info[i]->gp = msg.readLong(); diff --git a/src/gui/char_server.h b/src/gui/char_server.h index d19e84af..70361496 100644 --- a/src/gui/char_server.h +++ b/src/gui/char_server.h @@ -26,13 +26,12 @@ #include <guichan/actionlistener.hpp> #include <guichan/listmodel.hpp> +#include <SDL_events.h> #include "window.h" #include "../guichanfwd.h" -struct SDL_KeyboardEvent; - /** * The list model for the server list. */ diff --git a/src/gui/chargedialog.cpp b/src/gui/chargedialog.cpp index 797d5129..c6cee598 100644 --- a/src/gui/chargedialog.cpp +++ b/src/gui/chargedialog.cpp @@ -33,14 +33,14 @@ ChargeDialog::ChargeDialog(): Window("") { - setContentSize(180,70); - progBar = new ProgressBar(0.0f,20,40,140,25,128,128,128); + setContentSize(180, 70); + progBar = new ProgressBar(0.0f, 20, 40, 140, 25, 128, 128, 128); add(progBar); } ChargeDialog::~ChargeDialog() { - + delete progBar; } void ChargeDialog::action(const std::string& eventId) diff --git a/src/gui/chargedialog.h b/src/gui/chargedialog.h index c42e06ec..4e6d83dc 100644 --- a/src/gui/chargedialog.h +++ b/src/gui/chargedialog.h @@ -36,10 +36,6 @@ class ProgressBar; */ class ChargeDialog : public Window, public gcn::ActionListener { - private: - // members - ProgressBar* progBar; - public: /** * Constructor. @@ -54,6 +50,9 @@ class ChargeDialog : public Window, public gcn::ActionListener // action listener void action(const std::string&); void logic(); + + private: + ProgressBar* progBar; }; extern ChargeDialog* chargeDialog; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index ab654440..be06a14a 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -47,11 +47,11 @@ ChatWindow::ChatWindow(const std::string &logfile): setContentSize(600, 100); setResizable(true); - + chatInput = new ChatInput(); chatInput->setEventId("chatinput"); chatInput->addActionListener(this); - + textOutput = new BrowserBox(BrowserBox::AUTO_WRAP); textOutput->setOpaque(false); textOutput->disableLinksAndUserColors(); @@ -73,6 +73,8 @@ ChatWindow::ChatWindow(const std::string &logfile): ChatWindow::~ChatWindow() { delete chatInput; + delete textOutput; + delete scrollArea; chatlog_file.flush(); chatlog_file.close(); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 5ed0c189..eeaa13da 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -46,10 +46,12 @@ EquipmentWindow::EquipmentWindow(): Image *itemImg = resman->getImage("graphics/sprites/items.png"); if (!itemImg) logger->error("Unable to load items.png"); itemset = new Spriteset(itemImg, 32, 32); + itemImg->decRef(); } EquipmentWindow::~EquipmentWindow() { + delete itemset; } void EquipmentWindow::draw(gcn::Graphics *graphics) diff --git a/src/gui/login.h b/src/gui/login.h index ce983b8a..5f841d37 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -26,12 +26,11 @@ #include <iosfwd> #include <guichan/actionlistener.hpp> +#include <SDL_events.h> #include "window.h" #include "../guichanfwd.h" -struct SDL_KeyboardEvent; - /** * The login dialog. * diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 4026679e..cc2150de 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -200,11 +200,13 @@ Setup::Setup(): Setup::~Setup() { + delete videoLabel; delete modeListModel; delete modeList; delete scrollArea; delete fsCheckBox; delete openGLCheckBox; + delete customCursorCheckBox; delete soundCheckBox; delete audioLabel; delete applyButton; diff --git a/src/gui/setup.h b/src/gui/setup.h index 7e75c2b0..64358176 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -72,6 +72,23 @@ class ModeListModel : public gcn::ListModel */ class Setup : public Window, public gcn::ActionListener { + public: + /** + * Constructor. + */ + Setup(); + + /** + * Destructor. + */ + ~Setup(); + + /** + * Event handling method. + */ + void + action(const std::string& eventId); + private: ModeListModel *modeListModel; @@ -97,23 +114,6 @@ class Setup : public Window, public gcn::ActionListener bool openGLEnabled; bool customCursorEnabled; bool soundEnabled; - - public: - /** - * Constructor. - */ - Setup(); - - /** - * Destructor. - */ - ~Setup(); - - /** - * Event handling method. - */ - void - action(const std::string& eventId); }; extern Setup *setupWindow; diff --git a/src/gui/status.cpp b/src/gui/status.cpp index a601ff59..aea72995 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -220,8 +220,10 @@ StatusWindow::~StatusWindow() delete statsTitleLabel; delete statsTotalLabel; delete statsCostLabel; - for (int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) + { delete statsLabel[i]; + delete pointsLabel[i]; delete statsDisplayLabel[i]; delete statsButton[i]; } diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index cd26aca9..5007e5f1 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -106,12 +106,13 @@ UpdaterWindow::~UpdaterWindow() remove((mBasePath + "/updates/resources.txt").c_str()); remove((mBasePath + "/updates/download.temp").c_str()); - delete [] mCurlError; + delete[] mCurlError; delete mScrollArea; delete mLabel; delete mProgressBar; delete mCancelButton; delete mPlayButton; + delete mBrowserBox; } void UpdaterWindow::setProgress(float p) diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h index 56ff4065..4fd29ff2 100644 --- a/src/gui/updatewindow.h +++ b/src/gui/updatewindow.h @@ -25,9 +25,9 @@ #define _UPDATERWINDOW_H #include <guichan/actionlistener.hpp> - #include <string> #include <vector> +#include <SDL_events.h> #include "window.h" @@ -39,7 +39,6 @@ class ProgressBar; class ScrollArea; struct SDL_mutex; -struct SDL_KeyboardEvent; struct SDL_Thread; /** diff --git a/src/main.cpp b/src/main.cpp index 79e2a767..69158784 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -307,6 +307,9 @@ void exit_engine() // Shutdown libxml xmlCleanupParser(); + + // Shutdown sound + sound.close(); ResourceManager::deleteInstance(); delete logger; @@ -501,6 +504,7 @@ int main(int argc, char *argv[]) } } + fclose(nullFile); logger->log("State: EXIT"); exit_engine(); PHYSFS_deinit(); diff --git a/src/map.cpp b/src/map.cpp index 47630450..2e1b3a00 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -41,7 +41,7 @@ Location::Location(int x, int y, MetaTile *tile): bool Location::operator< (const Location &loc) const { - return tile->Fcost > loc.tile->Fcost; + return tile->Fcost > loc.tile->Fcost; } diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index e23be049..69090dcb 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -30,6 +30,10 @@ ItemInfo::ItemInfo() : { } +ItemInfo::~ItemInfo() +{ +} + void ItemInfo::setImage(short image) { this->image = image; diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index f634025f..937911af 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -31,13 +31,14 @@ */ class ItemInfo { + friend class ItemManager; + public: /** * Constructor. */ ItemInfo(); - void setImage(short image); short getImage(); @@ -70,21 +71,18 @@ class ItemInfo char getSlot(); - protected: /** * Destructor. */ ~ItemInfo(); - + short image, art; std::string name; std::string description; std::string effect; short type, weight; char slot; - - }; #endif diff --git a/src/resources/itemmanager.cpp b/src/resources/itemmanager.cpp index 7d9c5ef5..caa26f5b 100644 --- a/src/resources/itemmanager.cpp +++ b/src/resources/itemmanager.cpp @@ -42,12 +42,16 @@ ItemManager::ItemManager() xmlDocPtr doc = xmlParseMemory(data, size); free(data); - if (doc) { + if (doc) + { xmlNodePtr node = xmlDocGetRootElement(doc); - if (!node || !xmlStrEqual(node->name, BAD_CAST "items")) { + if (!node || !xmlStrEqual(node->name, BAD_CAST "items")) + { logger->error("items.xml is not a valid database file!"); - } else { + } + else + { for (node = node->xmlChildrenNode; node != NULL; node = node->next) { if (xmlStrEqual(node->name, BAD_CAST "item")) @@ -112,6 +116,14 @@ ItemManager::ItemManager() ItemManager::~ItemManager() { + std::map<int, ItemInfo*>::iterator i; + for (i = db.begin(); i != db.end(); i++) + { + delete (*i).second; + } + db.clear(); + + delete unknown; } ItemInfo *ItemManager::getItemInfo(int id) diff --git a/src/resources/itemmanager.h b/src/resources/itemmanager.h index be861c01..6d969923 100644 --- a/src/resources/itemmanager.h +++ b/src/resources/itemmanager.h @@ -48,7 +48,7 @@ class ItemManager protected: // Items database - std::map <int, ItemInfo *> db; + std::map<int, ItemInfo*> db; ItemInfo *unknown; }; diff --git a/src/sound.cpp b/src/sound.cpp index d562a688..7bbe36e7 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -38,8 +38,6 @@ Sound::Sound(): Sound::~Sound() { - stopMusic(); - close(); } void Sound::init() @@ -207,6 +205,8 @@ void Sound::playSfx(const char *path) void Sound::close() { + stopMusic(); + installed = false; Mix_CloseAudio(); logger->log("Sound::close() Shutting down sound..."); |