version.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/platform.h"
  23. #include "app/version.h"
  24. #include "console/console.h"
  25. static const U32 csgVersionNumber = TORQUE_GAME_ENGINE;
  26. U32 getVersionNumber()
  27. {
  28. return csgVersionNumber;
  29. }
  30. const char* getVersionString()
  31. {
  32. return TORQUE_GAME_ENGINE_VERSION_STRING;
  33. }
  34. /// TGE 0001
  35. /// TGEA 0002
  36. /// TGB 0003
  37. /// TGEA 360 0004
  38. /// TGE WII 0005
  39. /// Torque 3D 0006
  40. const char* getEngineProductString()
  41. {
  42. #ifndef TORQUE_ENGINE_PRODUCT
  43. return "Torque Engine";
  44. #else
  45. switch (TORQUE_ENGINE_PRODUCT)
  46. {
  47. case 0001:
  48. return "Torque Game Engine";
  49. case 0002:
  50. return "Torque Game Engine Advanced";
  51. case 0003:
  52. return "Torque 2D";
  53. case 0004:
  54. return "Torque 360";
  55. case 0005:
  56. return "Torque for Wii";
  57. case 0006:
  58. return "Torque 3D";
  59. case 0007:
  60. return "Torque 3D MIT";
  61. default:
  62. return "Torque Engine";
  63. };
  64. #endif
  65. }
  66. const char* getCompileTimeString()
  67. {
  68. return __DATE__ " at " __TIME__;
  69. }
  70. //----------------------------------------------------------------
  71. ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." );
  72. ConsoleFunction( getVersionNumber, S32, 1, 1, "Get the version of the build, as a string.\n\n"
  73. "@ingroup Debugging")
  74. {
  75. return getVersionNumber();
  76. }
  77. ConsoleFunction( getVersionString, const char*, 1, 1, "Get the version of the build, as a string.\n\n"
  78. "@ingroup Debugging")
  79. {
  80. return getVersionString();
  81. }
  82. ConsoleFunction( getEngineName, const char*, 1, 1, "Get the name of the engine product that this is running from, as a string.\n\n"
  83. "@ingroup Debugging")
  84. {
  85. return getEngineProductString();
  86. }
  87. ConsoleFunction( getCompileTimeString, const char*, 1, 1, "Get the time of compilation.\n\n"
  88. "@ingroup Debugging")
  89. {
  90. return getCompileTimeString();
  91. }
  92. ConsoleFunction( getBuildString, const char*, 1, 1, "Get the type of build, \"Debug\" or \"Release\".\n\n"
  93. "@ingroup Debugging")
  94. {
  95. #ifdef TORQUE_DEBUG
  96. return "Debug";
  97. #else
  98. return "Release";
  99. #endif
  100. }
  101. ConsoleFunctionGroupEnd( CompileInformation );
  102. ConsoleFunction(isDemo, bool, 1, 1, "")
  103. {
  104. #ifdef TORQUE_DEMO
  105. return true;
  106. #else
  107. return false;
  108. #endif
  109. }
  110. ConsoleFunction(isWebDemo, bool, 1, 1, "")
  111. {
  112. #ifdef TORQUE_DEMO
  113. return Platform::getWebDeployment();
  114. #else
  115. return false;
  116. #endif
  117. }