Changeable.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #include "stdh.h"
  13. #include <Engine/Base/Changeable.h>
  14. #include <Engine/Base/ChangeableRT.h>
  15. #include <Engine/Base/Updateable.h>
  16. #include <Engine/Base/UpdateableRT.h>
  17. #include <Engine/Base/Timer.h>
  18. /*
  19. * Constructor.
  20. */
  21. CChangeable::CChangeable(void)
  22. {
  23. ch_LastChangeTime = TIME(-1);
  24. }
  25. /*
  26. * Mark that something has changed in this object.
  27. */
  28. void CChangeable::MarkChanged(void)
  29. {
  30. ch_LastChangeTime = _pTimer->CurrentTick();
  31. }
  32. /*
  33. * Test if some updateable object is up to date with this changeable.
  34. */
  35. BOOL CChangeable::IsUpToDate(const CUpdateable &ud) const
  36. {
  37. return ch_LastChangeTime < ud.LastUpdateTime();
  38. }
  39. /*
  40. * Constructor.
  41. */
  42. CChangeableRT::CChangeableRT(void)
  43. {
  44. ch_LastChangeTime = TIME(-1);
  45. }
  46. /*
  47. * Mark that something has changed in this object.
  48. */
  49. void CChangeableRT::MarkChanged(void)
  50. {
  51. ch_LastChangeTime = _pTimer->GetRealTimeTick();
  52. }
  53. /*
  54. * Test if some updateable object is up to date with this changeable.
  55. */
  56. BOOL CChangeableRT::IsUpToDate(const CUpdateableRT &ud) const
  57. {
  58. return ch_LastChangeTime < ud.LastUpdateTime();
  59. }