summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorBertram <bertram@cegetel.net>2010-03-03 23:38:18 +0100
committerBertram <bertram@cegetel.net>2010-03-03 23:38:18 +0100
commit1e52781e7d425cffcc6a5319b4cb5bf5eebe2ea9 (patch)
tree596305e9bfd4ad8448efd477a43f86490b1974c5 /src/game.cpp
parent8cc31b582f372238ce6bd2c86888d312cf1fe5b2 (diff)
parentf5f7a7d5990d1133f714b6cd431aecf6a332fbd5 (diff)
downloadmana-client-1e52781e7d425cffcc6a5319b4cb5bf5eebe2ea9.tar.gz
mana-client-1e52781e7d425cffcc6a5319b4cb5bf5eebe2ea9.tar.bz2
mana-client-1e52781e7d425cffcc6a5319b4cb5bf5eebe2ea9.tar.xz
mana-client-1e52781e7d425cffcc6a5319b4cb5bf5eebe2ea9.zip
Merge branch 'master' of gitorious.org:mana/mana
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/game.cpp b/src/game.cpp
index b3670641..0f45d436 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -82,6 +82,7 @@
#include "resources/resourcemanager.h"
#include "utils/gettext.h"
+#include "utils/mkdir.h"
#include <guichan/exception.hpp>
#include <guichan/focushandler.hpp>
@@ -268,25 +269,17 @@ Game::~Game()
destroyGuiWindows();
- delete beingManager;
- delete player_node;
- delete floorItemManager;
- delete channelManager;
- delete commandHandler;
- delete joystick;
- delete particleEngine;
- delete viewport;
-
- viewport->setMap(NULL);
-
- delete mCurrentMap;
+ del_0(beingManager)
+ del_0(player_node)
+ del_0(floorItemManager)
+ del_0(channelManager)
+ del_0(commandHandler)
+ del_0(joystick)
+ del_0(particleEngine)
+ del_0(viewport)
+ del_0(mCurrentMap)
map_path = "";
- player_node = NULL;
- beingManager = NULL;
- floorItemManager = NULL;
- joystick = NULL;
-
mInstance = 0;
}
@@ -300,14 +293,24 @@ static bool saveScreenshot()
std::stringstream filenameSuffix;
std::stringstream filename;
std::fstream testExists;
+ std::string screenshotDirectory = Client::getScreenshotDirectory();
bool found = false;
+ if (mkdir_r(screenshotDirectory.c_str()) != 0)
+ {
+ logger->log("Directory %s doesn't exist and can't be created! "
+ "Setting screenshot directory to home.",
+ screenshotDirectory.c_str());
+ screenshotDirectory = std::string(PHYSFS_getUserDir());
+ }
+
do {
screenshotCount++;
filenameSuffix.str("");
filename.str("");
- filename << Client::getScreenshotDirectory() << "/";
- filenameSuffix << "Mana_Screenshot_" << screenshotCount << ".png";
+ filename << screenshotDirectory << "/";
+ filenameSuffix << branding.getValue("appShort", "Mana")
+ << "_Screenshot_" << screenshotCount << ".png";
filename << filenameSuffix.str();
testExists.open(filename.str().c_str(), std::ios::in);
found = !testExists.is_open();
@@ -593,8 +596,12 @@ void Game::handleInput()
case KeyboardConfig::KEY_PICKUP:
{
const Vector &pos = player_node->getPosition();
- Uint16 x = (int) pos.x / 32;
- Uint16 y = (int) pos.y / 32;
+ Map *map = viewport->getCurrentMap();
+ Uint16 x = (int) pos.x / map->getTileWidth();
+ Uint16 y = (int) (pos.y - 1)
+ / map->getTileHeight();
+ // y - 1 needed to fix position, otherwise, it's
+ // off under eAthena.
FloorItem *item =
floorItemManager->findByCoordinates(x, y);