summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/SDLMain.m4
-rw-r--r--src/being.cpp36
-rw-r--r--src/configuration.cpp38
-rw-r--r--src/configuration.h11
-rw-r--r--src/game.cpp6
-rw-r--r--src/gui/charcreatedialog.cpp13
-rw-r--r--src/gui/charselectdialog.cpp6
-rw-r--r--src/gui/chat.cpp9
-rw-r--r--src/gui/emotepopup.cpp3
-rw-r--r--src/gui/guildlistbox.cpp3
-rw-r--r--src/gui/guildwindow.cpp4
-rw-r--r--src/gui/inventorywindow.cpp5
-rw-r--r--src/gui/itemamount.cpp2
-rw-r--r--src/gui/itemcontainer.cpp16
-rw-r--r--src/gui/ministatus.cpp6
-rw-r--r--src/gui/outfitwindow.cpp53
-rw-r--r--src/gui/partywindow.cpp3
-rw-r--r--src/gui/playerbox.cpp6
-rw-r--r--src/gui/popupmenu.cpp3
-rw-r--r--src/gui/sell.cpp3
-rw-r--r--src/gui/serverdialog.cpp14
-rw-r--r--src/gui/shop.cpp2
-rw-r--r--src/gui/statuswindow.cpp3
-rw-r--r--src/gui/table.cpp9
-rw-r--r--src/gui/textdialog.cpp3
-rw-r--r--src/gui/trade.cpp13
-rw-r--r--src/gui/viewport.cpp9
-rw-r--r--src/gui/widgets/browserbox.cpp3
-rw-r--r--src/gui/widgets/icon.cpp2
-rw-r--r--src/gui/widgets/slider.cpp3
-rw-r--r--src/gui/widgets/tab.cpp3
-rw-r--r--src/gui/widgets/whispertab.cpp3
-rw-r--r--src/guild.cpp38
-rw-r--r--src/joystick.cpp3
-rw-r--r--src/keyboardconfig.h2
-rw-r--r--src/localplayer.cpp23
-rw-r--r--src/main.cpp65
-rw-r--r--src/map.cpp9
-rw-r--r--src/map.h2
-rw-r--r--src/net/ea/beinghandler.cpp25
-rw-r--r--src/net/ea/charserverhandler.cpp6
-rw-r--r--src/net/ea/generalhandler.cpp3
-rw-r--r--src/net/ea/inventoryhandler.cpp29
-rw-r--r--src/net/ea/loginhandler.cpp6
-rw-r--r--src/net/ea/network.cpp3
-rw-r--r--src/net/ea/partyhandler.cpp6
-rw-r--r--src/net/ea/playerhandler.cpp9
-rw-r--r--src/net/ea/tradehandler.cpp5
-rw-r--r--src/net/manaserv/chathandler.cpp17
-rw-r--r--src/net/manaserv/effecthandler.cpp24
-rw-r--r--src/net/manaserv/gamehandler.cpp3
-rw-r--r--src/net/manaserv/guildhandler.cpp12
-rw-r--r--src/net/manaserv/loginhandler.cpp21
-rw-r--r--src/net/manaserv/network.cpp9
-rw-r--r--src/net/manaserv/playerhandler.cpp6
-rw-r--r--src/net/manaserv/tradehandler.cpp5
-rw-r--r--src/net/messagein.cpp3
-rw-r--r--src/net/net.cpp3
-rw-r--r--src/particlecontainer.cpp6
-rw-r--r--src/particleemitter.cpp25
-rw-r--r--src/particleemitterprop.h8
-rw-r--r--src/playerrelations.cpp20
-rw-r--r--src/resources/image.cpp3
-rw-r--r--src/resources/imagewriter.cpp6
-rw-r--r--src/resources/mapreader.cpp67
-rw-r--r--src/resources/resourcemanager.cpp9
-rw-r--r--src/resources/sdlrescalefacility.cpp105
-rw-r--r--src/resources/spritedef.cpp107
-rw-r--r--src/sound.cpp20
-rw-r--r--src/statuseffect.cpp12
-rw-r--r--src/text.cpp6
-rw-r--r--src/units.cpp13
-rw-r--r--src/utils/base64.cpp39
-rw-r--r--src/utils/xml.cpp16
74 files changed, 622 insertions, 474 deletions
diff --git a/src/SDLMain.m b/src/SDLMain.m
index 3d02719c..d7e9273b 100644
--- a/src/SDLMain.m
+++ b/src/SDLMain.m
@@ -364,7 +364,9 @@ int main (int argc, char **argv)
gArgv[1] = NULL;
gArgc = 1;
gFinderLaunch = YES;
- } else {
+ }
+ else
+ {
int i;
gArgc = argc;
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
diff --git a/src/being.cpp b/src/being.cpp
index 6e8449a4..613e692a 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -181,7 +181,7 @@ void Being::setDestination(int dstX, int dstY)
// And add interpolation between the starting and ending offsets
Path::iterator it = thisPath.begin();
int i = 0;
- while(it != thisPath.end())
+ while (it != thisPath.end())
{
it->x = (it->x * 32) + startX + (changeX * i);
it->y = (it->y * 32) + startY + (changeY * i);
@@ -624,10 +624,12 @@ void Being::logic()
(*it)->update(tick_time * MILLISECONDS_IN_A_TICK);
// Restart status/particle effects, if needed
- if (mMustResetParticles) {
+ if (mMustResetParticles)
+ {
mMustResetParticles = false;
for (std::set<int>::iterator it = mStatusEffects.begin();
- it != mStatusEffects.end(); it++) {
+ it != mStatusEffects.end(); it++)
+ {
const StatusEffect *effect = StatusEffect::getStatusEffect(*it, true);
if (effect && effect->particleEffectIsPersistent())
updateStatusEffect(*it, true);
@@ -709,7 +711,8 @@ void Being::drawSpeech(int offsetX, int offsetY)
{
mSpeechBubble->setVisible(false);
- if (! mText) {
+ if (! mText)
+ {
mText = new Text(mSpeech,
mPx, mPy - getHeight(),
gcn::Graphics::CENTER,
@@ -730,7 +733,8 @@ void Being::drawSpeech(int offsetX, int offsetY)
void Being::setStatusEffectBlock(int offset, Uint16 newEffects)
{
- for (int i = 0; i < STATUS_EFFECTS; i++) {
+ for (int i = 0; i < STATUS_EFFECTS; i++)
+ {
int index = StatusEffect::blockEffectIndexToEffectIndex(offset + i);
if (index != -1)
@@ -752,8 +756,11 @@ void Being::handleStatusEffect(StatusEffect *effect, int effectId)
Particle *particle = effect->getParticle();
if (effectId >= 0)
+ {
mStatusParticleEffects.setLocally(effectId, particle);
- else {
+ }
+ else
+ {
mStunParticleEffects.clearLocally();
if (particle)
mStunParticleEffects.addLocally(particle);
@@ -775,7 +782,8 @@ void Being::setStatusEffect(int index, bool active)
{
const bool wasActive = mStatusEffects.find(index) != mStatusEffects.end();
- if (active != wasActive) {
+ if (active != wasActive)
+ {
updateStatusEffect(index, active);
if (active)
mStatusEffects.insert(index);
@@ -883,7 +891,8 @@ static EffectDescription *getEffectDescription(int effectId)
EffectDescription *EffectDescription =
getEffectDescription(node, &id);
effects[id] = EffectDescription;
- } else if (xmlStrEqual(node->name, BAD_CAST "default"))
+ }
+ else if (xmlStrEqual(node->name, BAD_CAST "default"))
{
EffectDescription *EffectDescription =
getEffectDescription(node, &id);
@@ -913,21 +922,22 @@ void Being::internalTriggerEffect(int effectId, bool sfx, bool gfx)
EffectDescription *ed = getEffectDescription(effectId);
- if (!ed) {
+ if (!ed)
+ {
logger->log("Unknown special effect and no default recorded");
return;
}
- if (gfx && !ed->mGFXEffect.empty()) {
+ if (gfx && !ed->mGFXEffect.empty())
+ {
Particle *selfFX;
selfFX = particleEngine->addEffect(ed->mGFXEffect, 0, 0);
controlParticle(selfFX);
}
- if (sfx && !ed->mSFXEffect.empty()) {
+ if (sfx && !ed->mSFXEffect.empty())
sound.playSfx(ed->mSFXEffect);
- }
}
void Being::updateCoords()
@@ -950,7 +960,7 @@ void Being::showName()
mDispName = 0;
std::string mDisplayName(mName);
- if(getType() == MONSTER)
+ if (getType() == MONSTER)
{
if (config.getValue("showMonstersTakedDamage", false))
{
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 0f73e2fb..cb5d9002 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -38,7 +38,8 @@ void Configuration::setValue(const std::string &key, const std::string &value)
// Notify listeners
ListenerMapIterator list = mListenerMap.find(key);
- if (list != mListenerMap.end()) {
+ if (list != mListenerMap.end())
+ {
Listeners listeners = list->second;
for (ListenerIterator i = listeners.begin(); i != listeners.end(); i++)
{
@@ -102,7 +103,8 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
for_each_xml_child_node(node, parent_node)
{
- if (xmlStrEqual(node->name, BAD_CAST "list")) {
+ if (xmlStrEqual(node->name, BAD_CAST "list"))
+ {
// list option handling
std::string name = XML::getProperty(node, "name", std::string());
@@ -110,7 +112,8 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
for_each_xml_child_node(subnode, node)
{
if (xmlStrEqual(subnode->name, BAD_CAST name.c_str())
- && subnode->type == XML_ELEMENT_NODE) {
+ && subnode->type == XML_ELEMENT_NODE)
+ {
ConfigurationObject *cobj = new ConfigurationObject;
cobj->initFromXML(subnode); // recurse
@@ -119,7 +122,9 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
}
}
- } else if (xmlStrEqual(node->name, BAD_CAST "option")) {
+ }
+ else if (xmlStrEqual(node->name, BAD_CAST "option"))
+ {
// single option handling
std::string name = XML::getProperty(node, "name", std::string());
@@ -137,12 +142,10 @@ void Configuration::init(const std::string &filename)
// Do not attempt to read config from non-existant file
FILE *testFile = fopen(filename.c_str(), "r");
- if (!testFile) {
+ if (!testFile)
return;
- }
- else {
+ else
fclose(testFile);
- }
xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
@@ -150,7 +153,8 @@ void Configuration::init(const std::string &filename)
xmlNodePtr rootNode = xmlDocGetRootElement(doc);
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration")) {
+ if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration"))
+ {
logger->log("Warning: No configuration file (%s)", filename.c_str());
xmlFreeDoc(doc);
return;
@@ -175,7 +179,8 @@ void ConfigurationObject::writeToXML(xmlTextWriterPtr writer)
}
for (std::map<std::string, ConfigurationList>::const_iterator
- it = mContainerOptions.begin(); it != mContainerOptions.end(); it++) {
+ it = mContainerOptions.begin(); it != mContainerOptions.end(); it++)
+ {
const char *name = it->first.c_str();
xmlTextWriterStartElement(writer, BAD_CAST "list");
@@ -183,8 +188,8 @@ void ConfigurationObject::writeToXML(xmlTextWriterPtr writer)
// recurse on all elements
for (ConfigurationList::const_iterator
- elt_it = it->second.begin(); elt_it != it->second.end(); elt_it++) {
-
+ elt_it = it->second.begin(); elt_it != it->second.end(); elt_it++)
+ {
xmlTextWriterStartElement(writer, BAD_CAST name);
(*elt_it)->writeToXML(writer);
xmlTextWriterEndElement(writer);
@@ -198,18 +203,21 @@ void Configuration::write()
{
// Do not attempt to write to file that cannot be opened for writing
FILE *testFile = fopen(mConfigPath.c_str(), "w");
- if (!testFile) {
+ if (!testFile)
+ {
logger->log("Configuration::write() couldn't open %s for writing",
mConfigPath.c_str());
return;
}
- else {
+ else
+ {
fclose(testFile);
}
xmlTextWriterPtr writer = xmlNewTextWriterFilename(mConfigPath.c_str(), 0);
- if (!writer) {
+ if (!writer)
+ {
logger->log("Configuration::write() error while creating writer");
return;
}
diff --git a/src/configuration.h b/src/configuration.h
index c6ff1186..b9720b94 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -128,14 +128,19 @@ class ConfigurationObject
deleteList(name);
ConfigurationList *list = &(mContainerOptions[name]);
- for (IT it = begin; it != end; it++) {
+ for (IT it = begin; it != end; it++)
+ {
ConfigurationObject *wrobj = manager->writeConfigItem(*it, nextobj);
- if (wrobj) { // wrote something
+ if (wrobj)
+ { // wrote something
assert (wrobj == nextobj);
nextobj = new ConfigurationObject;
list->push_back(wrobj);
- } else
+ }
+ else
+ {
nextobj->clear(); // you never know...
+ }
}
delete nextobj;
diff --git a/src/game.cpp b/src/game.cpp
index fc374025..3ef07dca 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1015,7 +1015,11 @@ void Game::handleInput()
player_node->setTarget(target);
mLastTarget = currentTarget;
}
- } else mLastTarget = Being::UNKNOWN; // Reset last target
+ }
+ else
+ {
+ mLastTarget = Being::UNKNOWN; // Reset last target
+ }
// Talk to the nearest NPC if 't' pressed
if ( keyboard.isKeyActive(keyboard.KEY_TALK) )
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 86a8bf2b..bd2f095b 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -201,13 +201,18 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
mHairStyle--;
updateHair();
}
- else if (event.getId() == "statslider") {
+ else if (event.getId() == "statslider")
+ {
updateSliders();
}
- else if (event.getId() == "gender"){
- if (mMale->isSelected()) {
+ else if (event.getId() == "gender")
+ {
+ if (mMale->isSelected())
+ {
mPlayer->setGender(GENDER_MALE);
- } else {
+ }
+ else
+ {
mPlayer->setGender(GENDER_FEMALE);
}
}
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 8dc292ab..04f2d2b6 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -142,7 +142,8 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo,
place(0, 0, mAccountNameLabel, 2);
place(0, 1, mSwitchLoginButton);
- if (optionalActions & Net::LoginHandler::Unregister) {
+ if (optionalActions & Net::LoginHandler::Unregister)
+ {
gcn::Button *unregisterButton = new Button(_("Unregister"),
"unregister", this);
place(3, 1, unregisterButton);
@@ -150,7 +151,8 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo,
place(0, 2, mChangePasswordButton);
- if (optionalActions & Net::LoginHandler::ChangeEmail) {
+ if (optionalActions & Net::LoginHandler::ChangeEmail)
+ {
gcn::Button *changeEmailButton = new Button(_("Change Email"),
"change_email", this);
place(3, 2, changeEmailButton);
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index c9defe33..d7b82de1 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -133,9 +133,8 @@ void ChatWindow::logic()
Window::logic();
Tab *tab = getFocused();
- if (tab != mCurrentTab) {
+ if (tab != mCurrentTab)
mCurrentTab = tab;
- }
}
ChatTab *ChatWindow::getFocused() const
@@ -336,7 +335,7 @@ void ChatWindow::mousePressed(gcn::MouseEvent &event)
{
Window::mousePressed(event);
- if(event.isConsumed())
+ if (event.isConsumed())
return;
mMoved = event.getY() <= mCurrentTab->getHeight();
@@ -349,10 +348,10 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
{
Window::mouseDragged(event);
- if(event.isConsumed())
+ if (event.isConsumed())
return;
- if(isMovable() && mMoved)
+ if (isMovable() && mMoved)
{
int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index 707f4bfa..ce664cae 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -110,7 +110,8 @@ void EmotePopup::mousePressed(gcn::MouseEvent &event)
return;
const int index = getIndexAt(event.getX(), event.getY());
- if (index != -1) {
+ if (index != -1)
+ {
setSelectedEmoteIndex(index);
emoteShortcut->setEmoteSelected(index + 1);
}
diff --git a/src/gui/guildlistbox.cpp b/src/gui/guildlistbox.cpp
index 89d311f1..0081c78c 100644
--- a/src/gui/guildlistbox.cpp
+++ b/src/gui/guildlistbox.cpp
@@ -48,7 +48,8 @@ void GuildListBox::draw(gcn::Graphics *gcnGraphics)
int fontHeight = getFont()->getHeight();
// Draw rectangle below the selected list element
- if (mSelected >= 0) {
+ if (mSelected >= 0)
+ {
graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected,
getWidth(), fontHeight));
}
diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp
index 1868de6a..00f59cb6 100644
--- a/src/gui/guildwindow.cpp
+++ b/src/gui/guildwindow.cpp
@@ -141,7 +141,7 @@ void GuildWindow::action(const gcn::ActionEvent &event)
else if (eventId == "CREATE_GUILD_OK")
{
std::string name = guildDialog->getText();
- if(name.size() > 16)
+ if (name.size() > 16)
{
// TODO : State too many characters in input.
return;
@@ -205,7 +205,7 @@ void GuildWindow::updateTab()
void GuildWindow::setTab(const std::string &guildName)
{
// Only enable invite button if user has rights
- if(player_node->checkInviteRights(guildName))
+ if (player_node->checkInviteRights(guildName))
{
mGuildButton[1]->setEnabled(true);
}
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index e593bc1b..6837aa38 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -295,10 +295,7 @@ void InventoryWindow::updateButtons()
mDropButton->setCaption(_("Drop"));
if (Net::getInventoryHandler()->canSplit(selectedItem))
- {
mSplitButton->setEnabled(true);
- }
- else {
+ else
mSplitButton->setEnabled(false);
- }
}
diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp
index e0162eda..4bc53892 100644
--- a/src/gui/itemamount.cpp
+++ b/src/gui/itemamount.cpp
@@ -156,7 +156,7 @@ ItemAmountWindow::~ItemAmountWindow()
// Show ItemTooltip
void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
{
- if(event.getSource() == mItemIcon)
+ if (event.getSource() == mItemIcon)
{
mItemPopup->setItem(mItem->getInfo());
mItemPopup->view(viewport->getMouseX(), viewport->getMouseY());
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index c8d3ca7d..ff431c31 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -120,12 +120,14 @@ void ItemContainer::draw(gcn::Graphics *graphics)
{
if (itemIndex == mSelectedIndex)
{
- if (mSelectionStatus == SEL_DRAGGING) {
+ if (mSelectionStatus == SEL_DRAGGING)
+ {
// Reposition the coords to that of the cursor.
itemX = mDragPosX - (BOX_WIDTH / 2);
itemY = mDragPosY - (BOX_HEIGHT / 2);
}
- else {
+ else
+ {
// Draw selection border image.
g->drawImage(mSelImg, itemX, itemY);
}
@@ -395,12 +397,10 @@ void ItemContainer::moveHighlight(Direction direction)
{
if (mHighlightedIndex == -1)
{
- if (mSelectedIndex != -1) {
+ if (mSelectedIndex != -1)
mHighlightedIndex = mSelectedIndex;
- }
- else {
+ else
mHighlightedIndex = 0;
- }
return;
}
@@ -408,9 +408,7 @@ void ItemContainer::moveHighlight(Direction direction)
{
case Left:
if (mHighlightedIndex % mGridColumns == 0)
- {
mHighlightedIndex += mGridColumns;
- }
mHighlightedIndex--;
break;
case Right:
@@ -423,9 +421,7 @@ void ItemContainer::moveHighlight(Direction direction)
break;
case Up:
if (mHighlightedIndex / mGridColumns == 0)
- {
mHighlightedIndex += (mGridColumns * mGridRows);
- }
mHighlightedIndex -= mGridColumns;
break;
case Down:
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 51dbdebc..7083147a 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -82,8 +82,10 @@ void MiniStatusWindow::drawIcons(Graphics *graphics)
{
// Draw icons
int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4;
- for (unsigned int i = 0; i < mIcons.size(); i++) {
- if (mIcons[i]) {
+ for (unsigned int i = 0; i < mIcons.size(); i++)
+ {
+ if (mIcons[i])
+ {
mIcons[i]->draw(graphics, icon_x, 3);
icon_x += 2 + mIcons[i]->getWidth();
}
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 6cb23286..ba060504 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -102,9 +102,8 @@ void OutfitWindow::load()
std::vector<int> tokens;
- while (ss >> buf) {
+ while (ss >> buf)
tokens.push_back(atoi(buf.c_str()));
- }
for (int i = 0; i < (int)tokens.size(); i++)
{
@@ -134,19 +133,21 @@ void OutfitWindow::action(const gcn::ActionEvent &event)
{
if (event.getId() == "next")
{
- if (mCurrentOutfit < (OUTFITS_COUNT - 1)) {
+ if (mCurrentOutfit < (OUTFITS_COUNT - 1))
mCurrentOutfit++;
- } else {
+ else
mCurrentOutfit = 0;
- }
mCurrentLabel->setCaption(strprintf(_("Outfit: %d"), mCurrentOutfit + 1));
mUnequipCheck->setSelected(mItemsUnequip[mCurrentOutfit]);
}
else if (event.getId() == "previous")
{
- if (mCurrentOutfit > 0) {
+ if (mCurrentOutfit > 0)
+ {
mCurrentOutfit--;
- } else {
+ }
+ else
+ {
mCurrentOutfit = OUTFITS_COUNT - 1;
}
mCurrentLabel->setCaption(strprintf(_("Outfit: %d"), mCurrentOutfit + 1));
@@ -166,9 +167,8 @@ void OutfitWindow::wearOutfit(int outfit)
item = player_node->getInventory()->findItem(mItems[outfit][i]);
if (item && !item->isEquipped() && item->getQuantity())
{
- if (item->isEquipment()) {
+ if (item->isEquipment())
Net::getInventoryHandler()->equipItem(item);
- }
}
}
@@ -236,12 +236,13 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
{
Window::mouseDragged(event);
- if (event.getButton() == gcn::MouseEvent::LEFT) {
- if (!mItemMoved && mItemClicked) {
+ if (event.getButton() == gcn::MouseEvent::LEFT)
+ {
+ if (!mItemMoved && mItemClicked)
+ {
const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1) {
+ if (index == -1)
return;
- }
const int itemId = mItems[mCurrentOutfit][index];
if (itemId < 0)
return;
@@ -252,7 +253,8 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
mItems[mCurrentOutfit][index] = -1;
}
}
- if (mItemMoved) {
+ if (mItemMoved)
+ {
mCursorPosX = event.getX();
mCursorPosY = event.getY();
}
@@ -263,16 +265,17 @@ void OutfitWindow::mousePressed(gcn::MouseEvent &event)
{
Window::mousePressed(event);
const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1) {
+ if (index == -1)
return;
- }
// Stores the selected item if there is one.
- if (isItemSelected()) {
+ if (isItemSelected())
+ {
mItems[mCurrentOutfit][index] = mItemSelected;
mItemSelected = -1;
}
- else if (mItems[mCurrentOutfit][index]) {
+ else if (mItems[mCurrentOutfit][index])
+ {
mItemClicked = true;
}
}
@@ -287,17 +290,18 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
mItemSelected = -1;
}
const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1) {
+ if (index == -1)
+ {
mItemMoved = NULL;
return;
}
- if (mItemMoved) {
+ if (mItemMoved)
+ {
mItems[mCurrentOutfit][index] = mItemMoved->getId();
mItemMoved = NULL;
}
- if (mItemClicked) {
+ if (mItemClicked)
mItemClicked = false;
- }
}
}
@@ -305,15 +309,12 @@ int OutfitWindow::getIndexFromGrid(int pointX, int pointY) const
{
const gcn::Rectangle tRect = gcn::Rectangle(
10, 25, 10 + mGridWidth * mBoxWidth, 25 + mGridHeight * mBoxHeight);
- if (!tRect.isPointInRect(pointX, pointY)) {
+ if (!tRect.isPointInRect(pointX, pointY))
return -1;
- }
const int index = (((pointY - 25) / mBoxHeight) * mGridWidth) +
(pointX - 10) / mBoxWidth;
if (index >= OUTFIT_ITEM_COUNT)
- {
return -1;
- }
return index;
}
diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp
index 67f1d4c0..da8189d6 100644
--- a/src/gui/partywindow.cpp
+++ b/src/gui/partywindow.cpp
@@ -46,7 +46,8 @@ PartyMember::~PartyMember()
void PartyMember::setLeader(bool leader)
{
- if (mLeader != leader) {
+ if (mLeader != leader)
+ {
mLeader = leader;
mAvatar->setDisplayBold(leader);
}
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index 70af6690..c1d6f5e5 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -49,8 +49,10 @@ PlayerBox::PlayerBox(const Player *player):
int bggridy[4] = {0, 3, 28, 31};
int a = 0, x, y;
- for (y = 0; y < 3; y++) {
- for (x = 0; x < 3; x++) {
+ for (y = 0; y < 3; y++)
+ {
+ for (x = 0; x < 3; x++)
+ {
background.grid[a] = textbox->getSubImage(
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 3450f4a5..ffb7c028 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -94,7 +94,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
mBrowserBox->addRow("##3---");
- switch (player_relations.getRelation(name)) {
+ switch (player_relations.getRelation(name))
+ {
case PlayerRelation::NEUTRAL:
mBrowserBox->addRow(strprintf("@@friend|%s@@",
strprintf(_("Befriend %s"),
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index d434408b..92ad1dbd 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -188,7 +188,8 @@ void SellDialog::action(const gcn::ActionEvent &event)
mPlayerMoney +=
mAmountItems * mShopItems->at(selectedItem)->getPrice();
mMaxItems -= mAmountItems;
- while (mAmountItems > 0) {
+ while (mAmountItems > 0)
+ {
// This order is important, item->getCurrentInvIndex() would return
// the inventory index of the next Duplicate otherwise.
itemIndex = item->getCurrentInvIndex();
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index bbbf132d..9dbc1025 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -159,14 +159,16 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
setFieldsReadOnly(true);
setVisible(true);
- if (mServerNameField->getText().empty()) {
+ if (mServerNameField->getText().empty())
+ {
mServerNameField->requestFocus();
- } else {
- if (mPortField->getText().empty()) {
+ }
+ else
+ {
+ if (mPortField->getText().empty())
mPortField->requestFocus();
- } else {
+ else
mConnectButton->requestFocus();
- }
}
downloadServerList();
@@ -175,9 +177,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
ServerDialog::~ServerDialog()
{
if (mDownload)
- {
mDownload->cancel();
- }
delete mServersListModel;
}
diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp
index b72be694..513e50cc 100644
--- a/src/gui/shop.cpp
+++ b/src/gui/shop.cpp
@@ -90,7 +90,7 @@ ShopItem *ShopItems::findItem(int id)
ShopItem *item;
std::vector<ShopItem*>::iterator it;
- for(it = mShopItems.begin(); it != mShopItems.end(); it++)
+ for (it = mShopItems.begin(); it != mShopItems.end(); it++)
{
item = *(it);
if (item->getId() == id)
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 4db8c751..cda83e82 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -543,7 +543,8 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
int newmod = player_node->getAttributeEffective(mId) - 1;
player_node->setAttributeEffective(mId, newmod);
Net::getPlayerHandler()->decreaseAttribute(mId);
- } else if (event.getSource() == mInc)
+ }
+ else if (event.getSource() == mInc)
{
int newpoints = player_node->getCharacterPoints() - 1;
player_node->setCharacterPoints(newpoints);
diff --git a/src/gui/table.cpp b/src/gui/table.cpp
index 995c393c..e2808992 100644
--- a/src/gui/table.cpp
+++ b/src/gui/table.cpp
@@ -533,9 +533,12 @@ void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler)
{
gcn::Widget::_setFocusHandler(focusHandler);
- if (mModel) {
- for (int r = 0; r < mModel->getRows(); ++r) {
- for (int c = 0; c < mModel->getColumns(); ++c) {
+ if (mModel)
+ {
+ for (int r = 0; r < mModel->getRows(); ++r)
+ {
+ for (int c = 0; c < mModel->getColumns(); ++c)
+ {
gcn::Widget *w = mModel->getElementAt(r, c);
if (w)
w->_setFocusHandler(focusHandler);
diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp
index 8430e974..326954e2 100644
--- a/src/gui/textdialog.cpp
+++ b/src/gui/textdialog.cpp
@@ -57,7 +57,8 @@ TextDialog::TextDialog(const std::string &title, const std::string &msg,
add(mOkButton);
add(cancelButton);
- if (getParent()) {
+ if (getParent())
+ {
setLocationRelativeTo(getParent());
getParent()->moveToTop(this);
}
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 5a659da9..b942b565 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -256,9 +256,9 @@ void TradeWindow::action(const gcn::ActionEvent &event)
if (event.getId() == "add")
{
- if(mStatus != PREPARING)
+ if (mStatus != PREPARING)
return;
-
+
if (!inventoryWindow->isVisible())
{
inventoryWindow->setVisible(true);
@@ -309,14 +309,15 @@ void TradeWindow::action(const gcn::ActionEvent &event)
}
else if (event.getId() == "money")
{
- if(mStatus != PREPARING)
+ if (mStatus != PREPARING)
return;
-
+
int v = atoi(mMoneyField->getText().c_str());
int curMoney = player_node->getMoney();
- if(v > curMoney)
+ if (v > curMoney)
{
- localChatTab->chatLog(_("You don't have enough money."), BY_SERVER);
+ localChatTab->chatLog(_("You don't have enough money."),
+ BY_SERVER);
v = curMoney;
}
Net::getTradeHandler()->setMoney(v);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index dc4b9721..e8a0e260 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -192,7 +192,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
{
mMap->draw(graphics, (int) mPixelViewX, (int) mPixelViewY);
- if (mShowDebugPath) {
+ if (mShowDebugPath)
+ {
mMap->drawCollision(graphics,
(int) mPixelViewX,
(int) mPixelViewY,
@@ -376,7 +377,8 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
break;
}
// Picks up a item if we clicked on one
- } else if ((item = floorItemManager->findByCoordinates(tilex, tiley)))
+ }
+ else if ((item = floorItemManager->findByCoordinates(tilex, tiley)))
{
player_node->pickUp(item);
}
@@ -452,9 +454,8 @@ void Viewport::optionChanged(const std::string &name)
mScrollLaziness = (int) config.getValue("ScrollLaziness", 32);
mScrollRadius = (int) config.getValue("ScrollRadius", 32);
- if (name == "visiblenames") {
+ if (name == "visiblenames")
mVisibleNames = config.getValue("visiblenames", 1);
- }
}
void Viewport::mouseMoved(gcn::MouseEvent &event)
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 91098074..d189947d 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -233,9 +233,8 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event)
LinkIterator i = find_if(mLinks.begin(), mLinks.end(),
MouseOverLink(event.getX(), event.getY()));
- if (i != mLinks.end()) {
+ if (i != mLinks.end())
mLinkHandler->handleLink(i->link);
- }
}
void BrowserBox::mouseMoved(gcn::MouseEvent &event)
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 0e29f603..21a33e10 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -48,7 +48,7 @@ void Icon::setImage(Image *image)
void Icon::draw(gcn::Graphics *g)
{
- if(mImage)
+ if (mImage)
{
Graphics *graphics = static_cast<Graphics*>(g);
const int x = (getWidth() - mImage->getWidth()) / 2;
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 1e9fe4f5..66fe780d 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -175,7 +175,8 @@ void Slider::draw(gcn::Graphics *graphics)
x += w;
static_cast<Graphics*>(graphics)->drawImage(hEnd, x, y);
- } else
+ }
+ else
{
static_cast<Graphics*>(graphics)->drawImage(hStartHi, x, y);
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 99a95d96..a49c4f12 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -150,7 +150,8 @@ void Tab::draw(gcn::Graphics *graphics)
mode = TAB_SELECTED;
// if tab is selected, it doesnt need to highlight activity
mHighlighted = false;
- } else if (mHasMouse)
+ }
+ else if (mHasMouse)
{
mode = TAB_HIGHLIGHTED;
}
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 537aa2cc..51ae6e8f 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -46,7 +46,8 @@ WhisperTab::~WhisperTab()
void WhisperTab::handleInput(const std::string &msg)
{
- if (msg.empty()) {
+ if (msg.empty())
+ {
chatLog(_("Cannot send empty chat!"), BY_SERVER, false);
return;
}
diff --git a/src/guild.cpp b/src/guild.cpp
index c06f2176..f44ecccf 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -51,9 +51,7 @@ Guild::Guild(short id):
void Guild::addMember(GuildMember *member)
{
if (member->mGuild > 0 && member->mGuild != this)
- {
throw "Member in another guild!";
- }
if (!isMember(member))
{
@@ -66,12 +64,10 @@ GuildMember *Guild::getMember(int id)
{
MemberList::iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while(itr != itr_end)
+ while (itr != itr_end)
{
- if((*itr)->mId == id)
- {
+ if ((*itr)->mId == id)
return (*itr);
- }
++itr;
}
@@ -82,9 +78,9 @@ GuildMember *Guild::getMember(std::string name)
{
MemberList::iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while(itr != itr_end)
+ while (itr != itr_end)
{
- if((*itr)->mName == name)
+ if ((*itr)->mName == name)
{
return (*itr);
}
@@ -98,9 +94,9 @@ void Guild::removeMember(GuildMember *member)
{
MemberList::iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while(itr != itr_end)
+ while (itr != itr_end)
{
- if((*itr)->mId == member->mId && (*itr)->mName == member->mName)
+ if ((*itr)->mId == member->mId && (*itr)->mName == member->mName)
{
mMembers.erase(itr);
}
@@ -112,12 +108,10 @@ void Guild::removeMember(int id)
{
MemberList::iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while(itr != itr_end)
+ while (itr != itr_end)
{
- if((*itr)->mId == id)
- {
+ if ((*itr)->mId == id)
mMembers.erase(itr);
- }
++itr;
}
}
@@ -126,9 +120,9 @@ void Guild::removeMember(const std::string &name)
{
MemberList::iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while(itr != itr_end)
+ while (itr != itr_end)
{
- if((*itr)->mName == name)
+ if ((*itr)->mName == name)
{
mMembers.erase(itr);
}
@@ -140,22 +134,16 @@ std::string Guild::getElementAt(int index)
{
GuildMember *m = mMembers[index];
if (m->mOnline)
- {
return "* " + m->mName;
- }
else
- {
return m->mName;
- }
}
void Guild::setRights(short rights)
{
// to invite, rights must be greater than 0
if (rights > 0)
- {
mCanInviteUsers = true;
- }
}
bool Guild::isMember(GuildMember *member) const
@@ -168,9 +156,7 @@ bool Guild::isMember(GuildMember *member) const
while (itr != itr_end)
{
if ((*itr)->mId == member->mId && (*itr)->mName == member->mName)
- {
return true;
- }
++itr;
}
@@ -184,9 +170,7 @@ bool Guild::isMember(int id) const
while (itr != itr_end)
{
if ((*itr)->mId == id)
- {
return true;
- }
++itr;
}
@@ -200,9 +184,7 @@ bool Guild::isMember(const std::string &name) const
while (itr != itr_end)
{
if ((*itr)->mName == name)
- {
return true;
- }
++itr;
}
diff --git a/src/joystick.cpp b/src/joystick.cpp
index b72c9103..1eb0f797 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -78,7 +78,8 @@ void Joystick::update()
mDirection = 0;
// When calibrating, don't bother the outside with our state
- if (mCalibrating) {
+ if (mCalibrating)
+ {
doCalibration();
return;
};
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index c6d0b723..c14eec58 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -139,7 +139,7 @@ class KeyboardConfig
*/
void refreshActiveKeys();
- std::string getBindError()
+ std::string getBindError() const
{ return mBindError; }
/**
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 95739329..58abf75f 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -640,7 +640,8 @@ void LocalPlayer::startWalking(unsigned char dir)
void LocalPlayer::stopWalking(bool sendToServer)
{
- if (mAction == WALK && mWalkingDir) {
+ if (mAction == WALK && mWalkingDir)
+ {
mWalkingDir = 0;
#ifdef MANASERV_SUPPORT
mLocalWalkTime = 0;
@@ -1062,25 +1063,33 @@ void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId)
AnimatedSprite *sprite = effect->getIcon();
- if (!sprite) {
+ if (!sprite)
+ {
// delete sprite, if necessary
for (unsigned int i = 0; i < mStatusEffectIcons.size();)
- if (mStatusEffectIcons[i] == effectId) {
+ if (mStatusEffectIcons[i] == effectId)
+ {
mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i);
miniStatusWindow->eraseIcon(i);
- } else i++;
- } else {
+ }
+ else
+ i++;
+ }
+ else
+ {
// replace sprite or append
bool found = false;
for (unsigned int i = 0; i < mStatusEffectIcons.size(); i++)
- if (mStatusEffectIcons[i] == effectId) {
+ if (mStatusEffectIcons[i] == effectId)
+ {
miniStatusWindow->setIcon(i, sprite);
found = true;
break;
}
- if (!found) { // add new
+ if (!found)
+ { // add new
int offset = mStatusEffectIcons.size();
miniStatusWindow->setIcon(offset, sprite);
mStatusEffectIcons.push_back(effectId);
diff --git a/src/main.cpp b/src/main.cpp
index 3c3d3232..9789ee46 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -340,13 +340,17 @@ static void initConfiguration(const Options &options)
configFile = fopen(configPath.c_str(), "r");
// If we can't read it, it doesn't exist !
- if (configFile == NULL) {
+ if (configFile == NULL)
+ {
// We reopen the file in write mode and we create it
configFile = fopen(configPath.c_str(), "wt");
}
- if (configFile == NULL) {
+ if (configFile == NULL)
+ {
logger->log("Can't create %s. Using defaults.", configPath.c_str());
- } else {
+ }
+ else
+ {
fclose(configFile);
config.init(configPath);
}
@@ -359,7 +363,8 @@ static void initEngine(const Options &options)
{
// Initialize SDL
logger->log("Initializing SDL...");
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
+ {
logger->error(strprintf("Could not initialize SDL: %s",
SDL_GetError()));
}
@@ -373,7 +378,8 @@ static void initEngine(const Options &options)
ResourceManager *resman = ResourceManager::getInstance();
- if (!resman->setWriteDir(homeDir)) {
+ if (!resman->setWriteDir(homeDir))
+ {
logger->error(strprintf("%s couldn't be set as home directory! "
"Exiting.", homeDir.c_str()));
}
@@ -382,9 +388,8 @@ static void initEngine(const Options &options)
resman->addToSearchPath(homeDir, false);
// Add the main data directories to our PhysicsFS search path
- if (!options.dataPath.empty()) {
+ if (!options.dataPath.empty())
resman->addToSearchPath(options.dataPath, true);
- }
resman->addToSearchPath("data", true);
#if defined __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
@@ -665,11 +670,10 @@ static void accountLogin(LoginData *loginData)
Net::getCharHandler()->setCharInfo(&charInfo);
// Send login infos
- if (loginData->registerLogin) {
+ if (loginData->registerLogin)
Net::getLoginHandler()->registerAccount(loginData);
- } else {
+ else
Net::getLoginHandler()->loginAccount(loginData);
- }
// Clear the password, avoids auto login when returning to login
loginData->password = "";
@@ -677,9 +681,7 @@ static void accountLogin(LoginData *loginData)
// TODO This is not the best place to save the config, but at least better
// than the login gui window
if (loginData->remember)
- {
config.setValue("username", loginData->username);
- }
config.setValue("remember", loginData->remember);
}
@@ -783,17 +785,18 @@ int main(int argc, char *argv[])
loginData.remember = config.getValue("remember", 0);
loginData.registerLogin = false;
- if (currentServer.hostname.empty()) {
+ if (currentServer.hostname.empty())
+ {
currentServer.hostname = branding.getValue("defaultServer",
"server.themanaworld.org").c_str();
}
- if (options.serverPort == 0) {
+ if (options.serverPort == 0)
+ {
currentServer.port = (short) branding.getValue("defaultPort",
DEFAULT_PORT);
}
- if (loginData.username.empty() && loginData.remember) {
+ if (loginData.username.empty() && loginData.remember)
loginData.username = config.getValue("username", "");
- }
if (state != STATE_ERROR)
state = STATE_CHOOSE_SERVER;
@@ -899,31 +902,35 @@ int main(int argc, char *argv[])
oldstate = state;
// Get rid of the dialog of the previous state
- if (currentDialog) {
+ if (currentDialog)
+ {
delete currentDialog;
currentDialog = NULL;
}
// State has changed, while the quitDialog was active, it might
// not be correct anymore
- if (quitDialog) {
+ if (quitDialog)
quitDialog->scheduleDelete();
- }
- switch (state) {
+ switch (state)
+ {
case STATE_CHOOSE_SERVER:
logger->log("State: CHOOSE SERVER");
// Allow changing this using a server choice dialog
// We show the dialog box only if the command-line
// options weren't set.
- if (options.serverName.empty() && options.serverPort == 0) {
+ if (options.serverName.empty() && options.serverPort == 0)
+ {
// Don't allow an alpha opacity
// lower than the default value
SkinLoader::instance()->setMinimumOpacity(0.8f);
currentDialog = new ServerDialog(&currentServer,
homeDir);
- } else {
+ }
+ else
+ {
state = STATE_CONNECT_SERVER;
// Reset options so that cancelling or connect
@@ -945,9 +952,12 @@ int main(int argc, char *argv[])
SkinLoader::instance()->setMinimumOpacity(0.8f);
if (options.username.empty()
- || options.password.empty()) {
+ || options.password.empty())
+ {
currentDialog = new LoginDialog(&loginData);
- } else {
+ }
+ else
+ {
state = STATE_LOGIN_ATTEMPT;
// Clear the password so that when login fails, the
// dialog will show up next time.
@@ -1057,9 +1067,12 @@ int main(int argc, char *argv[])
new CharSelectDialog(&charInfo, &loginData);
if (((CharSelectDialog*) currentDialog)->
- selectByName(options.character)) {
+ selectByName(options.character))
+ {
((CharSelectDialog*) currentDialog)->chooseSelected();
- } else {
+ }
+ else
+ {
((CharSelectDialog*) currentDialog)->selectByName(
config.getValue("lastCharacter", ""));
}
diff --git a/src/map.cpp b/src/map.cpp
index db1e9aa2..df03873f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -230,7 +230,8 @@ void Map::initializeAmbientLayers()
{
name = "overlay" + toString(i);
}
- else {
+ else
+ {
break; // the FOR loop
}
@@ -712,12 +713,14 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
newTile->Gcost = Gcost;
newTile->Fcost = Gcost + newTile->Hcost;
- if (x != destX || y != destY) {
+ if (x != destX || y != destY)
+ {
// Add this tile to the open list
newTile->whichList = mOnOpenList;
openList.push(Location(x, y, newTile));
}
- else {
+ else
+ {
// Target location was found
foundPath = true;
}
diff --git a/src/map.h b/src/map.h
index 0e4345b2..f8b14cd3 100644
--- a/src/map.h
+++ b/src/map.h
@@ -300,7 +300,7 @@ class Map : public Properties
void setDebugFlags(int n) {mDebugFlags = n;}
- int getDebugFlags() {return mDebugFlags;}
+ int getDebugFlags() const {return mDebugFlags;}
/**
* Gets the tile animation for a specific gid
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index cba1c984..6c943454 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -245,7 +245,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
* we'll just pretend the packet didn't happen
*/
- if (dstBeing) {
+ if (dstBeing)
+ {
dstBeing->setAction(Being::STAND);
dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
@@ -406,14 +407,18 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
int id = 0;
int id2 = 0;
- if (msg.getId() == SMSG_BEING_CHANGE_LOOKS) {
+ if (msg.getId() == SMSG_BEING_CHANGE_LOOKS)
+ {
id = msg.readInt8();
- } else { // SMSG_BEING_CHANGE_LOOKS2
+ }
+ else
+ { // SMSG_BEING_CHANGE_LOOKS2
id = msg.readInt16();
id2 = msg.readInt16();
}
- switch (type) {
+ switch (type)
+ {
case 1: // eAthena LOOK_HAIR
player->setSpriteID(Player::HAIR_SPRITE, id *-1);
break;
@@ -606,14 +611,17 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
*/
id = msg.readInt32();
- if (mSync || id != player_node->getId()) {
+ if (mSync || id != player_node->getId())
+ {
dstBeing = beingManager->findBeing(id);
- if (dstBeing) {
+ if (dstBeing)
+ {
Uint16 x, y;
x = msg.readInt16();
y = msg.readInt16();
dstBeing->setTileCoords(x, y);
- if (dstBeing->mAction == Being::WALK) {
+ if (dstBeing->mAction == Being::WALK)
+ {
dstBeing->mFrame = 0;
dstBeing->setAction(Being::STAND);
}
@@ -639,7 +647,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
statusEffects |= ((Uint32) msg.readInt16()) << 16;
msg.readInt8();
- if (dstBeing) {
+ if (dstBeing)
+ {
dstBeing->setStunMode(stunMode);
dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff);
dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff);
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index 8dacb06f..cda839bb 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -96,7 +96,8 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_CHAR_LOGIN_ERROR:
- switch (msg.readInt8()) {
+ switch (msg.readInt8())
+ {
case 0:
errorMessage = _("Access denied.");
break;
@@ -216,9 +217,8 @@ LocalPlayer *CharServerHandler::readPlayerData(Net::MessageIn &msg, int &slot)
tempPlayer->setSprite(Player::HAIR_SPRITE, hairStyle * -1, ColorDB::get(msg.readInt16()));
tempPlayer->setSprite(Player::MISC2_SPRITE, msg.readInt16());
tempPlayer->setName(msg.readString(24));
- for (int i = 0; i < 6; i++) {
+ for (int i = 0; i < 6; i++)
tempPlayer->setAttributeBase(i + STR, msg.readInt8());
- }
slot = msg.readInt8(); // character slot
msg.readInt8(); // unknown
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
index 44542ddc..5c7c5036 100644
--- a/src/net/ea/generalhandler.cpp
+++ b/src/net/ea/generalhandler.cpp
@@ -118,7 +118,8 @@ void GeneralHandler::handleMessage(Net::MessageIn &msg)
code = msg.readInt8();
logger->log("Connection problem: %i", code);
- switch (code) {
+ switch (code)
+ {
case 0:
errorMessage = _("Authentication failed.");
break;
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index c616464a..c7080c2d 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -155,17 +155,21 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
cards[0], cards[1], cards[2], cards[3]);
}
- if (msg.getId() == SMSG_PLAYER_INVENTORY) {
+ if (msg.getId() == SMSG_PLAYER_INVENTORY)
+ {
inventory->setItem(index, itemId, amount, false);
// Trick because arrows are not considered equipment
- if (arrow & 0x8000) {
+ if (arrow & 0x8000)
+ {
if (Item *item = inventory->getItem(index))
item->setEquipment(true);
}
//const Item *item = inventory->getItem(index);
- } else {
+ }
+ else
+ {
storage->setItem(index, itemId, amount, false);
}
}
@@ -175,7 +179,8 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
msg.readInt16(); // length
number = (msg.getLength() - 4) / 20;
- for (int loop = 0; loop < number; loop++) {
+ for (int loop = 0; loop < number; loop++)
+ {
index = msg.readInt16() - STORAGE_OFFSET;
itemId = msg.readInt16();
itemType = msg.readInt8();
@@ -258,9 +263,12 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
index = msg.readInt16() - INVENTORY_OFFSET;
amount = msg.readInt16();
- if (msg.readInt8() == 0) {
+ if (msg.readInt8() == 0)
+ {
localChatTab->chatLog(_("Failed to use item."), BY_SERVER);
- } else {
+ }
+ else
+ {
if (Item *item = inventory->getItem(index))
item->setQuantity(amount);
}
@@ -354,13 +362,9 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
flag = msg.readInt8();
if (!flag)
- {
localChatTab->chatLog(_("Unable to equip."), BY_SERVER);
- }
else
- {
mEquips.setEquipment(getSlot(equipType), index);
- }
break;
case SMSG_PLAYER_UNEQUIP:
@@ -368,13 +372,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
equipType = msg.readInt16();
flag = msg.readInt8();
- if (!flag) {
+ if (!flag)
localChatTab->chatLog(_("Unable to unequip."), BY_SERVER);
- }
else
- {
mEquips.setEquipment(getSlot(equipType), -1);
- }
break;
case SMSG_PLAYER_ATTACK_RANGE:
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index e27eccf8..07caa325 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -73,7 +73,8 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// pass change failed
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case 0:
errorMessage = _("Account was not found. Please re-login.");
break;
@@ -142,7 +143,8 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
code = msg.readInt8();
logger->log("Login::error code: %i", code);
- switch (code) {
+ switch (code)
+ {
case 0:
errorMessage = _("Unregistered ID.");
break;
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index c12e1bb9..a93d6cfd 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -411,7 +411,8 @@ void Network::receive()
setError(_("Connection to server terminated. ") +
std::string(SDLNet_GetError()));
}
- else {
+ else
+ {
mInSize += ret;
if (mToSkip)
{
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index de17855f..af842c11 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -162,7 +162,8 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
short exp = msg.readInt16();
short item = msg.readInt16();
- switch (exp) {
+ switch (exp)
+ {
case PARTY_SHARE:
if (mShareExp == PARTY_SHARE)
break;
@@ -185,7 +186,8 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
logger->log("Unknown party exp option: %d\n", exp);
}
- switch (item) {
+ switch (item)
+ {
case PARTY_SHARE:
if (mShareItems == PARTY_SHARE)
break;
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 0592bb55..14907300 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -309,7 +309,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_PLAYER_STAT_UPDATE_2:
- switch (msg.readInt16()) {
+ switch (msg.readInt16())
+ {
case 0x0001:
player_node->setExp(msg.readInt32());
break;
@@ -490,7 +491,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_PLAYER_STAT_UPDATE_6:
- switch (msg.readInt16()) {
+ switch (msg.readInt16())
+ {
case 0x0020:
statusWindow->setPointsNeeded(STR, msg.readInt8());
break;
@@ -516,7 +518,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
{
int type = msg.readInt16();
- switch (type) {
+ switch (type)
+ {
case 0:
localChatTab->chatLog(_("Equip arrows first."),
BY_SERVER);
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 2f5186df..b02bb900 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -161,11 +161,10 @@ void TradeHandler::handleMessage(Net::MessageIn &msg)
msg.skip(8); // card (4 shorts)
// TODO: handle also identified, etc
- if (type == 0) {
+ if (type == 0)
tradeWindow->setMoney(amount);
- } else {
+ else
tradeWindow->addItem(type, false, amount, false);
- }
}
break;
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 4efde53a..36e57278 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -127,7 +127,8 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
}
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case ERRMSG_NO_LOGIN:
errorMessage = "Chatserver: Not logged in";
break;
@@ -169,7 +170,7 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
{
- if(msg.readInt8() == ERRMSG_OK)
+ if (msg.readInt8() == ERRMSG_OK)
{
short channelId = msg.readInt16();
std::string channelName = msg.readString();
@@ -182,7 +183,7 @@ void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
std::string user;
std::string userModes;
tab->chatLog(_("Players in this channel:"), BY_CHANNEL);
- while(msg.getUnreadLength())
+ while (msg.getUnreadLength())
{
user = msg.readString();
if (user == "")
@@ -205,7 +206,7 @@ void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
void ChatHandler::handleListChannelsResponse(Net::MessageIn &msg)
{
localChatTab->chatLog(_("Listing channels."), BY_SERVER);
- while(msg.getUnreadLength())
+ while (msg.getUnreadLength())
{
std::string channelName = msg.readString();
if (channelName == "")
@@ -245,7 +246,7 @@ void ChatHandler::handleChatMessage(Net::MessageIn &msg)
void ChatHandler::handleQuitChannelResponse(Net::MessageIn &msg)
{
- if(msg.readInt8() == ERRMSG_OK)
+ if (msg.readInt8() == ERRMSG_OK)
{
short channelId = msg.readInt16();
Channel *channel = channelManager->findById(channelId);
@@ -260,7 +261,7 @@ void ChatHandler::handleListChannelUsersResponse(Net::MessageIn &msg)
std::string userModes;
Channel *channel = channelManager->findByName(channelName);
channel->getTab()->chatLog(_("Players in this channel:"), BY_CHANNEL);
- while(msg.getUnreadLength())
+ while (msg.getUnreadLength())
{
userNick = msg.readString();
if (userNick == "")
@@ -283,7 +284,7 @@ void ChatHandler::handleChannelEvent(Net::MessageIn &msg)
std::string line = msg.readString();
Channel *channel = channelManager->findById(channelId);
- if(channel)
+ if (channel)
{
switch(eventId)
{
@@ -334,7 +335,7 @@ void ChatHandler::handleWhoResponse(Net::MessageIn &msg)
{
std::string userNick;
- while(msg.getUnreadLength())
+ while (msg.getUnreadLength())
{
userNick = msg.readString();
if (userNick == "")
diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp
index f9504ebb..39bc9cba 100644
--- a/src/net/manaserv/effecthandler.cpp
+++ b/src/net/manaserv/effecthandler.cpp
@@ -58,23 +58,21 @@ void EffectHandler::handleMessage(Net::MessageIn &msg)
void EffectHandler::handleCreateEffectPos(Net::MessageIn &msg)
{
- int id = msg.readInt16();
- Uint16 x = msg.readInt16();
- Uint16 y = msg.readInt16();
- effectManager->trigger(id, x, y);
+ int id = msg.readInt16();
+ Uint16 x = msg.readInt16();
+ Uint16 y = msg.readInt16();
+ effectManager->trigger(id, x, y);
}
void EffectHandler::handleCreateEffectBeing(Net::MessageIn &msg)
{
- int eid = msg.readInt16();
- int bid = msg.readInt16();
- Being* b = beingManager->findBeing(bid);
- if (b)
- {
- effectManager->trigger(eid, b);
- } else {
- logger->log("Warning: CreateEffect called for unknown being #%d", bid);
- }
+ int eid = msg.readInt16();
+ int bid = msg.readInt16();
+ Being* b = beingManager->findBeing(bid);
+ if (b)
+ effectManager->trigger(eid, b);
+ else
+ logger->log("Warning: CreateEffect called for unknown being #%d", bid);
}
} // namespace ManaServ
diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp
index 8b8b9d0f..51b9d1c9 100644
--- a/src/net/manaserv/gamehandler.cpp
+++ b/src/net/manaserv/gamehandler.cpp
@@ -72,7 +72,8 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
// Logout failed
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case ERRMSG_NO_LOGIN:
errorMessage = "Gameserver: Not logged in";
break;
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index c87671ea..79f76320 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -74,7 +74,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_GUILD_CREATE_RESPONSE:
{
logger->log("Received CPMSG_GUILD_CREATE_RESPONSE");
- if(msg.readInt8() == ERRMSG_OK)
+ if (msg.readInt8() == ERRMSG_OK)
{
// TODO - Acknowledge guild was created
localChatTab->chatLog(_("Guild created."));
@@ -89,7 +89,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_GUILD_INVITE_RESPONSE:
{
logger->log("Received CPMSG_GUILD_INVITE_RESPONSE");
- if(msg.readInt8() == ERRMSG_OK)
+ if (msg.readInt8() == ERRMSG_OK)
{
// TODO - Acknowledge invite was sent
localChatTab->chatLog(_("Invite sent."));
@@ -99,7 +99,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_GUILD_ACCEPT_RESPONSE:
{
logger->log("Received CPMSG_GUILD_ACCEPT_RESPONSE");
- if(msg.readInt8() == ERRMSG_OK)
+ if (msg.readInt8() == ERRMSG_OK)
{
// TODO - Acknowledge accepted into guild
joinedGuild(msg);
@@ -109,7 +109,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_GUILD_GET_MEMBERS_RESPONSE:
{
logger->log("Received CPMSG_GUILD_GET_MEMBERS_RESPONSE");
- if(msg.readInt8() == ERRMSG_OK)
+ if (msg.readInt8() == ERRMSG_OK)
{
std::string name;
bool online;
@@ -124,11 +124,11 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
guild->clearMembers();
- while(msg.getUnreadLength())
+ while (msg.getUnreadLength())
{
name = msg.readString();
online = msg.readInt8();
- if(name != "")
+ if (name != "")
{
member = new GuildMember(guildId, name);
member->setOnline(online);
diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp
index 34202411..91d9171b 100644
--- a/src/net/manaserv/loginhandler.cpp
+++ b/src/net/manaserv/loginhandler.cpp
@@ -78,7 +78,8 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// Login failed
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case ERRMSG_INVALID_ARGUMENT:
errorMessage = _("Wrong magic_token.");
break;
@@ -108,7 +109,8 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// pass change failed
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case ERRMSG_INVALID_ARGUMENT:
errorMessage = _("New password incorrect.");
break;
@@ -138,7 +140,8 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// pass change failed
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case ERRMSG_INVALID_ARGUMENT:
errorMessage = _("New email address incorrect.");
break;
@@ -171,7 +174,8 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// Logout failed
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case ERRMSG_NO_LOGIN:
errorMessage = "Accountserver: Not logged in";
break;
@@ -194,7 +198,8 @@ void LoginHandler::handleMessage(Net::MessageIn &msg)
// Unregistration failed
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case ERRMSG_INVALID_ARGUMENT:
errorMessage =
"Accountserver: Wrong username or password";
@@ -249,7 +254,8 @@ void LoginHandler::handleLoginResponse(Net::MessageIn &msg)
}
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case LOGIN_INVALID_VERSION:
errorMessage = _("Client version is too old.");
break;
@@ -285,7 +291,8 @@ void LoginHandler::handleRegisterResponse(Net::MessageIn &msg)
}
else
{
- switch (errMsg) {
+ switch (errMsg)
+ {
case REGISTER_INVALID_VERSION:
errorMessage = _("Client version is too old.");
break;
diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index 0ca61fc2..83d78e06 100644
--- a/src/net/manaserv/network.cpp
+++ b/src/net/manaserv/network.cpp
@@ -66,7 +66,8 @@ void finalize()
if (!client)
return; // Wasn't initialized at all
- if (connections) {
+ if (connections)
+ {
logger->error("Tried to shutdown the network subsystem while there "
"are network connections left!");
}
@@ -120,12 +121,14 @@ namespace
MessageHandlerIterator iter = mMessageHandlers.find(msg.getId());
- if (iter != mMessageHandlers.end()) {
+ if (iter != mMessageHandlers.end())
+ {
//logger->log("Received packet %x (%i B)",
// msg.getId(), msg.getLength());
iter->second->handleMessage(msg);
}
- else {
+ else
+ {
logger->log("Unhandled packet %x (%i B)",
msg.getId(), msg.getLength());
}
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index b0f299b6..671d02a3 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -278,7 +278,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
{
Sint16 type = msg.readInt16();
- switch (type) {
+ switch (type)
+ {
case 0:
localChatTab->chatLog(_("Equip arrows first."),
BY_SERVER);
@@ -314,7 +315,8 @@ void PlayerHandler::handleMapChangeMessage(Net::MessageIn &msg)
/* Scroll if neccessary */
if (!nearby
|| (abs(x - (int) playerPos.x) > MAP_TELEPORT_SCROLL_DISTANCE)
- || (abs(y - (int) playerPos.y) > MAP_TELEPORT_SCROLL_DISTANCE)) {
+ || (abs(y - (int) playerPos.y) > MAP_TELEPORT_SCROLL_DISTANCE))
+ {
scrollOffsetX = x - (int) playerPos.x;
scrollOffsetY = y - (int) playerPos.y;
}
diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp
index cbcc29dc..08fc354c 100644
--- a/src/net/manaserv/tradehandler.cpp
+++ b/src/net/manaserv/tradehandler.cpp
@@ -92,11 +92,10 @@ TradeHandler::TradeHandler():
void TradeHandler::setAcceptTradeRequests(bool acceptTradeRequests)
{
mAcceptTradeRequests = acceptTradeRequests;
- if (mAcceptTradeRequests) {
+ if (mAcceptTradeRequests)
localChatTab->chatLog(_("Accepting incoming trade requests."), BY_SERVER);
- } else {
+ else
localChatTab->chatLog(_("Ignoring incoming trade requests."), BY_SERVER);
- }
}
void TradeHandler::handleMessage(Net::MessageIn &msg)
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index f659fcfc..5cc13192 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -139,7 +139,8 @@ std::string MessageIn::readString(int length)
length = readInt16();
// Make sure the string isn't erroneous
- if (length < 0 || mPos + length > mLength) {
+ if (length < 0 || mPos + length > mLength)
+ {
mPos = mLength + 1;
return "";
}
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 3b380367..ade879a3 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -189,7 +189,8 @@ void connectToServer(const ServerInfo &server)
getLoginHandler()->connect();
}
-void unload() {
+void unload()
+{
GeneralHandler *handler = getGeneralHandler();
if (handler)
{
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index 63f89079..67f82b0b 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -75,7 +75,8 @@ void ParticleList::removeLocally(Particle *particle)
for (std::list<Particle *>::iterator it = mElements.begin();
it != mElements.end(); it++)
{
- if (*it == particle) {
+ if (*it == particle)
+ {
(*it)->kill();
mElements.erase(it);
}
@@ -158,7 +159,8 @@ void ParticleVector::moveTo(float x, float y)
ParticleContainer::moveTo(x, y);
for (std::vector<Particle *>::iterator it = mIndexedElements.begin();
- it != mIndexedElements.end(); it++) {
+ it != mIndexedElements.end(); it++)
+ {
if (*it)
{
(*it)->moveTo(x, y);
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index d4a56bfd..885f25d4 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -380,19 +380,18 @@ ParticleEmitter::readParticleEmitterProp(xmlNodePtr propertyNode, T def)
retval.set((T) XML::getFloatProperty(propertyNode, "min", (double) def),
(T) XML::getFloatProperty(propertyNode, "max", (double) def));
- std::string change = XML::getProperty(propertyNode, "change-func", "none");
- T amplitude = (T) XML::getFloatProperty(propertyNode, "change-amplitude", 0.0);
- int period = XML::getProperty(propertyNode, "change-period", 0);
- int phase = XML::getProperty(propertyNode, "change-phase", 0);
- if (change == "saw" || change == "sawtooth") {
- retval.setFunction(FUNC_SAW, amplitude, period, phase);
- } else if (change == "sine" || change == "sinewave") {
- retval.setFunction(FUNC_SINE, amplitude, period, phase);
- } else if (change == "triangle") {
- retval.setFunction(FUNC_TRIANGLE, amplitude, period, phase);
- } else if (change == "square"){
- retval.setFunction(FUNC_SQUARE, amplitude, period, phase);
- }
+ std::string change = XML::getProperty(propertyNode, "change-func", "none");
+ T amplitude = (T) XML::getFloatProperty(propertyNode, "change-amplitude", 0.0);
+ int period = XML::getProperty(propertyNode, "change-period", 0);
+ int phase = XML::getProperty(propertyNode, "change-phase", 0);
+ if (change == "saw" || change == "sawtooth")
+ retval.setFunction(FUNC_SAW, amplitude, period, phase);
+ else if (change == "sine" || change == "sinewave")
+ retval.setFunction(FUNC_SINE, amplitude, period, phase);
+ else if (change == "triangle")
+ retval.setFunction(FUNC_TRIANGLE, amplitude, period, phase);
+ else if (change == "square")
+ retval.setFunction(FUNC_SQUARE, amplitude, period, phase);
return retval;
}
diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h
index e68ac222..4fbdd578 100644
--- a/src/particleemitterprop.h
+++ b/src/particleemitterprop.h
@@ -77,18 +77,18 @@ template <typename T> struct ParticleEmitterProp
if ((tick%changePeriod) * 2 < changePeriod)
{
val += changeAmplitude - (T)((tick%changePeriod) / (double)changePeriod) * changeAmplitude * 4;
- } else {
+ }
+ else
+ {
val += changeAmplitude * -3 + (T)((tick%changePeriod) / (double)changePeriod) * changeAmplitude * 4;
// I have no idea why this works but it does
}
break;
case FUNC_SQUARE:
if ((tick%changePeriod) * 2 < changePeriod)
- {
val += changeAmplitude;
- } else {
+ else
val -= changeAmplitude;
- }
break;
case FUNC_NONE:
default:
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 2825d114..98d8ad11 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -63,7 +63,8 @@ class PlayerConfSerialiser : public ConfigurationListManager<std::pair<std::stri
if (name.empty())
return container;
- if (!(*container)[name]) {
+ if (!(*container)[name])
+ {
int v = (int)cobj->getValue(RELATION, PlayerRelation::NEUTRAL);
(*container)[name] = new PlayerRelation(static_cast<PlayerRelation::Relation>(v));
}
@@ -168,8 +169,11 @@ void PlayerRelationsManager::signalUpdate(const std::string &name)
{
store();
- for (std::list<PlayerRelationsListener *>::const_iterator it = mListeners.begin(); it != mListeners.end(); it++)
+ for (std::list<PlayerRelationsListener *>::const_iterator it = mListeners.begin();
+ it != mListeners.end(); it++)
+ {
(*it)->updatedPlayer(name);
+ }
}
unsigned int PlayerRelationsManager::checkPermissionSilently(const std::string &player_name, unsigned int flags)
@@ -177,10 +181,12 @@ unsigned int PlayerRelationsManager::checkPermissionSilently(const std::string &
PlayerRelation *r = mRelations[player_name];
if (!r)
return mDefaultPermissions & flags;
- else {
+ else
+ {
unsigned int permissions = PlayerRelation::RELATION_PERMISSIONS[r->mRelation];
- switch (r->mRelation) {
+ switch (r->mRelation)
+ {
case PlayerRelation::NEUTRAL:
permissions = mDefaultPermissions;
break;
@@ -210,9 +216,11 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
unsigned int rejections = flags & ~checkPermissionSilently(name, flags);
bool permitted = rejections == 0;
- if (!permitted) {
+ if (!permitted)
+ {
// execute `ignore' strategy, if possible
- if (mIgnoreStrategy) {
+ if (mIgnoreStrategy)
+ {
Player *to_ignore = dynamic_cast<Player *>(beingManager->findBeingByName(name, Being::PLAYER));
if (to_ignore)
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 15ad3b54..41c3a194 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -483,9 +483,8 @@ Image *Image::_GLload(SDL_Surface *tmpImage)
glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- if (SDL_MUSTLOCK(tmpImage)) {
+ if (SDL_MUSTLOCK(tmpImage))
SDL_UnlockSurface(tmpImage);
- }
SDL_FreeSurface(tmpImage);
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index 86f92561..634d80fc 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -36,9 +36,8 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
png_bytep *row_pointers;
int colortype;
- if (SDL_MUSTLOCK(surface)) {
+ if (SDL_MUSTLOCK(surface))
SDL_LockSurface(surface);
- }
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
if (!png_ptr)
@@ -103,9 +102,8 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
- if (SDL_MUSTLOCK(surface)) {
+ if (SDL_MUSTLOCK(surface))
SDL_UnlockSurface(surface);
- }
return true;
}
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 60b5e9d2..28bc91c3 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -76,7 +76,8 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret != Z_STREAM_ERROR);
- switch (ret) {
+ switch (ret)
+ {
case Z_NEED_DICT:
ret = Z_DATA_ERROR;
case Z_DATA_ERROR:
@@ -185,14 +186,19 @@ Map *MapReader::readMap(const std::string &filename)
xmlNodePtr node = doc.rootNode();
// Parse the inflated map data
- if (node) {
- if (!xmlStrEqual(node->name, BAD_CAST "map")) {
+ if (node)
+ {
+ if (!xmlStrEqual(node->name, BAD_CAST "map"))
+ {
logger->log("Error: Not a map file (%s)!", filename.c_str());
}
- else {
+ else
+ {
map = readMap(node, filename);
}
- } else {
+ }
+ else
+ {
logger->log("Error while parsing map file (%s)!", filename.c_str());
}
@@ -217,7 +223,8 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
if (xmlStrEqual(childNode->name, BAD_CAST "tileset"))
{
Tileset *tileset = readTileset(childNode, pathDir, map);
- if (tileset) {
+ if (tileset)
+ {
map->addTileset(tileset);
}
}
@@ -261,7 +268,8 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
if (objType == "PARTICLE_EFFECT")
{
- if (objName.empty()) {
+ if (objName.empty())
+ {
logger->log(" Warning: No particle file given");
continue;
}
@@ -308,7 +316,9 @@ static void setTile(Map *map, MapLayer *layer, int x, int y, int gid)
// Set regular tile on a layer
Image * const img = set ? set->get(gid - set->getFirstGid()) : 0;
layer->setTile(x, y, img);
- } else {
+ }
+ else
+ {
// Set collision tile
if (set && (gid - set->getFirstGid() != 0))
map->blockTile(x, y, Map::BLOCKTYPE_WALL);
@@ -330,7 +340,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
MapLayer *layer = 0;
- if (!isCollisionLayer) {
+ if (!isCollisionLayer)
+ {
layer = new MapLayer(offsetX, offsetY, w, h, isFringeLayer);
map->addLayer(layer);
}
@@ -352,7 +363,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
if (encoding == "base64")
{
- if (!compression.empty() && compression != "gzip") {
+ if (!compression.empty() && compression != "gzip")
+ {
logger->log("Warning: only gzip layer compression supported!");
return;
}
@@ -367,7 +379,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
const char *charStart = (const char*)dataChild->content;
unsigned char *charIndex = charData;
- while (*charStart) {
+ while (*charStart)
+ {
if (*charStart != ' ' && *charStart != '\t' &&
*charStart != '\n')
{
@@ -384,8 +397,10 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
delete[] charData;
- if (binData) {
- if (compression == "gzip") {
+ if (binData)
+ {
+ if (compression == "gzip")
+ {
// Inflate the gzipped layer data
unsigned char *inflated;
unsigned int inflatedSize =
@@ -395,13 +410,15 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
binData = inflated;
binLen = inflatedSize;
- if (!inflated) {
+ if (!inflated)
+ {
logger->log("Error: Could not decompress layer!");
return;
}
}
- for (int i = 0; i < binLen - 3; i += 4) {
+ for (int i = 0; i < binLen - 3; i += 4)
+ {
const int gid = binData[i] |
binData[i + 1] << 8 |
binData[i + 2] << 16 |
@@ -416,7 +433,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
}
x++;
- if (x == w) {
+ if (x == w)
+ {
x = 0; y++;
// When we're done, don't crash on too much data
@@ -427,7 +445,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
free(binData);
}
}
- else {
+ else
+ {
// Read plain XML map file
for_each_xml_child_node(childNode2, childNode)
{
@@ -438,7 +457,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
setTile(map, layer, x, y, gid);
x++;
- if (x == w) {
+ if (x == w)
+ {
x = 0; y++;
if (y >= h)
break;
@@ -496,7 +516,8 @@ Tileset *MapReader::readTileset(xmlNodePtr node,
set = new Tileset(tilebmp, tw, th, firstGid);
tilebmp->decRef();
}
- else {
+ else
+ {
logger->log("Warning: Failed to load tileset (%s)",
source.c_str());
}
@@ -531,18 +552,18 @@ Tileset *MapReader::readTileset(xmlNodePtr node,
iFrame = tileProperties.find("animation-frame" + toString(i));
iDelay = tileProperties.find("animation-delay" + toString(i));
if (iFrame != tileProperties.end() && iDelay != tileProperties.end())
- {
ani->addFrame(set->get(iFrame->second), iDelay->second, 0, 0);
- } else {
+ else
break;
- }
}
if (ani->getLength() > 0)
{
map->addAnimation(tileGID, new TileAnimation(ani));
logger->log("Animation length: %d", ani->getLength());
- } else {
+ }
+ else
+ {
delete ani;
}
}
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index bc3267da..fe594a3f 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -146,7 +146,8 @@ bool ResourceManager::setWriteDir(const std::string &path)
bool ResourceManager::addToSearchPath(const std::string &path, bool append)
{
logger->log("Adding to PhysicsFS: %s", path.c_str());
- if (!PHYSFS_addToSearchPath(path.c_str(), append ? 1 : 0)) {
+ if (!PHYSFS_addToSearchPath(path.c_str(), append ? 1 : 0))
+ {
logger->log("Error: %s", PHYSFS_getLastError());
return false;
}
@@ -409,7 +410,8 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
PHYSFS_file *file = PHYSFS_openRead(fileName.c_str());
// If the handler is an invalid pointer indicate failure
- if (file == NULL) {
+ if (file == NULL)
+ {
logger->log("Warning: Failed to load %s: %s",
fileName.c_str(), PHYSFS_getLastError());
return NULL;
@@ -488,7 +490,8 @@ SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename)
void *buffer = loadFile(filename, fileSize);
SDL_Surface *tmp = NULL;
- if (buffer) {
+ if (buffer)
+ {
SDL_RWops *rw = SDL_RWFromMem(buffer, fileSize);
tmp = IMG_Load_RW(rw, 1);
::free(buffer);
diff --git a/src/resources/sdlrescalefacility.cpp b/src/resources/sdlrescalefacility.cpp
index 49ba8aa4..82c1216c 100644
--- a/src/resources/sdlrescalefacility.cpp
+++ b/src/resources/sdlrescalefacility.cpp
@@ -43,24 +43,22 @@ void zoomSurfaceSize(int width, int height, double zoomx, double zoomy,
/*
* Sanity check zoom factors
*/
- if (zoomx < VALUE_LIMIT) {
+ if (zoomx < VALUE_LIMIT)
zoomx = VALUE_LIMIT;
- }
- if (zoomy < VALUE_LIMIT) {
+
+ if (zoomy < VALUE_LIMIT)
zoomy = VALUE_LIMIT;
- }
/*
* Calculate target size
*/
*dstwidth = (int) ((double) width * zoomx);
*dstheight = (int) ((double) height * zoomy);
- if (*dstwidth < 1) {
+ if (*dstwidth < 1)
*dstwidth = 1;
- }
- if (*dstheight < 1) {
+
+ if (*dstheight < 1)
*dstheight = 1;
- }
}
int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
@@ -74,7 +72,8 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
/*
* Variable setup
*/
- if (smooth) {
+ if (smooth)
+ {
/*
* For interpolation: assume source dimension is one pixel
*/
@@ -83,7 +82,9 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
*/
sx = (int) (65536.0 * (float) (src->w - 1) / (float) dst->w);
sy = (int) (65536.0 * (float) (src->h - 1) / (float) dst->h);
- } else {
+ }
+ else
+ {
sx = (int) (65536.0 * (float) src->w / (float) dst->w);
sy = (int) (65536.0 * (float) src->h / (float) dst->h);
}
@@ -91,10 +92,10 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
/*
* Allocate memory for row increments
*/
- if ((sax = (int *) malloc((dst->w + 1) * sizeof(Uint32))) == NULL) {
+ if ((sax = (int *) malloc((dst->w + 1) * sizeof(Uint32))) == NULL)
return (-1);
- }
- if ((say = (int *) malloc((dst->h + 1) * sizeof(Uint32))) == NULL) {
+ if ((say = (int *) malloc((dst->h + 1) * sizeof(Uint32))) == NULL)
+ {
free(sax);
return (-1);
}
@@ -110,7 +111,8 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
csx = 0;
csax = sax;
- for (x = 0; x <= dst->w; x++) {
+ for (x = 0; x <= dst->w; x++)
+ {
*csax = csx;
csax++;
csx &= 0xffff;
@@ -118,7 +120,8 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
}
csy = 0;
csay = say;
- for (y = 0; y <= dst->h; y++) {
+ for (y = 0; y <= dst->h; y++)
+ {
*csay = csy;
csay++;
csy &= 0xffff;
@@ -130,7 +133,8 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
/*
* Switch between interpolating and non-interpolating code
*/
- if (smooth) {
+ if (smooth)
+ {
/*
* Interpolating Zoom
@@ -141,7 +145,8 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
*/
ly = 0;
csay = say;
- for (y = 0; y < dst->h; y++) {
+ for (y = 0; y < dst->h; y++)
+ {
/*
* Setup color source pointers
*/
@@ -152,16 +157,19 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
c11 = c10;
c11++;
csax = sax;
- if (flipx) {
+ if (flipx)
+ {
cswap = c00; c00=c01; c01=cswap;
cswap = c10; c10=c11; c11=cswap;
}
- if (flipy) {
+ if (flipy)
+ {
cswap = c00; c00=c10; c10=cswap;
cswap = c01; c01=c11; c11=cswap;
}
lx = 0;
- for (x = 0; x < dst->w; x++) {
+ for (x = 0; x < dst->w; x++)
+ {
/*
* Interpolate colors
*/
@@ -213,17 +221,20 @@ int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface * dst,
*/
dp = (tColorRGBA *) ((Uint8 *) dp + dgap);
}
- } else {
-
+ }
+ else
+ {
/*
* Non-Interpolating Zoom
*/
csay = say;
- for (y = 0; y < dst->h; y++) {
+ for (y = 0; y < dst->h; y++)
+ {
sp = csp;
csax = sax;
- for (x = 0; x < dst->w; x++) {
+ for (x = 0; x < dst->w; x++)
+ {
/*
* Draw
*/
@@ -283,10 +294,11 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst, int flipx, int flipy)
/*
* Allocate memory for row increments
*/
- if ((sax = (Uint32 *) malloc((dst->w + 1) * sizeof(Uint32))) == NULL) {
+ if ((sax = (Uint32 *) malloc((dst->w + 1) * sizeof(Uint32))) == NULL)
return (-1);
- }
- if ((say = (Uint32 *) malloc((dst->h + 1) * sizeof(Uint32))) == NULL) {
+
+ if ((say = (Uint32 *) malloc((dst->h + 1) * sizeof(Uint32))) == NULL)
+ {
free(sax);
return (-1);
}
@@ -306,7 +318,8 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst, int flipx, int flipy)
*/
csx = 0;
csax = sax;
- for (x = 0; x <= dst->w; x++) {
+ for (x = 0; x <= dst->w; x++)
+ {
*csax = csx;
csax++;
csx &= 0xffff;
@@ -314,7 +327,8 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst, int flipx, int flipy)
}
csy = 0;
csay = say;
- for (y = 0; y <= dst->h; y++) {
+ for (y = 0; y <= dst->h; y++)
+ {
*csay = csy;
csay++;
csy &= 0xffff;
@@ -326,10 +340,12 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst, int flipx, int flipy)
* Draw
*/
csay = say;
- for (y = 0; y < dst->h; y++) {
+ for (y = 0; y < dst->h; y++)
+ {
csax = sax;
sp = csp;
- for (x = 0; x < dst->w; x++) {
+ for (x = 0; x < dst->w; x++)
+ {
/*
* Draw
*/
@@ -390,13 +406,16 @@ SDL_Surface *_SDLzoomSurface(SDL_Surface * src, double zoomx, double zoomy, int
* Determine if source surface is 32bit or 8bit
*/
is32bit = (src->format->BitsPerPixel == 32);
- if ((is32bit) || (src->format->BitsPerPixel == 8)) {
+ if ((is32bit) || (src->format->BitsPerPixel == 8))
+ {
/*
* Use source surface 'as is'
*/
rz_src = src;
src_converted = 0;
- } else {
+ }
+ else
+ {
/*
* New source surface is 32bit with a defined RGBA ordering
*/
@@ -425,7 +444,8 @@ SDL_Surface *_SDLzoomSurface(SDL_Surface * src, double zoomx, double zoomy, int
* Alloc space to completely contain the zoomed surface
*/
rz_dst = NULL;
- if (is32bit) {
+ if (is32bit)
+ {
/*
* Target surface is 32bit with source RGBA/ABGR ordering
*/
@@ -433,7 +453,9 @@ SDL_Surface *_SDLzoomSurface(SDL_Surface * src, double zoomx, double zoomy, int
SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight, 32,
rz_src->format->Rmask, rz_src->format->Gmask,
rz_src->format->Bmask, rz_src->format->Amask);
- } else {
+ }
+ else
+ {
/*
* Target surface is 8bit
*/
@@ -447,7 +469,8 @@ SDL_Surface *_SDLzoomSurface(SDL_Surface * src, double zoomx, double zoomy, int
/*
* Check which kind of surface we have
*/
- if (is32bit) {
+ if (is32bit)
+ {
/*
* Call the 32bit transformation routine to do the zooming (using alpha)
*/
@@ -456,11 +479,14 @@ SDL_Surface *_SDLzoomSurface(SDL_Surface * src, double zoomx, double zoomy, int
* Turn on source-alpha support
*/
SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255);
- } else {
+ }
+ else
+ {
/*
* Copy palette and colorkey info
*/
- for (i = 0; i < rz_src->format->palette->ncolors; i++) {
+ for (i = 0; i < rz_src->format->palette->ncolors; i++)
+ {
rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
}
rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
@@ -478,9 +504,8 @@ SDL_Surface *_SDLzoomSurface(SDL_Surface * src, double zoomx, double zoomy, int
/*
* Cleanup temp surface
*/
- if (src_converted) {
+ if (src_converted)
SDL_FreeSurface(rz_src);
- }
/*
* Return destination surface
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 30d8e778..62db7b66 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -61,9 +61,12 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
{
logger->log("Error, failed to parse %s", animationFile.c_str());
- if (animationFile != "graphics/sprites/error.xml") {
+ if (animationFile != "graphics/sprites/error.xml")
+ {
return load("graphics/sprites/error.xml", 0);
- } else {
+ }
+ else
+ {
return NULL;
}
}
@@ -292,7 +295,8 @@ void SpriteDef::substituteAction(SpriteAction complete, SpriteAction with)
if (mActions.find(complete) == mActions.end())
{
Actions::iterator i = mActions.find(with);
- if (i != mActions.end()) {
+ if (i != mActions.end())
+ {
mActions[complete] = i->second;
}
}
@@ -323,104 +327,73 @@ SpriteDef::~SpriteDef()
SpriteAction SpriteDef::makeSpriteAction(const std::string &action)
{
- if (action.empty() || action == "default") {
+ if (action.empty() || action == "default")
return ACTION_DEFAULT;
- }
- if (action == "stand") {
+
+ if (action == "stand")
return ACTION_STAND;
- }
- else if (action == "walk") {
+ else if (action == "walk")
return ACTION_WALK;
- }
- else if (action == "run") {
+ else if (action == "run")
return ACTION_RUN;
- }
- else if (action == "attack") {
+ else if (action == "attack")
return ACTION_ATTACK;
- }
- else if (action == "attack_swing") {
+ else if (action == "attack_swing")
return ACTION_ATTACK_SWING;
- }
- else if (action == "attack_stab") {
+ else if (action == "attack_stab")
return ACTION_ATTACK_STAB;
- }
- else if (action == "attack_bow") {
+ else if (action == "attack_bow")
return ACTION_ATTACK_BOW;
- }
- else if (action == "attack_throw") {
+ else if (action == "attack_throw")
return ACTION_ATTACK_THROW;
- }
- else if (action == "special0") {
+ else if (action == "special0")
return ACTION_SPECIAL_0;
- }
- else if (action == "special1") {
+ else if (action == "special1")
return ACTION_SPECIAL_1;
- }
- else if (action == "special2") {
+ else if (action == "special2")
return ACTION_SPECIAL_2;
- }
- else if (action == "special3") {
+ else if (action == "special3")
return ACTION_SPECIAL_3;
- }
- else if (action == "special4") {
+ else if (action == "special4")
return ACTION_SPECIAL_4;
- }
- else if (action == "special5") {
+ else if (action == "special5")
return ACTION_SPECIAL_5;
- }
- else if (action == "special6") {
+ else if (action == "special6")
return ACTION_SPECIAL_6;
- }
- else if (action == "special7") {
+ else if (action == "special7")
return ACTION_SPECIAL_7;
- }
- else if (action == "special8") {
+ else if (action == "special8")
return ACTION_SPECIAL_8;
- }
- else if (action == "special9") {
+ else if (action == "special9")
return ACTION_SPECIAL_9;
- }
- else if (action == "cast_magic") {
+ else if (action == "cast_magic")
return ACTION_CAST_MAGIC;
- }
- else if (action == "use_item") {
+ else if (action == "use_item")
return ACTION_USE_ITEM;
- }
- else if (action == "sit") {
+ else if (action == "sit")
return ACTION_SIT;
- }
- else if (action == "sleep") {
+ else if (action == "sleep")
return ACTION_SLEEP;
- }
- else if (action == "hurt") {
+ else if (action == "hurt")
return ACTION_HURT;
- }
- else if (action == "dead") {
+ else if (action == "dead")
return ACTION_DEAD;
- }
- else {
+ else
return ACTION_INVALID;
- }
}
SpriteDirection SpriteDef::makeSpriteDirection(const std::string &direction)
{
- if (direction.empty() || direction == "default") {
+ if (direction.empty() || direction == "default")
return DIRECTION_DEFAULT;
- }
- else if (direction == "up") {
+ else if (direction == "up")
return DIRECTION_UP;
- }
- else if (direction == "left") {
+ else if (direction == "left")
return DIRECTION_LEFT;
- }
- else if (direction == "right") {
+ else if (direction == "right")
return DIRECTION_RIGHT;
- }
- else if (direction == "down") {
+ else if (direction == "down")
return DIRECTION_DOWN;
- }
- else {
+ else
return DIRECTION_INVALID;
- }
}
diff --git a/src/sound.cpp b/src/sound.cpp
index 4a9a6f39..3b7c241d 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -92,7 +92,8 @@ void Sound::info()
SDL_AudioDriverName(driver, 40);
Mix_QuerySpec(&rate, &audioFormat, &channels);
- switch (audioFormat) {
+ switch (audioFormat)
+ {
case AUDIO_U8: format = "U8"; break;
case AUDIO_S8: format = "S8"; break;
case AUDIO_U16LSB: format = "U16LSB"; break;
@@ -150,12 +151,12 @@ static Mix_Music *loadMusic(const std::string &filename)
path.c_str());
bool success = resman->copyFile("music/" + filename, "tempMusic.ogg");
if (success)
- {
path = resman->getPath("tempMusic.ogg");
- } else {
+ else
return NULL;
- }
- } else {
+ }
+ else
+ {
logger->log("Loading music \"%s\"", path.c_str());
}
@@ -190,7 +191,8 @@ void Sound::stopMusic()
logger->log("Sound::stopMusic()");
- if (mMusic) {
+ if (mMusic)
+ {
Mix_HaltMusic();
Mix_FreeMusic(mMusic);
mMusic = NULL;
@@ -219,7 +221,8 @@ void Sound::fadeOutMusic(int ms)
logger->log("Sound::fadeOutMusic() Fading-out (%i ms)", ms);
- if (mMusic) {
+ if (mMusic)
+ {
Mix_FadeOutMusic(ms);
Mix_FreeMusic(mMusic);
mMusic = NULL;
@@ -233,7 +236,8 @@ void Sound::playSfx(const std::string &path)
ResourceManager *resman = ResourceManager::getInstance();
SoundEffect *sample = resman->getSoundEffect(path);
- if (sample) {
+ if (sample)
+ {
logger->log("Sound::playSfx() Playing: %s", path.c_str());
sample->play(0, 120);
}
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index fe076a55..7ef1be19 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -63,10 +63,12 @@ AnimatedSprite *StatusEffect::getIcon()
{
if (mIcon.empty())
return NULL;
- else {
+ else
+ {
AnimatedSprite *sprite = AnimatedSprite::load(
"graphics/sprites/" + mIcon);
- if (false && sprite) {
+ if (false && sprite)
+ {
sprite->play(ACTION_DEFAULT);
sprite->reset();
}
@@ -135,10 +137,12 @@ void StatusEffect::load()
if (index >= 0 && block_index >= 0)
blockEffectIndexMap[block_index] = index;
- } else if (xmlStrEqual(node->name, BAD_CAST "stun-effect"))
+ }
+ else if (xmlStrEqual(node->name, BAD_CAST "stun-effect"))
the_map = &stunEffects;
- if (the_map) {
+ if (the_map)
+ {
StatusEffect *startEffect = new StatusEffect;
StatusEffect *endEffect = new StatusEffect;
diff --git a/src/text.cpp b/src/text.cpp
index 384a048f..2cd1e29a 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -122,12 +122,14 @@ void Text::adviseXY(int x, int y)
void Text::draw(gcn::Graphics *graphics, int xOff, int yOff)
{
- if (mIsSpeech) {
+ if (mIsSpeech)
+ {
static_cast<Graphics*>(graphics)->drawImageRect(
mX - xOff - 5, mY - yOff - 5, mWidth + 10, mHeight + 10,
mBubble);
/*
- if (mWidth >= 15) {
+ if (mWidth >= 15)
+ {
static_cast<Graphics*>(graphics)->drawImage(
mBubbleArrow, mX - xOff - 7 + mWidth / 2,
mY - yOff + mHeight + 4);
diff --git a/src/units.cpp b/src/units.cpp
index f865531a..ac252fcd 100644
--- a/src/units.cpp
+++ b/src/units.cpp
@@ -164,10 +164,13 @@ std::string formatUnit(int value, int type)
struct UnitLevel ul;
// Shortcut for 0; do the same for values less than 0 (for now)
- if (value <= 0) {
+ if (value <= 0)
+ {
ul = ud.levels[0];
return strprintf("0%s", ul.symbol.c_str());
- } else {
+ }
+ else
+ {
double amount = ud.conversion * value;
// If only the first level is needed, act like mix if false
@@ -183,7 +186,8 @@ std::string formatUnit(int value, int type)
amount -= levelAmount * ul.count;
- if (amount > 0) {
+ if (amount > 0)
+ {
output = strprintf("%.*f%s", pl.round, amount,
pl.symbol.c_str());
}
@@ -210,7 +214,8 @@ std::string formatUnit(int value, int type)
for (unsigned int i = 0; i < ud.levels.size(); i++)
{
ul = ud.levels[i];
- if (amount < ul.count && ul.count > 0) {
+ if (amount < ul.count && ul.count > 0)
+ {
ul = ud.levels[i - 1];
break;
}
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index 298841be..57a9fc84 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -42,12 +42,14 @@ static char base64_table[] =
};
static char base64_pad = '=';
-unsigned char *php3_base64_encode(const unsigned char *string, int length, int *ret_length) {
+unsigned char *php3_base64_encode(const unsigned char *string, int length, int *ret_length)
+{
const unsigned char *current = string;
int i = 0;
unsigned char *result = (unsigned char *)malloc(((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char));
- while (length > 2) { /* keep going until we have less than 24 bits */
+ while (length > 2)
+ { /* keep going until we have less than 24 bits */
result[i++] = base64_table[current[0] >> 2];
result[i++] = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
result[i++] = base64_table[((current[1] & 0x0f) << 2) + (current[2] >> 6)];
@@ -58,20 +60,24 @@ unsigned char *php3_base64_encode(const unsigned char *string, int length, int *
}
/* now deal with the tail end of things */
- if (length != 0) {
+ if (length != 0)
+ {
result[i++] = base64_table[current[0] >> 2];
- if (length > 1) {
+ if (length > 1)
+ {
result[i++] = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
result[i++] = base64_table[(current[1] & 0x0f) << 2];
result[i++] = base64_pad;
}
- else {
+ else
+ {
result[i++] = base64_table[(current[0] & 0x03) << 4];
result[i++] = base64_pad;
result[i++] = base64_pad;
}
}
- if(ret_length) {
+ if (ret_length)
+ {
*ret_length = i;
}
result[i] = '\0';
@@ -79,19 +85,22 @@ unsigned char *php3_base64_encode(const unsigned char *string, int length, int *
}
/* as above, but backwards. :) */
-unsigned char *php3_base64_decode(const unsigned char *string, int length, int *ret_length) {
+unsigned char *php3_base64_decode(const unsigned char *string, int length, int *ret_length)
+{
const unsigned char *current = string;
int ch, i = 0, j = 0, k;
char *chp;
unsigned char *result = (unsigned char *)malloc(length + 1);
- if (result == NULL) {
+ if (result == NULL)
+ {
return NULL;
}
/* run through the whole string, converting as we go */
- while ((ch = *current++) != '\0') {
+ while ((ch = *current++) != '\0')
+ {
if (ch == base64_pad) break;
/* When Base64 gets POSTed, all pluses are interpreted as spaces.
@@ -107,7 +116,8 @@ unsigned char *php3_base64_decode(const unsigned char *string, int length, int *
if (chp == NULL) continue;
ch = chp - base64_table;
- switch(i % 4) {
+ switch(i % 4)
+ {
case 0:
result[j] = ch << 2;
break;
@@ -128,8 +138,10 @@ unsigned char *php3_base64_decode(const unsigned char *string, int length, int *
k = j;
/* mop things up if we ended on a boundary */
- if (ch == base64_pad) {
- switch(i % 4) {
+ if (ch == base64_pad)
+ {
+ switch(i % 4)
+ {
case 0:
case 1:
free(result);
@@ -140,7 +152,8 @@ unsigned char *php3_base64_decode(const unsigned char *string, int length, int *
result[k++] = 0;
}
}
- if(ret_length) {
+ if (ret_length)
+ {
*ret_length = j;
}
result[k] = '\0';
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 63487215..a81c37da 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -63,13 +63,16 @@ namespace XML
}
}
- if (data) {
+ if (data)
+ {
mDoc = xmlParseMemory(data, size);
free(data);
if (!mDoc)
logger->log("Error parsing XML file %s", filename.c_str());
- } else {
+ }
+ else
+ {
logger->log("Error loading %s", filename.c_str());
}
}
@@ -95,7 +98,8 @@ namespace XML
int &ret = def;
xmlChar *prop = xmlGetProp(node, BAD_CAST name);
- if (prop) {
+ if (prop)
+ {
ret = atoi((char*)prop);
xmlFree(prop);
}
@@ -108,7 +112,8 @@ namespace XML
double &ret = def;
xmlChar *prop = xmlGetProp(node, BAD_CAST name);
- if (prop) {
+ if (prop)
+ {
ret = atof((char*)prop);
xmlFree(prop);
}
@@ -120,7 +125,8 @@ namespace XML
const std::string &def)
{
xmlChar *prop = xmlGetProp(node, BAD_CAST name);
- if (prop) {
+ if (prop)
+ {
std::string val = (char*)prop;
xmlFree(prop);
return val;