summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp4
-rw-r--r--src/gui/buy.cpp6
-rw-r--r--src/gui/skilldialog.cpp17
-rw-r--r--src/gui/skilldialog.h4
-rw-r--r--src/localplayer.cpp3
-rw-r--r--src/log.cpp5
-rw-r--r--src/main.h2
-rw-r--r--src/net/manaserv/generalhandler.cpp2
-rw-r--r--src/net/tmwa/buysellhandler.cpp11
-rw-r--r--src/net/tmwa/generalhandler.cpp2
-rw-r--r--src/net/tmwa/loginhandler.cpp9
-rw-r--r--src/net/tmwa/playerhandler.cpp26
-rw-r--r--src/net/tmwa/specialhandler.cpp3
-rw-r--r--src/resources/spritedef.cpp2
-rw-r--r--src/utils/mkdir.cpp12
-rw-r--r--src/utils/xml.cpp2
-rw-r--r--src/winver.h4
17 files changed, 63 insertions, 51 deletions
diff --git a/src/client.cpp b/src/client.cpp
index d88c32c9..e955a75c 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -489,8 +489,6 @@ int Client::exec()
while (mState != STATE_EXIT)
{
- bool handledEvents = false;
-
if (game)
{
// Let the game handle the events while it is active
@@ -501,8 +499,6 @@ int Client::exec()
// Handle SDL events
while (SDL_PollEvent(&event))
{
- handledEvents = true;
-
switch (event.type)
{
case SDL_QUIT:
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index faa86cc9..299633e9 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -203,11 +203,7 @@ void BuyDialog::action(const gcn::ActionEvent &event)
if (price < 0)
price = 0;
setMoney(mMoney - mAmountItems * price);
-
- // Reset selection
- mAmountItems = 1;
- mSlider->setValue(1);
- mSlider->gcn::Slider::setScale(1, mMaxItems);
+ valueChanged(gcn::SelectionEvent(mShopItemList));
}
}
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 207e3ded..b48df8df 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -54,6 +54,8 @@
#include <set>
#include <string>
+#define SKILLS_FILE "skills.xml"
+
class SkillModel;
class SkillEntry;
@@ -230,8 +232,7 @@ SkillDialog::SkillDialog():
SkillDialog::~SkillDialog()
{
- // Clear gui
- loadSkills("");
+ clearSkills();
}
void SkillDialog::action(const gcn::ActionEvent &event)
@@ -279,7 +280,7 @@ void SkillDialog::update()
}
}
-void SkillDialog::loadSkills(const std::string &file)
+void SkillDialog::clearSkills()
{
// Fixes issues with removing tabs
if (mTabs->getSelectedTabIndex() != -1)
@@ -296,11 +297,13 @@ void SkillDialog::loadSkills(const std::string &file)
delete_all(mSkills);
mSkills.clear();
+}
- if (file.length() == 0)
- return;
+void SkillDialog::loadSkills()
+{
+ clearSkills();
- XML::Document doc(file);
+ XML::Document doc(SKILLS_FILE);
xmlNodePtr root = doc.rootNode();
int setCount = 0;
@@ -311,7 +314,7 @@ void SkillDialog::loadSkills(const std::string &file)
if (!root || !xmlStrEqual(root->name, BAD_CAST "skills"))
{
- logger->log("Error loading skills file: %s", file.c_str());
+ logger->log("Error loading skills file: %s", SKILLS_FILE);
if (Net::getNetworkType() == ServerInfo::TMWATHENA)
{
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 95f8ef25..40fa988d 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -65,7 +65,9 @@ class SkillDialog : public Window, public gcn::ActionListener
*/
void update();
- void loadSkills(const std::string &file);
+ void loadSkills();
+
+ void clearSkills();
void setModifiable(int id, bool modifiable);
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index cea27960..4d0ad17e 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -1090,7 +1090,8 @@ void LocalPlayer::setMaxWeight(int value)
{
mMaxWeight = value;
- inventoryWindow->updateWeight();
+ if (inventoryWindow)
+ inventoryWindow->updateWeight();
}
void LocalPlayer::setAttributeBase(int num, int value, bool notify)
diff --git a/src/log.cpp b/src/log.cpp
index acb9f67c..9fc6aa55 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -62,12 +62,13 @@ void Logger::setLogFile(const std::string &logFilename)
void Logger::log(const char *log_text, ...)
{
- char* buf = new char[1024];
+ const size_t bufSize = 1024;
+ char* buf = new char[bufSize];
va_list ap;
// Use a temporary buffer to fill in the variables
va_start(ap, log_text);
- vsprintf(buf, log_text, ap);
+ vsnprintf(buf, bufSize, log_text, ap);
va_end(ap);
// Get the current system time
diff --git a/src/main.h b/src/main.h
index 341ab1d0..b1db3258 100644
--- a/src/main.h
+++ b/src/main.h
@@ -55,7 +55,7 @@
#elif defined WIN32
#include "winver.h"
#elif defined __APPLE__
-#define PACKAGE_VERSION "0.5.1"
+#define PACKAGE_VERSION "0.5.2"
#endif
#ifdef PACKAGE_VERSION
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 0d3073f1..4f6ade4e 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -166,7 +166,7 @@ void GeneralHandler::flushNetwork()
void GeneralHandler::guiWindowsLoaded()
{
inventoryWindow->setSplitAllowed(true);
- skillDialog->loadSkills("mana-skills.xml");
+ skillDialog->loadSkills();
specialsWindow->loadSpecials("specials.xml");
player_node->setExpNeeded(100);
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index 209f034d..fae63c67 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -112,11 +112,7 @@ void BuySellHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_NPC_BUY_RESPONSE:
- if (msg.readInt8() == 0)
- {
- localChatTab->chatLog(_("Thanks for buying."), BY_SERVER);
- }
- else
+ if (msg.readInt8() != 0)
{
// Reset player money since buy dialog already assumed purchase
// would go fine
@@ -126,11 +122,8 @@ void BuySellHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_NPC_SELL_RESPONSE:
- if (msg.readInt8() == 0)
- localChatTab->chatLog(_("Thanks for selling."), BY_SERVER);
- else
+ if (msg.readInt8() != 0)
localChatTab->chatLog(_("Unable to sell."), BY_SERVER);
-
break;
}
}
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 14f48055..12768807 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -212,7 +212,7 @@ void GeneralHandler::flushNetwork()
void GeneralHandler::guiWindowsLoaded()
{
inventoryWindow->setSplitAllowed(false);
- skillDialog->loadSkills("ea-skills.xml");
+ skillDialog->loadSkills();
statusWindow->addAttribute(STR, _("Strength"), true, "");
statusWindow->addAttribute(AGI, _("Agility"), true, "");
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index e58acb4d..7e654951 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -168,6 +168,9 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
errorMessage = _("You have been permanently banned from "
"the game. Please contact the GM team.");
break;
+ case 5:
+ errorMessage = _("Client too old.");
+ break;
case 6:
errorMessage = strprintf(_("You have been temporarily "
"banned from the game until "
@@ -175,9 +178,15 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
"team via the forums."),
msg.readString(20).c_str());
break;
+ case 7:
+ errorMessage = _("Server overpopulated.");
+ break;
case 9:
errorMessage = _("This user name is already taken.");
break;
+ case 99:
+ errorMessage = _("Username permanently erased.");
+ break;
default:
errorMessage = _("Unknown error.");
break;
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 48e7f4b3..3dab8c34 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -21,6 +21,7 @@
#include "net/tmwa/playerhandler.h"
+#include "configuration.h"
#include "game.h"
#include "localplayer.h"
#include "log.h"
@@ -232,6 +233,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
case SMSG_PLAYER_STAT_UPDATE_1:
{
+ if (!player_node)
+ break;
int type = msg.readInt16();
int value = msg.readInt32();
@@ -337,14 +340,20 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
player_node->setExperience(JOB, msg.readInt32(),
player_node->getExperience(JOB).second);
break;
- case 0x0014: {
- int curGp = player_node->getMoney();
+ case 0x0014:
+ {
+ const int curGp = player_node->getMoney();
player_node->setMoney(msg.readInt32());
- if (player_node->getMoney() > curGp)
+ if (player_node->getMoney() <= curGp)
+ break;
+ std::string money = Units::formatCurrency(
+ player_node->getMoney() - curGp);
+ if (config.getValue("showpickupchat", 1))
localChatTab->chatLog(strprintf(_("You picked up "
- "%s."),
- Units::formatCurrency(player_node->getMoney()
- - curGp).c_str()), BY_SERVER);
+ "%s."), money.c_str()), BY_SERVER);
+ if (config.getValue("showpickupparticle", 1))
+ player_node->addMessageToQueue(money,
+ UserPalette::PICKUP_INFO);
}
break;
case 0x0016:
@@ -591,8 +600,13 @@ void PlayerHandler::increaseSkill(int skillId)
void PlayerHandler::pickUp(FloorItem *floorItem)
{
+ static Uint32 lastTime = 0;
+ if (SDL_GetTicks() < lastTime + 100)
+ return;
+
MessageOut outMsg(CMSG_ITEM_PICKUP);
outMsg.writeInt32(floorItem->getId());
+ lastTime = SDL_GetTicks();
}
void PlayerHandler::setDirection(char direction)
diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp
index c5f5d540..bcf5ba44 100644
--- a/src/net/tmwa/specialhandler.cpp
+++ b/src/net/tmwa/specialhandler.cpp
@@ -107,7 +107,8 @@ void SpecialHandler::handleMessage(Net::MessageIn &msg)
player_node->setAttributeBase(skillId, level);
player_node->setAttributeEffective(skillId, level);
- skillDialog->setModifiable(skillId, up);
+ if (skillDialog)
+ skillDialog->setModifiable(skillId, up);
}
break;
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index c524c43c..9ad8382b 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -260,7 +260,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
if (!img)
{
logger->log("No image at index %d", start + variant_offset);
- continue;
+ break;
}
animation->addFrame(img, delay, offsetX, offsetY);
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 43f5264e..bd9fd2b1 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -36,17 +36,13 @@
#include "mkdir.h"
+/// Create a directory, making leading components first if necessary
int mkdir_r(const char *pathname) {
- char tmp[PATH_MAX];
+ size_t len = strlen(pathname);
+ char tmp[len+2];
char *p;
- if (strlen(pathname) >= PATH_MAX-2)
- return -1;
-
- strncpy(tmp, pathname, sizeof(tmp)-1);
- tmp[PATH_MAX-1] = '\0';
-
- int len=strlen(tmp);
+ strcpy(tmp, pathname);
// terminate the pathname with '/'
if (tmp[len-1] != '/') {
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 9835f88c..1970b062 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -149,7 +149,7 @@ namespace XML
logger->log("Error in unknown xml file on line %d",
error->line);
- logger->log(error->message);
+ logger->log("%s", error->message);
// No need to keep errors around
xmlCtxtResetLastError(error->ctxt);
diff --git a/src/winver.h b/src/winver.h
index fa85216e..89b7004f 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 1
+#define VER_RELEASE 2
#define VER_BUILD 0
-#define PACKAGE_VERSION "0.5.1.0"
+#define PACKAGE_VERSION "0.5.2.0"