diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-25 22:18:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-25 22:18:26 +0300 |
commit | 853757df15383c2e9cc33023dc04a256c458e671 (patch) | |
tree | f12cf49d6ddc17b6b4fc96d066359872b108f144 /src | |
parent | 8e57e80d73a58077615924d50ac206d19efddae6 (diff) | |
download | manaverse-853757df15383c2e9cc33023dc04a256c458e671.tar.gz manaverse-853757df15383c2e9cc33023dc04a256c458e671.tar.bz2 manaverse-853757df15383c2e9cc33023dc04a256c458e671.tar.xz manaverse-853757df15383c2e9cc33023dc04a256c458e671.zip |
fix some code style by cpplint.
Diffstat (limited to 'src')
30 files changed, 22 insertions, 69 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 2e21c3432..6875936c4 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -82,9 +82,6 @@ bool ActorSprite::draw(Graphics *const graphics, const int offsetX, const int offsetY) const { FUNC_BLOCK("ActorSprite::draw", 1) - // TODO: Eventually, we probably should fix all sprite offsets so that - // these translations aren't necessary anymore. The sprites know - // best where their base point should be. const int px = getPixelX() + offsetX - 16; // Temporary fix to the Y offset. #ifdef MANASERV_SUPPORT diff --git a/src/being.cpp b/src/being.cpp index 66d5249c1..3ebfb77af 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -197,7 +197,6 @@ std::list<BeingCacheEntry*> beingInfoCache; typedef std::map<int, Guild*>::const_iterator GuildsMapCIter; typedef std::map<int, int>::const_iterator IntMapCIter; -// TODO: mWalkTime used by eAthena only Being::Being(const int id, const Type type, const uint16_t subtype, Map *const map) : ActorSprite(id), diff --git a/src/client.cpp b/src/client.cpp index e22f50fea..aac1d8139 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -138,7 +138,6 @@ */ static const int MAX_TICK_VALUE = INT_MAX / 2; -// TODO: Get rid fo these globals std::string errorMessage; ErrorListener errorListener; LoginData loginData; @@ -1059,7 +1058,6 @@ int Client::gameExec() BLOCK_END("~Client::SDL_framerateDelay") BLOCK_START("Client::gameExec 6") - // TODO: Add connect timeouts if (mState == STATE_CONNECT_GAME && Net::getGameHandler()->isConnected()) { @@ -1663,7 +1661,6 @@ int Client::gameExec() case STATE_LOGOUT_ATTEMPT: logger->log1("State: LOGOUT ATTEMPT"); - // TODO break; case STATE_WAIT: diff --git a/src/commands.cpp b/src/commands.cpp index 8f03780ba..3ef4dbd40 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1101,7 +1101,7 @@ impHandler0(testsdlfont) delete nullGraphics; delete font; - long int diff = (static_cast<long long int>( + int64_t diff = (static_cast<long long int>( time2.tv_sec) * 1000000000LL + static_cast<long long int>( time2.tv_nsec)) / 100000 - (static_cast<long long int>( time1.tv_sec) * 1000000000LL + static_cast<long long int>( diff --git a/src/game.cpp b/src/game.cpp index 758e26064..016e4dded 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -532,8 +532,8 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot) if (success) { std::stringstream chatlogentry; - // TODO: Make it one complete gettext string below - chatlogentry << _("Screenshot saved as ") << filenameSuffix.str(); + chatlogentry << strprintf(_("Screenshot saved as %s"), + filenameSuffix.str().c_str()); if (localChatTab) localChatTab->chatLog(chatlogentry.str(), BY_SERVER); } diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h index 82b04ca85..417adc42e 100644 --- a/src/gui/beingpopup.h +++ b/src/gui/beingpopup.h @@ -50,8 +50,6 @@ class BeingPopup final : public Popup */ void show(const int x, const int y, Being *const b); - // TODO: Add a version for monsters, NPCs, etc? - private: Label *mBeingName; Label *mBeingParty; diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 936adc2d5..3930ae715 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -407,9 +407,6 @@ void BuyDialog::action(const gcn::ActionEvent &event) mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } - // TODO: Actually we'd have a bug elsewhere if this check for the number - // of items to be bought ever fails, Bertram removed the assertions, is - // there a better way to ensure this fails in an _obvious_ way in C++? else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems) { if (mNpcId != -1) diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index ecb24849f..0b56b300a 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -83,7 +83,7 @@ extern int serverVersion; std::string tradePartnerName(""); -PopupMenu::PopupMenu(): +PopupMenu::PopupMenu() : Popup("PopupMenu", "popupmenu.xml"), mBrowserBox(new BrowserBox(this)), mScrollArea(nullptr), @@ -1736,7 +1736,6 @@ void PopupMenu::showPopup(Window *const parent, const int x, const int y, mBrowserBox->addRow("split", _("Split")); } // Assume in storage for now - // TODO: make this whole system more flexible, if needed else { mBrowserBox->addRow("retrieve", _("Retrieve")); diff --git a/src/gui/registerdialog.cpp b/src/gui/registerdialog.cpp index bb76bc8b2..8628e4010 100644 --- a/src/gui/registerdialog.cpp +++ b/src/gui/registerdialog.cpp @@ -229,8 +229,6 @@ void RegisterDialog::action(const gcn::ActionEvent &event) error = 2; } - // TODO: Check if a valid email address was given - if (error > 0) { if (error == 1) diff --git a/src/gui/sdlfont_unittest.cc b/src/gui/sdlfont_unittest.cc index 7575772f0..eab4d2994 100644 --- a/src/gui/sdlfont_unittest.cc +++ b/src/gui/sdlfont_unittest.cc @@ -256,9 +256,12 @@ TEST(TextChunkList, moveToFirst4) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", gcn::Color(), gcn::Color()); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", gcn::Color(), gcn::Color()); - SDLTextChunk *chunk3 = new SDLTextChunk("test3", gcn::Color(), gcn::Color()); + SDLTextChunk *chunk1 = new SDLTextChunk("test", + gcn::Color(), gcn::Color()); + SDLTextChunk *chunk2 = new SDLTextChunk("test2", + gcn::Color(), gcn::Color()); + SDLTextChunk *chunk3 = new SDLTextChunk("test3", + gcn::Color(), gcn::Color()); list.insertFirst(chunk1); list.insertFirst(chunk3); diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index f52bbb09c..a46e8d5bd 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -343,11 +343,7 @@ void Setup_Colors::setEntry(Slider *const s, TextField *const t, if (s) s->setValue(value); if (t) - { - char buffer[100]; - sprintf(buffer, "%d", value); - t->setText(buffer); - } + t->setText(toString(value)); } void Setup_Colors::apply() diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index b787c685e..b0a80eaa4 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -219,7 +219,6 @@ public: void invite() { - // TODO - Give feedback on whether the invite succeeded mInviteDialog = new TextDialog(_("Member Invite to Guild"), strprintf(_("Who would you like to invite to guild %s?"), mGuild->getName().c_str()), @@ -393,7 +392,6 @@ public: void invite() { - // TODO - Give feedback on whether the invite succeeded mInviteDialog = new TextDialog(_("Member Invite to Party"), strprintf(_("Who would you like to invite to party %s?"), mParty->getName().c_str()), @@ -1506,10 +1504,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) std::string name = mGuildCreateDialog->getText(); if (name.size() > 16) - { - // TODO : State too many characters in input. return; - } Net::getGuildHandler()->create(name); if (localChatTab) @@ -1529,10 +1524,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) std::string name = mPartyCreateDialog->getText(); if (name.size() > 16) - { - // TODO : State too many characters in input. return; - } Net::getPartyHandler()->create(name); if (localChatTab) diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 935408714..0542bf6eb 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -517,7 +517,6 @@ void UpdaterWindow::download() setLabel(mCurrentFile + " (0%)"); mDownloadComplete = false; - // TODO: check return mDownload->start(); } @@ -648,7 +647,6 @@ void UpdaterWindow::logic() switch (mDownloadStatus) { case UPDATE_ERROR: - // TODO: Only send complete sentences to gettext mBrowserBox->addRow(""); mBrowserBox->addRow(_("##1 The update process is incomplete.")); // TRANSLATORS: Continues "you try again later.". diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 9077da6c0..e378aef6c 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -183,7 +183,8 @@ UserPalette::~UserPalette() if (col->grad == STATIC || col->grad == PULSE) { char buffer[20]; - sprintf(buffer, "0x%06x", col->getRGB()); + snprintf(buffer, sizeof(buffer), "0x%06x", col->getRGB()); + buffer[19] = 0; config.setValue(configName, std::string(buffer)); } } @@ -286,7 +287,8 @@ void UserPalette::addColor(const unsigned type, const unsigned rgb, const std::string &configName = ColorTypeNames[type]; char buffer[20]; - sprintf(buffer, "0x%06x", rgb); + snprintf(buffer, sizeof(buffer), "0x%06x", rgb); + buffer[19] = 0; const std::string rgbString = config.getValue(configName, std::string(buffer)); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 35cd2aa32..2edd5d67b 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -516,8 +516,6 @@ int BrowserBox::calcHeight() prevColor[1] = selColor[1]; bold = false; - // TODO: Check if we must take texture size limits into account here - // TODO: Check if some of the O(n) calls can be removed for (size_t start = 0, end = std::string::npos; start != std::string::npos; start = end, end = std::string::npos) diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index b4eef0352..95f46385b 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -174,7 +174,6 @@ void ChatTab::chatLog(std::string line, Own own, break; case BY_CHANNEL: tmp.nick.clear(); - // TODO: Use a predefined color lineColor = "##2"; // Equiv. to BrowserBox::GREEN break; case ACT_WHISPER: diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index ed9436c11..1f3d71192 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -133,8 +133,6 @@ void Tab::updateAlpha() const float alpha = std::max(Client::getGuiAlpha(), Theme::instance()->getMinimumOpacity()); - // TODO We don't need to do this for every tab on every draw - // Maybe use a config listener to do it as the value changes. if (alpha != mAlpha) { mAlpha = alpha; diff --git a/src/joystick.cpp b/src/joystick.cpp index 1527cd544..324de047d 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -90,7 +90,6 @@ bool Joystick::open() mJoystick = SDL_JoystickOpen(mNumber); - // TODO Bail out! if (!mJoystick) { logger->log("Couldn't open joystick: %s", SDL_GetError()); diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index 27eebc3fb..dda73014e 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -111,7 +111,7 @@ void MumbleManager::init() #elif defined BSD4_4 #else char memName[256]; - snprintf(memName, 256, "/MumbleLink.%u", getuid()); + snprintf(memName, sizeof(memName), "/MumbleLink.%u", getuid()); const int shmfd = shm_open(memName, O_RDWR, S_IRUSR | S_IWUSR); diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 6c24954b7..9f1bdabe0 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -233,8 +233,6 @@ void Network::receive() while (mState == CONNECTED) { - // TODO Try to get this to block all the time while still being able - // to escape the loop const int numReady = TcpNet::checkSockets( set, (static_cast<uint32_t>(500))); switch (numReady) diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 51e006779..93bc990f5 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -39,17 +39,14 @@ void NpcHandler::sendLetter(const int npcId A_UNUSED, const std::string &recipient A_UNUSED, const std::string &text A_UNUSED) const { - // TODO } void NpcHandler::startShopping(const int beingId A_UNUSED) const { - // TODO } void NpcHandler::endShopping(const int beingId A_UNUSED) const { - // TODO } void NpcHandler::clearDialogs() diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index e7b6c69b2..3c8627f4b 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -48,7 +48,6 @@ extern int weightNoticeTime; // everything beyond will reset the port hard. static const int MAP_TELEPORT_SCROLL_DISTANCE = 8; -// TODO Move somewhere else namespace { /** diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index aa6952b65..91bd4de69 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -70,7 +70,6 @@ TradeHandler::TradeHandler() void TradeHandler::removeItem(const int slotNum A_UNUSED, const int amount A_UNUSED) const { - // TODO } void TradeHandler::processTradeRequest(Net::MessageIn &msg) @@ -185,7 +184,6 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg) const int refine = msg.readInt8(); // refine msg.skip(8); // card (4 shorts) - // TODO: handle also identified, etc if (tradeWindow) { if (type == 0) diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp index 8785fd83c..5deb326fa 100644 --- a/src/net/eathena/guildhandler.cpp +++ b/src/net/eathena/guildhandler.cpp @@ -277,7 +277,6 @@ void GuildHandler::chat(const int guildId A_UNUSED, void GuildHandler::memberList(const int guildId A_UNUSED) const { - // TODO four types of info requests: // 0 = basic info + alliance info // 1 = position name list + member list // 2 = position name list + position info list @@ -290,7 +289,6 @@ void GuildHandler::memberList(const int guildId A_UNUSED) const void GuildHandler::info(const int guildId A_UNUSED) { - // TODO four types of info requests: // 0 = basic info + alliance info // 1 = position name list + member list // 2 = position name list + position info list diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index b19419407..11eb7fcf0 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -172,7 +172,6 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const if (!item) return; - // TODO: Fix wrong coordinates of drops, serverside? (what's wrong here?) MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP); outMsg.writeInt16(static_cast<int16_t>( item->getInvIndex() + INVENTORY_OFFSET)); diff --git a/src/net/net.cpp b/src/net/net.cpp index bb3160cda..f22a87695 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -149,12 +149,6 @@ ServerInfo::Type networkType = ServerInfo::UNKNOWN; void connectToServer(const ServerInfo &server) { - if (server.type == ServerInfo::UNKNOWN) - { - // TODO: Query the server about itself and choose the netcode based on - // that - } - if (networkType == server.type && getGeneralHandler()) { getGeneralHandler()->reload(); diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 69d5f0e41..59756e2c9 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -278,7 +278,6 @@ void GuildHandler::chat(const int guildId A_UNUSED, void GuildHandler::memberList(const int guildId A_UNUSED) const { - // TODO four types of info requests: // 0 = basic info + alliance info // 1 = position name list + member list // 2 = position name list + position info list @@ -291,7 +290,6 @@ void GuildHandler::memberList(const int guildId A_UNUSED) const void GuildHandler::info(const int guildId A_UNUSED) { - // TODO four types of info requests: // 0 = basic info + alliance info // 1 = position name list + member list // 2 = position name list + position info list diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 561f3ec90..d1cfc7136 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -174,7 +174,6 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const if (!item) return; - // TODO: Fix wrong coordinates of drops, serverside? (what's wrong here?) MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP); outMsg.writeInt16(static_cast<int16_t>( item->getInvIndex() + INVENTORY_OFFSET)); diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 58dffa131..3530d0e96 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -116,7 +116,7 @@ void Wallpaper::loadWallpapers() if (separator == std::string::npos) { // Then, append the width and height search mask. - filename.append("_%dx%d.png"); + filename.append("_%10dx%10d.png"); int width; int height; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 88349d407..a07cd1a96 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -78,11 +78,12 @@ const char *ipToString(const int address) { static char asciiIP[18]; - sprintf(asciiIP, "%i.%i.%i.%i", + snprintf(asciiIP, sizeof(asciiIP), "%i.%i.%i.%i", static_cast<unsigned char>(address), static_cast<unsigned char>(address >> 8), static_cast<unsigned char>(address >> 16), static_cast<unsigned char>(address >> 24)); + asciiIP[17] = 0; return asciiIP; } @@ -93,6 +94,7 @@ std::string strprintf(const char *const format, ...) va_list(args); va_start(args, format); int nb = vsnprintf(buf, 256, format, args); + buf[256] = 0; va_end(args); if (nb < 256) return buf; @@ -659,6 +661,7 @@ std::string decodeLinkText(std::string data) std::string toStringPrint(const unsigned int val) { static char str[100]; - sprintf(str, "%u 0x%x", val, val); + snprintf(str, sizeof(str), "%u 0x%x", val, val); + str[99] = 0; return str; } |