version.cc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 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 "game/version.h"
  24. #include "console/console.h"
  25. #include "string/stringTable.h"
  26. #include "io/resource/resourceManager.h"
  27. //-----------------------------------------------------------------------------
  28. static const U32 csgVersionNumber = TORQUE_GAME_ENGINE;
  29. static StringTableEntry sgCompanyName = NULL;
  30. static StringTableEntry sgProductName = NULL;
  31. //-----------------------------------------------------------------------------
  32. U32 getVersionNumber()
  33. {
  34. return csgVersionNumber;
  35. }
  36. //-----------------------------------------------------------------------------
  37. const char* getVersionString()
  38. {
  39. return TORQUE_GAME_VERSION_STRING;
  40. }
  41. //-----------------------------------------------------------------------------
  42. const char* getCompileTimeString()
  43. {
  44. return __DATE__ " at " __TIME__;
  45. }
  46. //----------------------------------------------------------------
  47. ConsoleFunction(isDebugBuild, bool, 1, 1, "() Use the isDebugBuild function to determine if this is a debug build.\n"
  48. "@return Returns true if this is a debug build, otherwise false.\n"
  49. "@sa getBuildString, getCompileTimeString, getVersionNumber, getVersionString")
  50. {
  51. #ifdef TORQUE_DEBUG
  52. return true;
  53. #else
  54. return false;
  55. #endif
  56. }
  57. ConsoleFunction( getVersionNumber, S32, 1, 1, "() Use the getVersionNumber function to get the version number of the currently executing engine.\n"
  58. "@return Returns an integer representing the engine's version number.\n"
  59. "@sa getBuildString, getCompileTimeString, getVersionString, isDebugBuild")
  60. {
  61. return getVersionNumber();
  62. }
  63. ConsoleFunction( getVersionString, const char*, 1, 1, "() Use the getVersionString function to get the version name and number for the currently executing engine.\n"
  64. "@return Returns a string containing a name and an integer representing the engine's version type and version number.\n"
  65. "@sa getBuildString, getCompileTimeString, getVersionNumber, isDebugBuild")
  66. {
  67. return getVersionString();
  68. }
  69. ConsoleFunction( getCompileTimeString, const char*, 1, 1, "() Use the getCompileTimeString function to determine when the currently running engine was built.\n"
  70. "@return Returns a string containing \"Month Day Year at Hour:Minute:Second\" showing when this executable was built.\n"
  71. "@sa getBuildString, getVersionNumber, getVersionString, isDebugBuild")
  72. {
  73. return getCompileTimeString();
  74. }
  75. ConsoleFunction( getBuildString, const char*, 1, 1, "() Use the getBuildString function to determine if this build is a \"Debug\" release, or a \"Release\" build.\n"
  76. "@return Returns a string, either \"Debug\" for a debug build, or \"Release\" for a release build.\n"
  77. "@sa getCompileTimeString, getVersionNumber, getVersionString, isDebugBuild")
  78. {
  79. #ifdef TORQUE_DEBUG
  80. return "Debug";
  81. #else
  82. return "Release";
  83. #endif
  84. }
  85. //-----------------------------------------------------------------------------
  86. ConsoleFunction( getEngineVersion, const char*, 1, 1, "() - Gets the engine version.")
  87. {
  88. return T2D_ENGINE_VERSION;
  89. }
  90. //-----------------------------------------------------------------------------
  91. ConsoleFunction( getiPhoneToolsVersion, const char*, 1, 1, "Returns iPhone Tools Version")
  92. {
  93. return T2D_IPHONETOOLS_VERSION;
  94. }
  95. //-----------------------------------------------------------------------------
  96. ConsoleFunction(setCompanyAndProduct, void, 3, 3, "(company, product) Sets the company and product information.")
  97. {
  98. sgCompanyName = StringTable->insert(argv[1]);
  99. sgProductName = StringTable->insert(argv[2]);
  100. Con::setVariable("$Game::CompanyName", sgCompanyName);
  101. Con::setVariable("$Game::ProductName", sgProductName);
  102. char appDataPath[1024];
  103. dSprintf(appDataPath, sizeof(appDataPath), "%s/%s/%s", Platform::getUserDataDirectory(), sgCompanyName, sgProductName);
  104. ResourceManager->addPath(appDataPath);
  105. }