afSettings.cpp
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:7k
源码类别:

其他游戏

开发平台:

Visual C++

  1. #pragma warning(disable: 4514)
  2. #include "afSettings.h"
  3. #include <direct.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. char* afSettings::pathApp = NULL;
  7. char* afSettings::pathAni = NULL;
  8. char* afSettings::pathAudio = NULL;
  9. char* afSettings::pathBSP = NULL;
  10. char* afSettings::pathChar = NULL;
  11. char* afSettings::pathGame = NULL;
  12. char* afSettings::pathPath = NULL;
  13. char* afSettings::pathLevel = NULL;
  14. char* afSettings::pathMD2 = NULL;
  15. char* afSettings::pathOBJ = NULL;
  16. char* afSettings::pathPS = NULL;
  17. char* afSettings::pathTex = NULL;
  18. char* afSettings::pathTerrain = NULL;
  19. char* afSettings::pathBspTex = NULL;
  20. char* createFullPath(const char* nPath1, const char* nPath2)
  21. {
  22. char* fullPath = new char[strlen(nPath1)+strlen(nPath2)+2];
  23. strcpy(fullPath, nPath1);
  24. strcat(fullPath, "\");
  25. strcat(fullPath, nPath2);
  26. return fullPath;
  27. }
  28. void afSettings::init()
  29. {
  30. pathApp = new char[_MAX_PATH];
  31. _getcwd(pathApp, _MAX_PATH);
  32. pathAni = createFullPath(pathApp, "animation");
  33. pathAudio = createFullPath(pathApp, "audio");
  34. pathBSP = createFullPath(pathApp, "bsp");
  35. pathChar = createFullPath(pathApp, "game");
  36. pathGame = createFullPath(pathApp, "game");
  37. pathPath = createFullPath(pathApp, "path");
  38. pathLevel = createFullPath(pathApp, "level");
  39. pathMD2 = createFullPath(pathApp, "md2");
  40. pathOBJ = createFullPath(pathApp, "obj");
  41. pathPS = createFullPath(pathApp, "animation");
  42. pathTerrain = createFullPath(pathApp, "terrain");
  43. pathTex = createFullPath(pathApp, "texture");
  44. pathBspTex = createFullPath(pathApp, "bsp");
  45. }
  46. char* afSettings::tmpFullPath(const char* nFileName, const char* nExt)
  47. {
  48. static char fullPath[_MAX_PATH];
  49. strcpy(fullPath, pathApp);
  50. strcat(fullPath, "\");
  51. strcat(fullPath, nFileName);
  52. if(nExt)
  53. strcat(fullPath, nExt);
  54. return fullPath;
  55. }
  56. void afSettings::extendToAniPath(const char* nFileName, char* nFullName)
  57. {
  58. strcpy(nFullName, pathAni);
  59. strcat(nFullName, "\");
  60. strcat(nFullName, nFileName);
  61. }
  62. char* afSettings::tmpFullAniPath(const char* nFileName, const char* nExt)
  63. {
  64. static char fullPath[_MAX_PATH];
  65. extendToAniPath(nFileName, fullPath);
  66. if(nExt)
  67. strcat(fullPath, nExt);
  68. return fullPath;
  69. }
  70. void afSettings::extendToBSPPath(const char* nFileName, char* nFullName)
  71. {
  72. strcpy(nFullName, pathBSP);
  73. strcat(nFullName, "\");
  74. strcat(nFullName, nFileName);
  75. }
  76. char* afSettings::tmpFullBSPPath(const char* nFileName, const char* nExt)
  77. {
  78. static char fullPath[_MAX_PATH];
  79. extendToBSPPath(nFileName, fullPath);
  80. if(nExt)
  81. strcat(fullPath, nExt);
  82. return fullPath;
  83. }
  84. void afSettings::extendToCharPath(const char* nFileName, char* nFullName)
  85. {
  86. strcpy(nFullName, pathChar);
  87. strcat(nFullName, "\");
  88. strcat(nFullName, nFileName);
  89. }
  90. char* afSettings::tmpFullCharPath(const char* nFileName, const char* nExt)
  91. {
  92. static char fullPath[_MAX_PATH];
  93. extendToCharPath(nFileName, fullPath);
  94. if(nExt)
  95. strcat(fullPath, nExt);
  96. return fullPath;
  97. }
  98. void afSettings::extendToAudioPath(const char* nFileName, char* nFullName)
  99. {
  100. strcpy(nFullName, pathAudio);
  101. strcat(nFullName, "\");
  102. strcat(nFullName, nFileName);
  103. }
  104. char* afSettings::tmpFullAudioPath(const char* nFileName, const char* nExt)
  105. {
  106. static char fullPath[_MAX_PATH];
  107. extendToAudioPath(nFileName, fullPath);
  108. if(nExt)
  109. strcat(fullPath, nExt);
  110. return fullPath;
  111. }
  112. void afSettings::extendToGamePath(const char* nFileName, char* nFullName)
  113. {
  114. strcpy(nFullName, pathGame);
  115. strcat(nFullName, "\");
  116. strcat(nFullName, nFileName);
  117. }
  118. char* afSettings::tmpFullGamePath(const char* nFileName, const char* nExt)
  119. {
  120. static char fullPath[_MAX_PATH];
  121. extendToGamePath(nFileName, fullPath);
  122. if(nExt)
  123. strcat(fullPath, nExt);
  124. return fullPath;
  125. }
  126. void afSettings::extendToPathPath(const char* nFileName, char* nFullName)
  127. {
  128. strcpy(nFullName, pathPath);
  129. strcat(nFullName, "\");
  130. strcat(nFullName, nFileName);
  131. }
  132. char* afSettings::tmpFullPathPath(const char* nFileName, const char* nExt)
  133. {
  134. static char fullPath[_MAX_PATH];
  135. extendToPathPath(nFileName, fullPath);
  136. if(nExt)
  137. strcat(fullPath, nExt);
  138. return fullPath;
  139. }
  140. void afSettings::extendToLevelPath(const char* nFileName, char* nFullName)
  141. {
  142. strcpy(nFullName, pathLevel);
  143. strcat(nFullName, "\");
  144. strcat(nFullName, nFileName);
  145. }
  146. char* afSettings::tmpFullLevelPath(const char* nFileName, const char* nExt)
  147. {
  148. static char fullPath[_MAX_PATH];
  149. extendToLevelPath(nFileName, fullPath);
  150. if(nExt)
  151. strcat(fullPath, nExt);
  152. return fullPath;
  153. }
  154. void afSettings::extendToMD2Path(const char* nFileName, char* nFullName)
  155. {
  156. strcpy(nFullName, pathMD2);
  157. strcat(nFullName, "\");
  158. strcat(nFullName, nFileName);
  159. }
  160. char* afSettings::tmpFullMD2Path(const char* nFileName, const char* nExt)
  161. {
  162. static char fullPath[_MAX_PATH];
  163. extendToMD2Path(nFileName, fullPath);
  164. if(nExt)
  165. strcat(fullPath, nExt);
  166. return fullPath;
  167. }
  168. void afSettings::extendToOBJPath(const char* nFileName, char* nFullName)
  169. {
  170. strcpy(nFullName, pathOBJ);
  171. strcat(nFullName, "\");
  172. strcat(nFullName, nFileName);
  173. }
  174. char* afSettings::tmpFullOBJPath(const char* nFileName, const char* nExt)
  175. {
  176. static char fullPath[_MAX_PATH];
  177. extendToOBJPath(nFileName, fullPath);
  178. if(nExt)
  179. strcat(fullPath, nExt);
  180. return fullPath;
  181. }
  182. void afSettings::extendToPsPath(const char* nFileName, char* nFullName)
  183. {
  184. strcpy(nFullName, pathPS);
  185. strcat(nFullName, "\");
  186. strcat(nFullName, nFileName);
  187. }
  188. char* afSettings::tmpFullPsPath(const char* nFileName, const char* nExt)
  189. {
  190. static char fullPath[_MAX_PATH];
  191. extendToAniPath(nFileName, fullPath);
  192. if(nExt)
  193. strcat(fullPath, nExt);
  194. return fullPath;
  195. }
  196. void afSettings::extendToTerrainPath(const char* nFileName, char* nFullName)
  197. {
  198. strcpy(nFullName, pathTerrain);
  199. strcat(nFullName, "\");
  200. strcat(nFullName, nFileName);
  201. }
  202. char* afSettings::tmpFullTerrainPath(const char* nFileName, const char* nExt)
  203. {
  204. static char fullPath[_MAX_PATH];
  205. extendToTerrainPath(nFileName, fullPath);
  206. if(nExt)
  207. strcat(fullPath, nExt);
  208. return fullPath;
  209. }
  210. void afSettings::extendToTexturePath(const char* nFileName, char* nFullName)
  211. {
  212. strcpy(nFullName, pathTex);
  213. strcat(nFullName, "\");
  214. strcat(nFullName, nFileName);
  215. }
  216. char* afSettings::tmpFullTexturePath(const char* nFileName, const char* nExt)
  217. {
  218. static char fullPath[_MAX_PATH];
  219. extendToTexturePath(nFileName, fullPath);
  220. if(nExt)
  221. strcat(fullPath, nExt);
  222. return fullPath;
  223. }
  224. void afSettings::extendToBspTexPath(const char* nFileName, char* nFullName)
  225. {
  226. strcpy(nFullName, pathBspTex);
  227. strcat(nFullName, "\");
  228. strcat(nFullName, nFileName);
  229. }
  230. char* afSettings::tmpFullBspTexPath(const char* nFileName, const char* nExt)
  231. {
  232. static char fullPath[_MAX_PATH];
  233. extendToBspTexPath(nFileName, fullPath);
  234. if(nExt)
  235. strcat(fullPath, nExt);
  236. return fullPath;
  237. }
  238. void afSettings::extendToTextureMD2Path(const char* nFileName, char* nFullName)
  239. {
  240. strcpy(nFullName, pathMD2);
  241. strcat(nFullName, "\");
  242. strcat(nFullName, nFileName);
  243. }
  244. char* afSettings::tmpFullTextureMD2Path(const char* nFileName, const char* nExt)
  245. {
  246. static char fullPath[_MAX_PATH];
  247. extendToTextureMD2Path(nFileName, fullPath);
  248. if(nExt)
  249. strcat(fullPath, nExt);
  250. return fullPath;
  251. }