diff options
author | David Athay <dathay@mini1.local> | 2011-04-06 19:24:23 -0500 |
---|---|---|
committer | David Athay <dathay@mini1.local> | 2011-04-06 19:24:23 -0500 |
commit | 701a8d8bf4fe2d286c2ffa39efa8b80e6c85ff01 (patch) | |
tree | 4f01225b6a3958ce9361fe60533a19d6d522ed48 /src | |
parent | 66bd56ebec2bff48fb1484603b41643fd89bf4d6 (diff) | |
parent | b6f3db30c595d8e89572c78eb82b9823b8491c54 (diff) | |
download | mana-701a8d8bf4fe2d286c2ffa39efa8b80e6c85ff01.tar.gz mana-701a8d8bf4fe2d286c2ffa39efa8b80e6c85ff01.tar.bz2 mana-701a8d8bf4fe2d286c2ffa39efa8b80e6c85ff01.tar.xz mana-701a8d8bf4fe2d286c2ffa39efa8b80e6c85ff01.zip |
Merge branch '0.5' of git://gitorious.org/mana/mana into 0.5
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/client.cpp | 11 | ||||
-rw-r--r-- | src/commandhandler.cpp | 16 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 10 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 2 | ||||
-rw-r--r-- | src/localplayer.cpp | 31 | ||||
-rw-r--r-- | src/localplayer.h | 18 | ||||
-rw-r--r-- | src/main.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 7 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 43 | ||||
-rw-r--r-- | src/utils/sha256.cpp | 5 | ||||
-rw-r--r-- | src/winver.h | 4 |
12 files changed, 121 insertions, 32 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0fd32f59..35af94fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -620,8 +620,8 @@ SET(SRCS_MANA ) IF (WIN32) - SET(SRCS_MANA - ${SRCS_MANA} + SET(SRCS + ${SRCS} utils/specialfolder.cpp utils/specialfolder.h mana.rc diff --git a/src/client.cpp b/src/client.cpp index 42a8465b..d88c32c9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1106,18 +1106,19 @@ void Client::initHomeDir() mConfigDir = mOptions.configDir; - if (mConfigDir.empty()){ + if (mConfigDir.empty()) + { + const std::string app = branding.getValue("appShort", "manasource"); #ifdef __APPLE__ - mConfigDir = mLocalDataDir + "/" + branding.getValue("appShort", "mana"); + mConfigDir = mLocalDataDir + "/" + app; #elif defined WIN32 mConfigDir = getSpecialFolderLocation(CSIDL_APPDATA); if (mConfigDir.empty()) mConfigDir = mLocalDataDir; else - mConfigDir += "/mana/" + branding.getValue("appShort", "Mana"); + mConfigDir += "/mana/" + app; #else - mConfigDir = std::string(PHYSFS_getUserDir()) + - "/.config/mana/" + branding.getValue("appShort", "mana"); + mConfigDir = std::string(PHYSFS_getUserDir()) + "/.config/mana/" + app; #endif } diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 1c375ad9..f8ef116c 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -50,6 +50,7 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) std::string::size_type pos = command.find(' '); std::string type(command, 0, pos); std::string args(command, pos == std::string::npos ? command.size() : pos + 1); + trim(args); if (type == "help") // Do help before tabs so they can't override it { @@ -402,8 +403,21 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) void CommandHandler::handleQuery(const std::string &args, ChatTab *tab) { - if (chatWindow->addWhisperTab(args, true)) + if (args.empty()) + { + tab->chatLog(_("No <nick> was given."), BY_SERVER); + return; + } + + if (args.length() > 1 && args[0] == '\"' && args[args.length() - 1] == '\"') + { + if (chatWindow->addWhisperTab(args.substr(1, args.length() - 2), true)) + return; + } + else if (chatWindow->addWhisperTab(args, true)) + { return; + } tab->chatLog(strprintf(_("Cannot create a whisper tab for nick \"%s\"! " "It either already exists, or is you."), args.c_str()), BY_SERVER); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 409a0eda..fa068cda 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -344,6 +344,11 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, if (isInventory) { + if (InventoryWindow::isStorageActive()) + { + mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store"))); + } + if (item->isEquipment()) { if (item->isEquipped()) @@ -363,11 +368,6 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, { mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split"))); } - - if (InventoryWindow::isStorageActive()) - { - mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store"))); - } } // Assume in storage for now // TODO: make this whole system more flexible, if needed diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index abe898b0..6939d1e7 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -377,8 +377,8 @@ void ServerDialog::action(const gcn::ActionEvent &event) else if (event.getId() == "remove") { int index = mServersList->getSelected(); - mServersList->setSelected(0); mServers.erase(mServers.begin() + index); + mServersList->setSelected(0); saveCustomServers(); } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 7826596c..cea27960 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1239,13 +1239,32 @@ void LocalPlayer::setMoney(int value) statusWindow->update(StatusWindow::MONEY); } -void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount) +void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, + unsigned char fail) { - if (!amount) + if (fail) { + const char* msg; + switch (fail) + { + case PICKUP_BAD_ITEM: + msg = N_("Tried to pick up nonexistent item."); break; + case PICKUP_TOO_HEAVY: msg = N_("Item is too heavy."); break; + case PICKUP_TOO_FAR: msg = N_("Item is too far away"); break; + case PICKUP_INV_FULL: msg = N_("Inventory is full."); break; + case PICKUP_STACK_FULL: msg = N_("Stack is too big."); break; + case PICKUP_DROP_STEAL: + msg = N_("Item belongs to someone else."); break; + default: msg = N_("Unknown problem picking up item."); break; + } if (config.getValue("showpickupchat", 1)) { - localChatTab->chatLog(_("Unable to pick up item."), BY_SERVER); + localChatTab->chatLog(_(msg), BY_SERVER); + } + if (mMap && config.getValue("showpickupparticle", 0)) + { + // Show pickup notification + addMessageToQueue(_(msg), UserPalette::PICKUP_INFO); } } else @@ -1263,7 +1282,11 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount) if (mMap && config.getValue("showpickupparticle", 0)) { // Show pickup notification - addMessageToQueue(itemInfo.getName(), UserPalette::PICKUP_INFO); + std::string msg = ""; + if (amount > 1) + msg = strprintf("%i ", amount); + msg += itemInfo.getName(); + addMessageToQueue(msg, UserPalette::PICKUP_INFO); } } } diff --git a/src/localplayer.h b/src/localplayer.h index 7706caeb..8033263b 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -107,6 +107,21 @@ enum }; /** + * Reasons an item can fail to be picked up. + */ +enum +{ + PICKUP_OKAY, + PICKUP_BAD_ITEM, + PICKUP_TOO_HEAVY, + PICKUP_TOO_FAR, + PICKUP_INV_FULL, + PICKUP_STACK_FULL, + PICKUP_DROP_STEAL, +}; + + +/** * The local player character. */ class LocalPlayer : public Player @@ -273,7 +288,8 @@ class LocalPlayer : public Player /** * Shows item pickup notifications. */ - void pickedUp(const ItemInfo &itemInfo, int amount); + void pickedUp(const ItemInfo &itemInfo, int amount, + unsigned char fail); int getHp() const { return mHp; } @@ -55,7 +55,7 @@ #elif defined WIN32 #include "winver.h" #elif defined __APPLE__ -#define PACKAGE_VERSION "0.5.0" +#define PACKAGE_VERSION "0.5.1" #endif #ifdef PACKAGE_VERSION diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 3809399d..5e404e6c 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -230,13 +230,14 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { const ItemInfo &itemInfo = ItemDB::get(itemId); - if (msg.readInt8() > 0) + unsigned char err = msg.readInt8(); + if (err) { - player_node->pickedUp(itemInfo, 0); + player_node->pickedUp(itemInfo, 0, err); } else { - player_node->pickedUp(itemInfo, amount); + player_node->pickedUp(itemInfo, amount, PICKUP_OKAY); Item *item = inventory->getItem(index); diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index b7c4fd72..c866c680 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -277,9 +277,11 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) if (encoding == "base64") { - if (!compression.empty() && compression != "gzip") + if (!compression.empty() && compression != "gzip" + && compression != "zlib") { - logger->log("Warning: only gzip layer compression supported!"); + logger->log("Warning: only gzip or zlib layer " + "compression supported!"); return; } @@ -290,7 +292,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) int len = strlen((const char*)dataChild->content) + 1; unsigned char *charData = new unsigned char[len + 1]; - const char *charStart = (const char*)dataChild->content; + const char *charStart = (const char*) xmlNodeGetContent(dataChild); unsigned char *charIndex = charData; while (*charStart) @@ -313,7 +315,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) if (binData) { - if (compression == "gzip") + if (compression == "gzip" || compression == "zlib") { // Inflate the gzipped layer data unsigned char *inflated; @@ -359,6 +361,39 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) free(binData); } } + else if (encoding == "csv") + { + xmlNodePtr dataChild = childNode->xmlChildrenNode; + if (!dataChild) + continue; + + const char *data = (const char*) xmlNodeGetContent(dataChild); + std::string csv(data); + + size_t pos = 0; + size_t oldPos = 0; + + while (oldPos != csv.npos) + { + pos = csv.find_first_of(",", oldPos); + + const int gid = atoi(csv.substr(oldPos, pos - oldPos).c_str()); + + setTile(map, layer, x, y, gid); + + x++; + if (x == w) + { + x = 0; y++; + + // When we're done, don't crash on too much data + if (y == h) + break; + } + + oldPos = pos + 1; + } + } else { // Read plain XML map file diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index 57809c8b..9175352f 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -6,9 +6,8 @@ * This file has been slighly modified as part of The Mana Client. * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/src/winver.h b/src/winver.h index ea8d8e9c..fa85216e 100644 --- a/src/winver.h +++ b/src/winver.h @@ -1,6 +1,6 @@ /* VERSION DEFINITIONS */ #define VER_MAJOR 0 #define VER_MINOR 5 -#define VER_RELEASE 0 +#define VER_RELEASE 1 #define VER_BUILD 0 -#define PACKAGE_VERSION "0.5.0.0" +#define PACKAGE_VERSION "0.5.1.0" |