diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-08-29 01:24:49 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-08-29 01:24:49 +0300 |
commit | ca130a19b36a78c6a23aa56c6ea82eaa187b0a06 (patch) | |
tree | a22f311c5698f3f4ee370c0f1d3cb05230a1da95 /src | |
parent | eeffaaf3ab0593f815e772bfb523b9e7a94d45f5 (diff) | |
download | manaplus-ca130a19b36a78c6a23aa56c6ea82eaa187b0a06.tar.gz manaplus-ca130a19b36a78c6a23aa56c6ea82eaa187b0a06.tar.bz2 manaplus-ca130a19b36a78c6a23aa56c6ea82eaa187b0a06.tar.xz manaplus-ca130a19b36a78c6a23aa56c6ea82eaa187b0a06.zip |
Use time_t for time values.
Diffstat (limited to 'src')
33 files changed, 67 insertions, 67 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index b0d8234ca..398d82f48 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -118,7 +118,7 @@ const unsigned int CACHE_SIZE = 50; -int Being::mUpdateConfigTime = 0; +time_t Being::mUpdateConfigTime = 0; unsigned int Being::mConfLineLim = 0; int Being::mSpeechType = 0; bool Being::mHighlightMapPortals = false; diff --git a/src/being/being.h b/src/being/being.h index 0b1bddcf4..78f0ec65c 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -66,7 +66,7 @@ struct HorseInfo; struct SkillInfo; struct ParticleInfo; -extern volatile int cur_time; +extern volatile time_t cur_time; struct NextSoundInfo final { @@ -705,19 +705,19 @@ class Being notfinal : public ActorSprite, void setOtherTime() restrict2 noexcept2 { mOtherTime = cur_time; } - int getMoveTime() const restrict2 noexcept2 + time_t getMoveTime() const restrict2 noexcept2 { return mMoveTime; } - int getAttackTime() const restrict2 noexcept2 + time_t getAttackTime() const restrict2 noexcept2 { return mAttackTime; } - int getTalkTime() const restrict2 noexcept2 + time_t getTalkTime() const restrict2 noexcept2 { return mTalkTime; } - int getTestTime() const restrict2 noexcept2 + time_t getTestTime() const restrict2 noexcept2 { return mTestTime; } - int getOtherTime() const restrict2 noexcept2 + time_t getOtherTime() const restrict2 noexcept2 { return mOtherTime; } void resetCounters() restrict2; @@ -1259,7 +1259,7 @@ class Being notfinal : public ActorSprite, ReachableT mReachable; int mGoodStatus; - static int mUpdateConfigTime; + static time_t mUpdateConfigTime; static unsigned int mConfLineLim; static int mSpeechType; static bool mHighlightMapPortals; @@ -1279,11 +1279,11 @@ class Being notfinal : public ActorSprite, static uint8_t mShowBadges; static int mAwayEffect; - int mMoveTime; - int mAttackTime; - int mTalkTime; - int mOtherTime; - int mTestTime; + time_t mMoveTime; + time_t mAttackTime; + time_t mTalkTime; + time_t mOtherTime; + time_t mTestTime; int mAttackDelay; int mMinHit; int mMaxHit; diff --git a/src/being/flooritem.cpp b/src/being/flooritem.cpp index 00b4ae45a..83857d043 100644 --- a/src/being/flooritem.cpp +++ b/src/being/flooritem.cpp @@ -41,7 +41,7 @@ #include "debug.h" -extern volatile int cur_time; +extern volatile time_t cur_time; FloorItem::FloorItem(const BeingId id, const int itemId, @@ -161,7 +161,7 @@ void FloorItem::draw(Graphics *const graphics, if (mHighlight) { - const int curTime = cur_time; + const time_t curTime = cur_time; font = gui->getFont(); if (mDropTime < curTime) { diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index bf50025fd..1a1155b36 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -343,7 +343,7 @@ void LocalPlayer::logic() void LocalPlayer::slowLogic() { BLOCK_START("LocalPlayer::slowLogic") - const int time = cur_time; + const time_t time = cur_time; if (weightNotice && weightNoticeTime < time) { weightNotice->scheduleDelete(); @@ -1873,11 +1873,11 @@ std::string LocalPlayer::getPingTime() const if (!mPingTime) str = "?"; else - str = toString(mPingTime); + str = toString(CAST_S32(mPingTime)); } else { - int time = tick_time; + time_t time = tick_time; if (time > mPingSendTick) time -= mPingSendTick; else @@ -1885,9 +1885,9 @@ std::string LocalPlayer::getPingTime() const if (time <= mPingTime) time = mPingTime; if (mPingTime != time) - str = strprintf("%d (%d)", mPingTime, time); + str = strprintf("%d (%d)", CAST_S32(mPingTime), CAST_S32(time)); else - str = toString(time); + str = toString(CAST_S32(time)); } return str; } @@ -1954,7 +1954,7 @@ void LocalPlayer::afkRespond(ChatTab *const tab, const std::string &nick) { if (settings.awayMode) { - const int time = cur_time; + const time_t time = cur_time; if (mAfkTime == 0 || time < mAfkTime || time - mAfkTime > awayLimitTimer) { @@ -2490,7 +2490,7 @@ void LocalPlayer::fixPos() const int dx = abs(mX - mCrossX); const int dy = abs(mY - mCrossY); const int dist = dx > dy ? dx : dy; - const int time = cur_time; + const time_t time = cur_time; const int maxDist = mSyncPlayerMove ? mSyncPlayerMoveDistance : 7; if (dist > maxDist) diff --git a/src/being/localplayer.h b/src/being/localplayer.h index e48730f6b..a3d4814e5 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -484,9 +484,9 @@ class LocalPlayer final : public Being, OkDialog *mAwayDialog; int mPingSendTick; - int mPingTime; - int mAfkTime; - int mActivityTime; + time_t mPingTime; + time_t mAfkTime; + time_t mActivityTime; int mNavigateX; int mNavigateY; BeingId mNavigateId; @@ -503,7 +503,7 @@ class LocalPlayer final : public Being, int mAdvertTime; Particle *mTestParticle; std::string mTestParticleName; - int mTestParticleTime; + time_t mTestParticleTime; unsigned long mTestParticleHash; int mSyncPlayerMoveDistance; int mUnfreezeTime; diff --git a/src/client.cpp b/src/client.cpp index 3028bd16b..ca48e4645 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -924,7 +924,7 @@ int Client::gameExec() BLOCK_START("Client::gameExec 4") if (gui) gui->logic(); - cur_time = CAST_S32(time(nullptr)); + cur_time = time(nullptr); int k = 0; while (lastTickTime != tick_time && k < 40) diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp index 4431d5231..659b3faff 100644 --- a/src/dyetool/client.cpp +++ b/src/dyetool/client.cpp @@ -527,7 +527,7 @@ int Client::gameExec() BLOCK_START("Client::gameExec 4") if (gui) gui->logic(); - cur_time = CAST_S32(time(nullptr)); + cur_time = time(nullptr); int k = 0; while (lastTickTime != tick_time && k < 40) { diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 7ed51092d..c4241c29f 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -238,7 +238,7 @@ void EffectManager::triggerDefault(int effectId, void EffectManager::logic() { - const int time = cur_time; + const time_t time = cur_time; bool found(true); while (found) { diff --git a/src/game.cpp b/src/game.cpp index e29eec872..789f87120 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -623,7 +623,7 @@ void Game::slowLogic() BLOCK_START("Game::slowLogic") if (localPlayer) localPlayer->slowLogic(); - const int time = cur_time; + const time_t time = cur_time; if (mTime != time) { if (valTest(Updated)) @@ -725,7 +725,7 @@ void Game::slowLogic() void Game::adjustPerfomance() { FUNC_BLOCK("Game::adjustPerfomance", 1) - const int time = cur_time; + const time_t time = cur_time; if (mNextAdjustTime <= adjustDelay) { mNextAdjustTime = time + adjustDelay; @@ -1123,7 +1123,7 @@ void Game::updateHistory(const SDL_Event &event) bool old = false; const InputActionT key = keyboard.getKeyIndex(event); - const int time = cur_time; + const time_t time = cur_time; int idx = -1; for (int f = 0; f < MAX_LASTKEYS; f ++) { @@ -1178,7 +1178,7 @@ void Game::checkKeys() if (!localPlayer || !settings.attackType) return; - const int time = cur_time; + const time_t time = cur_time; for (int f = 0; f < MAX_LASTKEYS; f ++) { LastKey &lastKey = mLastKeys[f]; diff --git a/src/game.h b/src/game.h index 571107e6a..551378ef2 100644 --- a/src/game.h +++ b/src/game.h @@ -33,7 +33,7 @@ static const int MAX_LASTKEYS = 10; -extern volatile int cur_time; +extern volatile time_t cur_time; class Map; @@ -131,13 +131,13 @@ class Game final std::string mMapName; bool mValidSpeed; LastKey mLastKeys[MAX_LASTKEYS]; - unsigned mNextAdjustTime; + time_t mNextAdjustTime; int mAdjustLevel; bool mAdjustPerfomance; int mLowerCounter; int mPing; - int mTime; - int mTime2; + time_t mTime; + time_t mTime2; static Game *mInstance; }; diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp index 39db3a0e8..ec4da8119 100644 --- a/src/gui/dialogsmanager.cpp +++ b/src/gui/dialogsmanager.cpp @@ -58,7 +58,7 @@ OkDialog *deathNotice = nullptr; DialogsManager *dialogsManager = nullptr; OkDialog *weightNotice = nullptr; -int weightNoticeTime = 0; +time_t weightNoticeTime = 0; #ifndef DYECMD namespace diff --git a/src/gui/fonts/font.h b/src/gui/fonts/font.h index ef7ff9a5a..d8e16936f 100644 --- a/src/gui/fonts/font.h +++ b/src/gui/fonts/font.h @@ -144,7 +144,7 @@ class Font final unsigned int mDeleteCounter; // Word surfaces cache - int mCleanTime; + time_t mCleanTime; mutable TextChunkList mCache[CACHES_NUMBER]; }; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 410891416..66ada43b2 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -345,7 +345,7 @@ void Gui::slowLogic() if (windowContainer) windowContainer->slowLogic(); - const int time = cur_time; + const time_t time = cur_time; if (mTime != time) { logger->flush(); diff --git a/src/gui/gui.h b/src/gui/gui.h index c27d7e8a8..9d42fcd3c 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -529,7 +529,7 @@ class Gui final FocusListenerList mFocusListeners; Color mForegroundColor; Color mForegroundColor2; - int mTime; + time_t mTime; bool mCustomCursor; /**< Show custom cursor */ bool mDoubleClick; }; diff --git a/src/gui/viewport.h b/src/gui/viewport.h index d189b2415..802ba8ffe 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -238,7 +238,7 @@ class Viewport final : public WindowContainer, int mViewXmax; int mViewYmax; - int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */ + time_t mLocalWalkTime; /**< Timestamp before the next walk can be sent. */ int mCameraRelativeX; int mCameraRelativeY; diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index d0655631c..74acc8847 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -228,7 +228,7 @@ class BrowserBox final : public Widget, int mHeight; int mWidth; int mYStart; - int mUpdateTime; + time_t mUpdateTime; int mPadding; unsigned int mNewLinePadding; int mItemPadding; diff --git a/src/gui/widgets/tabs/debugwindowtabs.h b/src/gui/widgets/tabs/debugwindowtabs.h index ca1527fa6..43292bcd5 100644 --- a/src/gui/widgets/tabs/debugwindowtabs.h +++ b/src/gui/widgets/tabs/debugwindowtabs.h @@ -68,7 +68,7 @@ class MapDebugTab final : public DebugTab Label *mMapActorCountLabel A_NONNULLPOINTER; Label *mXYLabel A_NONNULLPOINTER; Label *mTexturesLabel A_NONNULLPOINTER; - int mUpdateTime; + time_t mUpdateTime; #ifdef DEBUG_DRAW_CALLS Label *mDrawCallsLabel A_NONNULLPOINTER; #endif diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 89606d27c..aa016ef04 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -277,7 +277,7 @@ class TextField notfinal : public Widget, static ImageRect skin; int mMinimum; int mMaximum; - int mLastEventPaste; + time_t mLastEventPaste; int mPadding; bool mNumeric; bool mLoseFocusOnTab; diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index dfc3c616e..68b57b077 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -289,7 +289,7 @@ void KillStats::gainXp(int xp) void KillStats::recalcStats() { BLOCK_START("KillStats::recalcStats") - const int curTime = cur_time; + const time_t curTime = cur_time; // Need Update Exp Counter if (curTime - m1minExpTime > 60) diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h index d3b7a88b8..db41cf0e2 100644 --- a/src/gui/windows/killstats.h +++ b/src/gui/windows/killstats.h @@ -73,7 +73,7 @@ class KillStats final : public Window, const int newVal) override final; private: - int mKillTimer; /**< Timer for kill stats. */ + time_t mKillTimer; /**< Timer for kill stats. */ Button *mResetButton A_NONNULLPOINTER; Button *mTimerButton A_NONNULLPOINTER; Label *mLine1; @@ -98,15 +98,15 @@ class KillStats final : public Window, int mKillTCounter; /**< Timer Kill counter. */ int mExpTCounter; /**< Timer Exp counter. */ - int m1minExpTime; + time_t m1minExpTime; int m1minExpNum; int m1minSpeed; - int m5minExpTime; + time_t m5minExpTime; int m5minExpNum; int m5minSpeed; - int m15minExpTime; + time_t m15minExpTime; int m15minExpNum; int m15minSpeed; }; diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index cab3bcb37..e98d9ce1a 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -1030,7 +1030,7 @@ void ShopWindow::updateTimes() BLOCK_END("ShopWindow::updateTimes") } -bool ShopWindow::checkFloodCounter(int &counterTime) +bool ShopWindow::checkFloodCounter(time_t &counterTime) { if (!counterTime || counterTime > cur_time) counterTime = cur_time; diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index 3123178e7..50d924a1f 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -136,7 +136,7 @@ class ShopWindow final : public Window, const int mode); void updateTimes(); - static bool checkFloodCounter(int &counterTime) A_WARN_UNUSED; + static bool checkFloodCounter(time_t &counterTime) A_WARN_UNUSED; bool findShopItem(const ShopItem *const shopItem, const int mode) const A_WARN_UNUSED; @@ -188,9 +188,9 @@ class ShopWindow final : public Window, std::string mTradeNick; std::string mSellShopName; int mSelectedItem; - int mAnnonceTime; - int mLastRequestTimeList; - int mLastRequestTimeItem; + time_t mAnnonceTime; + time_t mLastRequestTimeList; + time_t mLastRequestTimeItem; int mRandCounter; int mTradeMoney; int mSellShopSize; diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 055b19ed8..0ab894ba6 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -464,7 +464,7 @@ void SocialWindow::updateActiveList() void SocialWindow::slowLogic() { BLOCK_START("SocialWindow::slowLogic") - const unsigned int nowTime = cur_time; + const time_t nowTime = cur_time; if (mNeedUpdate && nowTime - mLastUpdateTime > 1) { mPlayers->updateList(); diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index 4c2f82068..ad60c9ca8 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -160,7 +160,7 @@ class SocialWindow final : public Window, TabbedArea *mTabs A_NONNULLPOINTER; Map *mMap; - int mLastUpdateTime; + time_t mLastUpdateTime; int mPartyId; bool mNeedUpdate; bool mProcessedPortals; diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index 4bc7d0ca2..5233a17ad 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -134,7 +134,7 @@ class WhoIsOnline final : public Window, UPDATE_LIST }; - int mUpdateTimer; + time_t mUpdateTimer; /** A thread that use libcurl to download updates. */ SDL_Thread *mThread; diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 8ce8ec59d..44a8cb736 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -35,7 +35,7 @@ ChatHandler::ChatHandler() { if (!ChatRecv::mSentWhispers.empty()) ChatRecv::mSentWhispers.pop(); - ChatRecv::mMotdTime = -1; + ChatRecv::mMotdTime = 0; ChatRecv::mShowAllLang = serverConfig.getValue("showAllLang", 0); ChatRecv::mShowMotd = config.getBoolValue("showmotd"); ChatRecv::mSkipping = true; diff --git a/src/net/ea/chatrecv.cpp b/src/net/ea/chatrecv.cpp index 4e4695cf6..ee994b7e4 100644 --- a/src/net/ea/chatrecv.cpp +++ b/src/net/ea/chatrecv.cpp @@ -46,7 +46,7 @@ namespace Ea namespace ChatRecv { WhisperQueue mSentWhispers; - int mMotdTime = -1; + time_t mMotdTime = 0; bool mShowAllLang = false; bool mShowMotd = false; bool mSkipping = true; diff --git a/src/net/ea/chatrecv.h b/src/net/ea/chatrecv.h index 374d6c12a..2904fc58b 100644 --- a/src/net/ea/chatrecv.h +++ b/src/net/ea/chatrecv.h @@ -53,7 +53,7 @@ namespace Ea std::string getLastWhisperNick(); extern WhisperQueue mSentWhispers; - extern int mMotdTime; + extern time_t mMotdTime; extern bool mShowAllLang; extern bool mShowMotd; extern bool mSkipping; diff --git a/src/net/packetcounters.cpp b/src/net/packetcounters.cpp index 13eae4701..f29bb890c 100644 --- a/src/net/packetcounters.cpp +++ b/src/net/packetcounters.cpp @@ -24,7 +24,7 @@ #include "debug.h" -extern volatile int cur_time; +extern volatile time_t cur_time; extern volatile bool runCounters; int PacketCounters::mInCurrentSec = 0; @@ -108,7 +108,7 @@ void PacketCounters::updateCounter(int &restrict currentSec, int &restrict calc, int &restrict counter) { - const int idx = cur_time % 60; + const time_t idx = cur_time % 60; if (currentSec != idx) { currentSec = idx; diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp index 54c13545a..1d74fef4c 100644 --- a/src/net/tmwa/chatrecv.cpp +++ b/src/net/tmwa/chatrecv.cpp @@ -93,7 +93,7 @@ void ChatRecv::processChatContinue(std::string chatMsg, channel.empty()) { // skip motd from "new" tmw server - if (Ea::ChatRecv::mMotdTime == -1) + if (Ea::ChatRecv::mMotdTime == 0) { Ea::ChatRecv::mMotdTime = cur_time + 1; } diff --git a/src/net/tmwa/guildmanager.h b/src/net/tmwa/guildmanager.h index 24ace9e77..b47c498d6 100644 --- a/src/net/tmwa/guildmanager.h +++ b/src/net/tmwa/guildmanager.h @@ -96,7 +96,7 @@ class GuildManager final StringVect mTempList; EmulateGuildTab *mTab; bool mRequest; - int mRequestTime; + time_t mRequestTime; bool mGotOnlineInfo; }; diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp index fdb4a0c5a..dff2816a8 100644 --- a/src/utils/timer.cpp +++ b/src/utils/timer.cpp @@ -50,7 +50,7 @@ volatile int fps = 0; /**< Frames counted in the last second */ volatile int lps = 0; /**< Logic processed per second */ volatile int frame_count = 0; /**< Counts the frames during one second */ volatile int logic_count = 0; /**< Counts the logic during one second */ -volatile int cur_time; +volatile time_t cur_time = 0; static uint32_t nextTick(uint32_t interval, void *param A_UNUSED); static uint32_t nextSecond(uint32_t interval, void *param A_UNUSED); diff --git a/src/utils/timer.h b/src/utils/timer.h index 2e58fe508..5518622cc 100644 --- a/src/utils/timer.h +++ b/src/utils/timer.h @@ -26,7 +26,7 @@ extern volatile int fps; extern volatile int lps; extern volatile int tick_time; -extern volatile int cur_time; +extern volatile time_t cur_time; extern volatile int frame_count; extern volatile int logic_count; |