Advertisement
Guest User

raven_coda

a guest
Jul 13th, 2009
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.88 KB | None | 0 0
  1. diff -r ccc441794de0 contrib/extractor/System.cpp
  2. --- a/contrib/extractor/System.cpp Tue Jul 14 01:04:19 2009 +0200
  3. +++ b/contrib/extractor/System.cpp Mon Jul 13 22:54:13 2009 -0400
  4. -17,6 +17,7 @@
  5. #include "loadlib/adt.h"
  6. #include "loadlib/wdt.h"
  7. #include <fcntl.h>
  8. +#include "wmoJuicer.h"
  9.  
  10. #if defined( __GNUC__ )
  11. #define _open open
  12. -47,6 +48,7 @@
  13. char output_path[128] = ".";
  14. char input_path[128] = ".";
  15. uint32 maxAreaId = 0;
  16. +wmoJuicer* juicer;
  17.  
  18. //**************************************************
  19. // Extractor options
  20. -233,69 +235,6 @@
  21. printf("Done! (%u LiqTypes loaded)\n", LiqType_count);
  22. }
  23.  
  24. -//
  25. -// Adt file convertor function and data
  26. -//
  27. -
  28. -// Map file format data
  29. -#define MAP_MAGIC 'SPAM'
  30. -#define MAP_VERSION_MAGIC '0.1w'
  31. -#define MAP_AREA_MAGIC 'AERA'
  32. -#define MAP_HEIGTH_MAGIC 'TGHM'
  33. -#define MAP_LIQUID_MAGIC 'QILM'
  34. -
  35. -struct map_fileheader{
  36. - uint32 mapMagic;
  37. - uint32 versionMagic;
  38. - uint32 areaMapOffset;
  39. - uint32 areaMapSize;
  40. - uint32 heightMapOffset;
  41. - uint32 heightMapSize;
  42. - uint32 liquidMapOffset;
  43. - uint32 liquidMapSize;
  44. -};
  45. -
  46. -#define MAP_AREA_NO_AREA 0x0001
  47. -struct map_areaHeader{
  48. - uint32 fourcc;
  49. - uint16 flags;
  50. - uint16 gridArea;
  51. -};
  52. -
  53. -#define MAP_HEIGHT_NO_HIGHT 0x0001
  54. -#define MAP_HEIGHT_AS_INT16 0x0002
  55. -#define MAP_HEIGHT_AS_INT8 0x0004
  56. -
  57. -struct map_heightHeader{
  58. - uint32 fourcc;
  59. - uint32 flags;
  60. - float gridHeight;
  61. - float gridMaxHeight;
  62. -};
  63. -
  64. -#define MAP_LIQUID_TYPE_NO_WATER 0x00
  65. -#define MAP_LIQUID_TYPE_WATER 0x01
  66. -#define MAP_LIQUID_TYPE_OCEAN 0x02
  67. -#define MAP_LIQUID_TYPE_MAGMA 0x04
  68. -#define MAP_LIQUID_TYPE_SLIME 0x08
  69. -
  70. -#define MAP_LIQUID_TYPE_DARK_WATER 0x10
  71. -#define MAP_LIQUID_TYPE_WMO_WATER 0x20
  72. -
  73. -
  74. -#define MAP_LIQUID_NO_TYPE 0x0001
  75. -#define MAP_LIQUID_NO_HIGHT 0x0002
  76. -
  77. -struct map_liquidHeader{
  78. - uint32 fourcc;
  79. - uint16 flags;
  80. - uint16 liquidType;
  81. - uint8 offsetX;
  82. - uint8 offsetY;
  83. - uint8 width;
  84. - uint8 height;
  85. - float liquidLevel;
  86. -};
  87.  
  88. float selectUInt8StepStore(float maxDiff)
  89. {
  90. -334,8 +273,9 @@
  91. return false;
  92. }
  93.  
  94. - memset(liquid_show, 0, sizeof(liquid_show));
  95. - memset(liquid_type, 0, sizeof(liquid_type));
  96. + //memset(liquid_show, 0, sizeof(liquid_show));
  97. + //memset(liquid_type, 0, sizeof(liquid_type));
  98. + juicer->getLiquid(cell_x,cell_y, &liquid_type[0][0], &liquid_show[0][0], &liquid_height[0][0]);
  99.  
  100. // Prepare map header
  101. map_fileheader map;
  102. -628,9 +568,17 @@
  103. {
  104. int cx = j*ADT_CELL_SIZE + x + h->xOffset;
  105. if (height)
  106. - liquid_height[cy][cx] = height[pos];
  107. + {
  108. + float high=height[pos];
  109. + if (high> liquid_height[cy][cx]) //Just incase there happens to be a city floating in air over a river ;)
  110. + liquid_height[cy][cx] = high;
  111. + }
  112. else
  113. - liquid_height[cy][cx] = h->heightLevel1;
  114. + {
  115. + float high= h->heightLevel1;
  116. + if (high> liquid_height[cy][cx])
  117. + liquid_height[cy][cx] = high;
  118. + }
  119. pos++;
  120. }
  121. }
  122. -686,7 +634,9 @@
  123. for (int x=0; x<= ADT_CELL_SIZE; x++)
  124. {
  125. int cx = j*ADT_CELL_SIZE + x;
  126. - liquid_height[cy][cx] = liquid->liquid[y][x].height;
  127. + float high=liquid->liquid[y][x].height;
  128. + if (high> liquid_height[cy][cx])
  129. + liquid_height[cy][cx] = high;
  130. }
  131. }
  132. }
  133. -841,7 +791,7 @@
  134. std::string path = output_path;
  135. path += "/maps/";
  136. CreateDir(path);
  137. -
  138. + juicer=new wmoJuicer(path.c_str());
  139. printf("Convert map files\n");
  140. for(uint32 z = 0; z < map_count; ++z)
  141. {
  142. -854,7 +804,7 @@
  143. // printf("Error loading %s map wdt data\n", map_ids[z].name);
  144. continue;
  145. }
  146. -
  147. + juicer->Juice(map_ids[z].name, map_ids[z].id, &wdt);
  148. for(uint32 y = 0; y < WDT_MAP_SIZE; ++y)
  149. {
  150. for(uint32 x = 0; x < WDT_MAP_SIZE; ++x)
  151. -866,7 +816,7 @@
  152. ConvertADT(mpq_filename, output_filename, y, x);
  153. }
  154. // draw progress bar
  155. - printf("Processing........................%d%%\r", (100 * (y+1)) / WDT_MAP_SIZE);
  156. + printf("Processing........................%d%%\r", 50+(50 * (y+1)) / WDT_MAP_SIZE);
  157. }
  158. }
  159. delete [] areas;
  160. diff -r ccc441794de0 contrib/extractor/VC90_ad.vcproj
  161. --- a/contrib/extractor/VC90_ad.vcproj Tue Jul 14 01:04:19 2009 +0200
  162. +++ b/contrib/extractor/VC90_ad.vcproj Mon Jul 13 22:54:13 2009 -0400
  163. -1,327 +1,343 @@
  164. -<?xml version="1.0" encoding="windows-1251"?>
  165. -<VisualStudioProject
  166. - ProjectType="Visual C++"
  167. - Version="9,00"
  168. - Name="ad"
  169. - ProjectGUID="{D7552D4F-408F-4F8E-859B-366659150CF4}"
  170. - RootNamespace="ad"
  171. - TargetFrameworkVersion="131072"
  172. - >
  173. - <Platforms>
  174. - <Platform
  175. - Name="Win32"
  176. - />
  177. - </Platforms>
  178. - <ToolFiles>
  179. - </ToolFiles>
  180. - <Configurations>
  181. - <Configuration
  182. - Name="Debug|Win32"
  183. - OutputDirectory="."
  184. - IntermediateDirectory=".\debug\"
  185. - ConfigurationType="1"
  186. - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
  187. - UseOfMFC="0"
  188. - ATLMinimizesCRunTimeLibraryUsage="false"
  189. - CharacterSet="2"
  190. - >
  191. - <Tool
  192. - Name="VCPreBuildEventTool"
  193. - />
  194. - <Tool
  195. - Name="VCCustomBuildTool"
  196. - />
  197. - <Tool
  198. - Name="VCXMLDataGeneratorTool"
  199. - />
  200. - <Tool
  201. - Name="VCWebServiceProxyGeneratorTool"
  202. - />
  203. - <Tool
  204. - Name="VCMIDLTool"
  205. - PreprocessorDefinitions="_DEBUG"
  206. - MkTypLibCompatible="true"
  207. - SuppressStartupBanner="true"
  208. - TargetEnvironment="1"
  209. - TypeLibraryName="./ad.tlb"
  210. - HeaderFileName=""
  211. - />
  212. - <Tool
  213. - Name="VCCLCompilerTool"
  214. - Optimization="0"
  215. - AdditionalIncludeDirectories="libmpq"
  216. - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
  217. - BasicRuntimeChecks="3"
  218. - RuntimeLibrary="1"
  219. - UsePrecompiledHeader="0"
  220. - PrecompiledHeaderFile="$(IntDir)ad.pch"
  221. - AssemblerListingLocation="$(IntDir)\"
  222. - ObjectFile="$(IntDir)\"
  223. - ProgramDataBaseFileName="$(IntDir)\"
  224. - XMLDocumentationFileName="$(IntDir)\"
  225. - BrowseInformation="1"
  226. - BrowseInformationFile="$(IntDir)"
  227. - WarningLevel="3"
  228. - SuppressStartupBanner="true"
  229. - DebugInformationFormat="4"
  230. - />
  231. - <Tool
  232. - Name="VCManagedResourceCompilerTool"
  233. - />
  234. - <Tool
  235. - Name="VCResourceCompilerTool"
  236. - PreprocessorDefinitions="_DEBUG"
  237. - Culture="1049"
  238. - />
  239. - <Tool
  240. - Name="VCPreLinkEventTool"
  241. - />
  242. - <Tool
  243. - Name="VCLinkerTool"
  244. - AdditionalDependencies="zlib.lib"
  245. - OutputFile="ad debug.exe"
  246. - LinkIncremental="0"
  247. - SuppressStartupBanner="true"
  248. - AdditionalLibraryDirectories="./debug/"
  249. - IgnoreDefaultLibraryNames="LIBCD.lib"
  250. - GenerateDebugInformation="true"
  251. - ProgramDatabaseFile="./ad debug.pdb"
  252. - SubSystem="1"
  253. - RandomizedBaseAddress="1"
  254. - DataExecutionPrevention="0"
  255. - TargetMachine="1"
  256. - />
  257. - <Tool
  258. - Name="VCALinkTool"
  259. - />
  260. - <Tool
  261. - Name="VCManifestTool"
  262. - />
  263. - <Tool
  264. - Name="VCXDCMakeTool"
  265. - />
  266. - <Tool
  267. - Name="VCBscMakeTool"
  268. - />
  269. - <Tool
  270. - Name="VCFxCopTool"
  271. - />
  272. - <Tool
  273. - Name="VCAppVerifierTool"
  274. - />
  275. - <Tool
  276. - Name="VCPostBuildEventTool"
  277. - />
  278. - </Configuration>
  279. - <Configuration
  280. - Name="Release|Win32"
  281. - OutputDirectory="."
  282. - IntermediateDirectory=".\release"
  283. - ConfigurationType="1"
  284. - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
  285. - UseOfMFC="0"
  286. - ATLMinimizesCRunTimeLibraryUsage="false"
  287. - CharacterSet="2"
  288. - >
  289. - <Tool
  290. - Name="VCPreBuildEventTool"
  291. - />
  292. - <Tool
  293. - Name="VCCustomBuildTool"
  294. - />
  295. - <Tool
  296. - Name="VCXMLDataGeneratorTool"
  297. - />
  298. - <Tool
  299. - Name="VCWebServiceProxyGeneratorTool"
  300. - />
  301. - <Tool
  302. - Name="VCMIDLTool"
  303. - PreprocessorDefinitions="NDEBUG"
  304. - MkTypLibCompatible="true"
  305. - SuppressStartupBanner="true"
  306. - TargetEnvironment="1"
  307. - TypeLibraryName="./ad.tlb"
  308. - HeaderFileName=""
  309. - />
  310. - <Tool
  311. - Name="VCCLCompilerTool"
  312. - Optimization="3"
  313. - InlineFunctionExpansion="1"
  314. - AdditionalIncludeDirectories="libmpq"
  315. - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
  316. - RuntimeLibrary="0"
  317. - UsePrecompiledHeader="0"
  318. - PrecompiledHeaderFile="$(IntDir)ad.pch"
  319. - AssemblerListingLocation="$(IntDir)\"
  320. - ObjectFile="$(IntDir)\"
  321. - ProgramDataBaseFileName="$(IntDir)\"
  322. - XMLDocumentationFileName="$(IntDir)\"
  323. - WarningLevel="3"
  324. - SuppressStartupBanner="true"
  325. - />
  326. - <Tool
  327. - Name="VCManagedResourceCompilerTool"
  328. - />
  329. - <Tool
  330. - Name="VCResourceCompilerTool"
  331. - PreprocessorDefinitions="NDEBUG"
  332. - Culture="1049"
  333. - />
  334. - <Tool
  335. - Name="VCPreLinkEventTool"
  336. - />
  337. - <Tool
  338. - Name="VCLinkerTool"
  339. - AdditionalDependencies="zlib.lib"
  340. - OutputFile="./ad.exe"
  341. - LinkIncremental="0"
  342. - SuppressStartupBanner="true"
  343. - AdditionalLibraryDirectories="./release/"
  344. - IgnoreDefaultLibraryNames="LIBC.lib"
  345. - ProgramDatabaseFile="./ad.pdb"
  346. - SubSystem="1"
  347. - RandomizedBaseAddress="1"
  348. - DataExecutionPrevention="0"
  349. - TargetMachine="1"
  350. - />
  351. - <Tool
  352. - Name="VCALinkTool"
  353. - />
  354. - <Tool
  355. - Name="VCManifestTool"
  356. - />
  357. - <Tool
  358. - Name="VCXDCMakeTool"
  359. - />
  360. - <Tool
  361. - Name="VCBscMakeTool"
  362. - />
  363. - <Tool
  364. - Name="VCFxCopTool"
  365. - />
  366. - <Tool
  367. - Name="VCAppVerifierTool"
  368. - />
  369. - <Tool
  370. - Name="VCPostBuildEventTool"
  371. - />
  372. - </Configuration>
  373. - </Configurations>
  374. - <References>
  375. - </References>
  376. - <Files>
  377. - <Filter
  378. - Name="Source Files"
  379. - Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
  380. - >
  381. - <File
  382. - RelativePath=".\loadlib\loadlib.cpp"
  383. - >
  384. - </File>
  385. - <File
  386. - RelativePath=".\loadlib\adt.cpp"
  387. - >
  388. - </File>
  389. - <File
  390. - RelativePath=".\loadlib\wdt.cpp"
  391. - >
  392. - </File>
  393. - <File
  394. - RelativePath=".\libmpq\common.cpp"
  395. - >
  396. - </File>
  397. - <File
  398. - RelativePath=".\dbcfile.cpp"
  399. - >
  400. - </File>
  401. - <File
  402. - RelativePath=".\libmpq\explode.cpp"
  403. - >
  404. - </File>
  405. - <File
  406. - RelativePath=".\libmpq\extract.cpp"
  407. - >
  408. - </File>
  409. - <File
  410. - RelativePath=".\libmpq\huffman.cpp"
  411. - >
  412. - </File>
  413. - <File
  414. - RelativePath=".\libmpq\mpq.cpp"
  415. - >
  416. - </File>
  417. - <File
  418. - RelativePath=".\mpq_libmpq.cpp"
  419. - >
  420. - </File>
  421. - <File
  422. - RelativePath=".\libmpq\parser.cpp"
  423. - >
  424. - </File>
  425. - <File
  426. - RelativePath="system.cpp"
  427. - >
  428. - <FileConfiguration
  429. - Name="Debug|Win32"
  430. - >
  431. - <Tool
  432. - Name="VCCLCompilerTool"
  433. - Optimization="0"
  434. - PreprocessorDefinitions=""
  435. - BasicRuntimeChecks="3"
  436. - BrowseInformation="1"
  437. - />
  438. - </FileConfiguration>
  439. - <FileConfiguration
  440. - Name="Release|Win32"
  441. - >
  442. - <Tool
  443. - Name="VCCLCompilerTool"
  444. - Optimization="3"
  445. - PreprocessorDefinitions=""
  446. - />
  447. - </FileConfiguration>
  448. - </File>
  449. - <File
  450. - RelativePath=".\libmpq\wave.cpp"
  451. - >
  452. - </File>
  453. - </Filter>
  454. - <Filter
  455. - Name="Header Files"
  456. - Filter="h;hpp;hxx;hm;inl"
  457. - >
  458. - <File
  459. - RelativePath=".\libmpq\common.h"
  460. - >
  461. - </File>
  462. - <File
  463. - RelativePath=".\dbcfile.h"
  464. - >
  465. - </File>
  466. - <File
  467. - RelativePath=".\libmpq\explode.h"
  468. - >
  469. - </File>
  470. - <File
  471. - RelativePath=".\libmpq\huffman.h"
  472. - >
  473. - </File>
  474. - <File
  475. - RelativePath=".\libmpq\mpq.h"
  476. - >
  477. - </File>
  478. - <File
  479. - RelativePath=".\mpq_libmpq.h"
  480. - >
  481. - </File>
  482. - <File
  483. - RelativePath=".\libmpq\wave.h"
  484. - >
  485. - </File>
  486. - </Filter>
  487. - </Files>
  488. - <Globals>
  489. - </Globals>
  490. -</VisualStudioProject>
  491. +<?xml version="1.0" encoding="windows-1251"?>
  492.  
  493. +<VisualStudioProject
  494.  
  495. + ProjectType="Visual C++"
  496.  
  497. + Version="9.00"
  498.  
  499. + Name="ad"
  500.  
  501. + ProjectGUID="{D7552D4F-408F-4F8E-859B-366659150CF4}"
  502.  
  503. + RootNamespace="ad"
  504.  
  505. + TargetFrameworkVersion="131072"
  506.  
  507. + >
  508.  
  509. + <Platforms>
  510.  
  511. + <Platform
  512.  
  513. + Name="Win32"
  514.  
  515. + />
  516.  
  517. + </Platforms>
  518.  
  519. + <ToolFiles>
  520.  
  521. + </ToolFiles>
  522.  
  523. + <Configurations>
  524.  
  525. + <Configuration
  526.  
  527. + Name="Debug|Win32"
  528.  
  529. + OutputDirectory="."
  530.  
  531. + IntermediateDirectory=".\debug\"
  532.  
  533. + ConfigurationType="1"
  534.  
  535. + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
  536.  
  537. + UseOfMFC="0"
  538.  
  539. + ATLMinimizesCRunTimeLibraryUsage="false"
  540.  
  541. + CharacterSet="2"
  542.  
  543. + >
  544.  
  545. + <Tool
  546.  
  547. + Name="VCPreBuildEventTool"
  548.  
  549. + />
  550.  
  551. + <Tool
  552.  
  553. + Name="VCCustomBuildTool"
  554.  
  555. + />
  556.  
  557. + <Tool
  558.  
  559. + Name="VCXMLDataGeneratorTool"
  560.  
  561. + />
  562.  
  563. + <Tool
  564.  
  565. + Name="VCWebServiceProxyGeneratorTool"
  566.  
  567. + />
  568.  
  569. + <Tool
  570.  
  571. + Name="VCMIDLTool"
  572.  
  573. + PreprocessorDefinitions="_DEBUG"
  574.  
  575. + MkTypLibCompatible="true"
  576.  
  577. + SuppressStartupBanner="true"
  578.  
  579. + TargetEnvironment="1"
  580.  
  581. + TypeLibraryName="./ad.tlb"
  582.  
  583. + HeaderFileName=""
  584.  
  585. + />
  586.  
  587. + <Tool
  588.  
  589. + Name="VCCLCompilerTool"
  590.  
  591. + Optimization="0"
  592.  
  593. + AdditionalIncludeDirectories="libmpq"
  594.  
  595. + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
  596.  
  597. + BasicRuntimeChecks="3"
  598.  
  599. + RuntimeLibrary="1"
  600.  
  601. + UsePrecompiledHeader="0"
  602.  
  603. + PrecompiledHeaderFile="$(IntDir)ad.pch"
  604.  
  605. + AssemblerListingLocation="$(IntDir)\"
  606.  
  607. + ObjectFile="$(IntDir)\"
  608.  
  609. + ProgramDataBaseFileName="$(IntDir)\"
  610.  
  611. + XMLDocumentationFileName="$(IntDir)\"
  612.  
  613. + BrowseInformation="1"
  614.  
  615. + BrowseInformationFile="$(IntDir)"
  616.  
  617. + WarningLevel="3"
  618.  
  619. + SuppressStartupBanner="true"
  620.  
  621. + DebugInformationFormat="4"
  622.  
  623. + />
  624.  
  625. + <Tool
  626.  
  627. + Name="VCManagedResourceCompilerTool"
  628.  
  629. + />
  630.  
  631. + <Tool
  632.  
  633. + Name="VCResourceCompilerTool"
  634.  
  635. + PreprocessorDefinitions="_DEBUG"
  636.  
  637. + Culture="1049"
  638.  
  639. + />
  640.  
  641. + <Tool
  642.  
  643. + Name="VCPreLinkEventTool"
  644.  
  645. + />
  646.  
  647. + <Tool
  648.  
  649. + Name="VCLinkerTool"
  650.  
  651. + AdditionalDependencies="zlib.lib"
  652.  
  653. + OutputFile="ad debug.exe"
  654.  
  655. + LinkIncremental="0"
  656.  
  657. + SuppressStartupBanner="true"
  658.  
  659. + AdditionalLibraryDirectories="./debug/"
  660.  
  661. + IgnoreDefaultLibraryNames="LIBCD.lib"
  662.  
  663. + GenerateDebugInformation="true"
  664.  
  665. + ProgramDatabaseFile="./ad debug.pdb"
  666.  
  667. + SubSystem="1"
  668.  
  669. + RandomizedBaseAddress="1"
  670.  
  671. + DataExecutionPrevention="0"
  672.  
  673. + TargetMachine="1"
  674.  
  675. + />
  676.  
  677. + <Tool
  678.  
  679. + Name="VCALinkTool"
  680.  
  681. + />
  682.  
  683. + <Tool
  684.  
  685. + Name="VCManifestTool"
  686.  
  687. + />
  688.  
  689. + <Tool
  690.  
  691. + Name="VCXDCMakeTool"
  692.  
  693. + />
  694.  
  695. + <Tool
  696.  
  697. + Name="VCBscMakeTool"
  698.  
  699. + />
  700.  
  701. + <Tool
  702.  
  703. + Name="VCFxCopTool"
  704.  
  705. + />
  706.  
  707. + <Tool
  708.  
  709. + Name="VCAppVerifierTool"
  710.  
  711. + />
  712.  
  713. + <Tool
  714.  
  715. + Name="VCPostBuildEventTool"
  716.  
  717. + />
  718.  
  719. + </Configuration>
  720.  
  721. + <Configuration
  722.  
  723. + Name="Release|Win32"
  724.  
  725. + OutputDirectory="."
  726.  
  727. + IntermediateDirectory=".\release"
  728.  
  729. + ConfigurationType="1"
  730.  
  731. + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
  732.  
  733. + UseOfMFC="0"
  734.  
  735. + ATLMinimizesCRunTimeLibraryUsage="false"
  736.  
  737. + CharacterSet="2"
  738.  
  739. + >
  740.  
  741. + <Tool
  742.  
  743. + Name="VCPreBuildEventTool"
  744.  
  745. + />
  746.  
  747. + <Tool
  748.  
  749. + Name="VCCustomBuildTool"
  750.  
  751. + />
  752.  
  753. + <Tool
  754.  
  755. + Name="VCXMLDataGeneratorTool"
  756.  
  757. + />
  758.  
  759. + <Tool
  760.  
  761. + Name="VCWebServiceProxyGeneratorTool"
  762.  
  763. + />
  764.  
  765. + <Tool
  766.  
  767. + Name="VCMIDLTool"
  768.  
  769. + PreprocessorDefinitions="NDEBUG"
  770.  
  771. + MkTypLibCompatible="true"
  772.  
  773. + SuppressStartupBanner="true"
  774.  
  775. + TargetEnvironment="1"
  776.  
  777. + TypeLibraryName="./ad.tlb"
  778.  
  779. + HeaderFileName=""
  780.  
  781. + />
  782.  
  783. + <Tool
  784.  
  785. + Name="VCCLCompilerTool"
  786.  
  787. + Optimization="3"
  788.  
  789. + InlineFunctionExpansion="1"
  790.  
  791. + AdditionalIncludeDirectories="libmpq"
  792.  
  793. + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
  794.  
  795. + RuntimeLibrary="0"
  796.  
  797. + UsePrecompiledHeader="0"
  798.  
  799. + PrecompiledHeaderFile="$(IntDir)ad.pch"
  800.  
  801. + AssemblerListingLocation="$(IntDir)\"
  802.  
  803. + ObjectFile="$(IntDir)\"
  804.  
  805. + ProgramDataBaseFileName="$(IntDir)\"
  806.  
  807. + XMLDocumentationFileName="$(IntDir)\"
  808.  
  809. + WarningLevel="3"
  810.  
  811. + SuppressStartupBanner="true"
  812.  
  813. + />
  814.  
  815. + <Tool
  816.  
  817. + Name="VCManagedResourceCompilerTool"
  818.  
  819. + />
  820.  
  821. + <Tool
  822.  
  823. + Name="VCResourceCompilerTool"
  824.  
  825. + PreprocessorDefinitions="NDEBUG"
  826.  
  827. + Culture="1049"
  828.  
  829. + />
  830.  
  831. + <Tool
  832.  
  833. + Name="VCPreLinkEventTool"
  834.  
  835. + />
  836.  
  837. + <Tool
  838.  
  839. + Name="VCLinkerTool"
  840.  
  841. + AdditionalDependencies="zlib.lib"
  842.  
  843. + OutputFile="./ad.exe"
  844.  
  845. + LinkIncremental="0"
  846.  
  847. + SuppressStartupBanner="true"
  848.  
  849. + AdditionalLibraryDirectories="./release/"
  850.  
  851. + IgnoreDefaultLibraryNames="LIBC.lib"
  852.  
  853. + ProgramDatabaseFile="./ad.pdb"
  854.  
  855. + SubSystem="1"
  856.  
  857. + RandomizedBaseAddress="1"
  858.  
  859. + DataExecutionPrevention="0"
  860.  
  861. + TargetMachine="1"
  862.  
  863. + />
  864.  
  865. + <Tool
  866.  
  867. + Name="VCALinkTool"
  868.  
  869. + />
  870.  
  871. + <Tool
  872.  
  873. + Name="VCManifestTool"
  874.  
  875. + />
  876.  
  877. + <Tool
  878.  
  879. + Name="VCXDCMakeTool"
  880.  
  881. + />
  882.  
  883. + <Tool
  884.  
  885. + Name="VCBscMakeTool"
  886.  
  887. + />
  888.  
  889. + <Tool
  890.  
  891. + Name="VCFxCopTool"
  892.  
  893. + />
  894.  
  895. + <Tool
  896.  
  897. + Name="VCAppVerifierTool"
  898.  
  899. + />
  900.  
  901. + <Tool
  902.  
  903. + Name="VCPostBuildEventTool"
  904.  
  905. + />
  906.  
  907. + </Configuration>
  908.  
  909. + </Configurations>
  910.  
  911. + <References>
  912.  
  913. + </References>
  914.  
  915. + <Files>
  916.  
  917. + <Filter
  918.  
  919. + Name="Source Files"
  920.  
  921. + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
  922.  
  923. + >
  924.  
  925. + <File
  926.  
  927. + RelativePath=".\loadlib\adt.cpp"
  928.  
  929. + >
  930.  
  931. + </File>
  932.  
  933. + <File
  934.  
  935. + RelativePath=".\libmpq\common.cpp"
  936.  
  937. + >
  938.  
  939. + </File>
  940.  
  941. + <File
  942.  
  943. + RelativePath=".\dbcfile.cpp"
  944.  
  945. + >
  946.  
  947. + </File>
  948.  
  949. + <File
  950.  
  951. + RelativePath=".\libmpq\explode.cpp"
  952.  
  953. + >
  954.  
  955. + </File>
  956.  
  957. + <File
  958.  
  959. + RelativePath=".\libmpq\extract.cpp"
  960.  
  961. + >
  962.  
  963. + </File>
  964.  
  965. + <File
  966.  
  967. + RelativePath=".\libmpq\huffman.cpp"
  968.  
  969. + >
  970.  
  971. + </File>
  972.  
  973. + <File
  974.  
  975. + RelativePath=".\loadlib\loadlib.cpp"
  976.  
  977. + >
  978.  
  979. + </File>
  980.  
  981. + <File
  982.  
  983. + RelativePath=".\libmpq\mpq.cpp"
  984.  
  985. + >
  986.  
  987. + </File>
  988.  
  989. + <File
  990.  
  991. + RelativePath=".\mpq_libmpq.cpp"
  992.  
  993. + >
  994.  
  995. + </File>
  996.  
  997. + <File
  998.  
  999. + RelativePath=".\libmpq\parser.cpp"
  1000.  
  1001. + >
  1002.  
  1003. + </File>
  1004.  
  1005. + <File
  1006.  
  1007. + RelativePath="system.cpp"
  1008.  
  1009. + >
  1010.  
  1011. + <FileConfiguration
  1012.  
  1013. + Name="Debug|Win32"
  1014.  
  1015. + >
  1016.  
  1017. + <Tool
  1018.  
  1019. + Name="VCCLCompilerTool"
  1020.  
  1021. + Optimization="0"
  1022.  
  1023. + PreprocessorDefinitions=""
  1024.  
  1025. + BasicRuntimeChecks="3"
  1026.  
  1027. + BrowseInformation="1"
  1028.  
  1029. + />
  1030.  
  1031. + </FileConfiguration>
  1032.  
  1033. + <FileConfiguration
  1034.  
  1035. + Name="Release|Win32"
  1036.  
  1037. + >
  1038.  
  1039. + <Tool
  1040.  
  1041. + Name="VCCLCompilerTool"
  1042.  
  1043. + Optimization="3"
  1044.  
  1045. + PreprocessorDefinitions=""
  1046.  
  1047. + />
  1048.  
  1049. + </FileConfiguration>
  1050.  
  1051. + </File>
  1052.  
  1053. + <File
  1054.  
  1055. + RelativePath=".\libmpq\wave.cpp"
  1056.  
  1057. + >
  1058.  
  1059. + </File>
  1060.  
  1061. + <File
  1062.  
  1063. + RelativePath=".\loadlib\wdt.cpp"
  1064.  
  1065. + >
  1066.  
  1067. + </File>
  1068.  
  1069. + <File
  1070.  
  1071. + RelativePath=".\wmoJuicer.cpp"
  1072.  
  1073. + >
  1074.  
  1075. + </File>
  1076.  
  1077. + </Filter>
  1078.  
  1079. + <Filter
  1080.  
  1081. + Name="Header Files"
  1082.  
  1083. + Filter="h;hpp;hxx;hm;inl"
  1084.  
  1085. + >
  1086.  
  1087. + <File
  1088.  
  1089. + RelativePath=".\loadlib\adt.h"
  1090.  
  1091. + >
  1092.  
  1093. + </File>
  1094.  
  1095. + <File
  1096.  
  1097. + RelativePath=".\libmpq\common.h"
  1098.  
  1099. + >
  1100.  
  1101. + </File>
  1102.  
  1103. + <File
  1104.  
  1105. + RelativePath=".\dbcfile.h"
  1106.  
  1107. + >
  1108.  
  1109. + </File>
  1110.  
  1111. + <File
  1112.  
  1113. + RelativePath=".\libmpq\explode.h"
  1114.  
  1115. + >
  1116.  
  1117. + </File>
  1118.  
  1119. + <File
  1120.  
  1121. + RelativePath=".\libmpq\huffman.h"
  1122.  
  1123. + >
  1124.  
  1125. + </File>
  1126.  
  1127. + <File
  1128.  
  1129. + RelativePath=".\libmpq\mpq.h"
  1130.  
  1131. + >
  1132.  
  1133. + </File>
  1134.  
  1135. + <File
  1136.  
  1137. + RelativePath=".\mpq_libmpq.h"
  1138.  
  1139. + >
  1140.  
  1141. + </File>
  1142.  
  1143. + <File
  1144.  
  1145. + RelativePath=".\libmpq\wave.h"
  1146.  
  1147. + >
  1148.  
  1149. + </File>
  1150.  
  1151. + <File
  1152.  
  1153. + RelativePath=".\loadlib\wdt.h"
  1154.  
  1155. + >
  1156.  
  1157. + </File>
  1158.  
  1159. + <File
  1160.  
  1161. + RelativePath=".\wmoJuicer.h"
  1162.  
  1163. + >
  1164.  
  1165. + </File>
  1166.  
  1167. + </Filter>
  1168.  
  1169. + </Files>
  1170.  
  1171. + <Globals>
  1172.  
  1173. + </Globals>
  1174.  
  1175. +</VisualStudioProject>
  1176.  
  1177. diff -r ccc441794de0 contrib/extractor/loadlib/adt.h
  1178. --- a/contrib/extractor/loadlib/adt.h Tue Jul 14 01:04:19 2009 +0200
  1179. +++ b/contrib/extractor/loadlib/adt.h Mon Jul 13 22:54:14 2009 -0400
  1180. -13,6 +13,64 @@
  1181. LIQUID_TYPE_OCEAN = 1,
  1182. LIQUID_TYPE_MAGMA = 2,
  1183. LIQUID_TYPE_SLIME = 3
  1184. +};
  1185. +
  1186. +
  1187. +//
  1188. +// Adt file convertor function and data
  1189. +//
  1190. +
  1191. +// Map file format data
  1192. +#define MAP_MAGIC 'SPAM'
  1193. +#define MAP_VERSION_MAGIC '0.1w'
  1194. +#define MAP_AREA_MAGIC 'AERA'
  1195. +#define MAP_HEIGTH_MAGIC 'TGHM'
  1196. +#define MAP_LIQUID_MAGIC 'QILM'
  1197. +
  1198. +struct map_fileheader{
  1199. + uint32 mapMagic;
  1200. + uint32 versionMagic;
  1201. + uint32 areaMapOffset;
  1202. + uint32 areaMapSize;
  1203. + uint32 heightMapOffset;
  1204. + uint32 heightMapSize;
  1205. + uint32 liquidMapOffset;
  1206. + uint32 liquidMapSize;
  1207. +};
  1208. +
  1209. +#define MAP_AREA_NO_AREA 0x0001
  1210. +struct map_areaHeader{
  1211. + uint32 fourcc;
  1212. + uint16 flags;
  1213. + uint16 gridArea;
  1214. +};
  1215. +
  1216. +#define MAP_HEIGHT_NO_HIGHT 0x0001
  1217. +#define MAP_HEIGHT_AS_INT16 0x0002
  1218. +#define MAP_HEIGHT_AS_INT8 0x0004
  1219. +
  1220. +struct map_heightHeader{
  1221. + uint32 fourcc;
  1222. + uint32 flags;
  1223. + float gridHeight;
  1224. + float gridMaxHeight;
  1225. +};
  1226. +
  1227. +
  1228. +
  1229. +
  1230. +#define MAP_LIQUID_NO_TYPE 0x0001
  1231. +#define MAP_LIQUID_NO_HIGHT 0x0002
  1232. +
  1233. +struct map_liquidHeader{
  1234. + uint32 fourcc;
  1235. + uint16 flags;
  1236. + uint16 liquidType;
  1237. + uint8 offsetX;
  1238. + uint8 offsetY;
  1239. + uint8 width;
  1240. + uint8 height;
  1241. + float liquidLevel;
  1242. };
  1243.  
  1244. //**************************************************************************************
  1245. -242,6 +300,54 @@
  1246.  
  1247. };
  1248.  
  1249. +
  1250. +//
  1251. +// Adt wmo chunck
  1252. +//
  1253. +class adt_MWMO
  1254. +{
  1255. + union{
  1256. + uint32 fcc;
  1257. + char fcc_txt[4];
  1258. + };
  1259. +public:
  1260. + uint32 size;
  1261. +
  1262. + uint32 pad;
  1263. + uint8 *getWMO(uint32 idz){return ((uint8 *)&pad+(idz)) ;}
  1264. +};
  1265.  
  1266. +
  1267.  
  1268. +#ifndef MAP_OBJ
  1269. +#define MAP_OBJ
  1270. +
  1271. +struct SMMapObjDef // 03-29-2005 By ObscuR
  1272.  
  1273. +{
  1274.  
  1275. +uint32 nameId;
  1276.  
  1277. +uint32 uniqueId;
  1278.  
  1279. +float pos[3];
  1280.  
  1281. +float rot[3];
  1282.  
  1283. +float extents[6];
  1284.  
  1285. +uint32 flags;
  1286.  
  1287. +uint32 doodadSet;
  1288.  
  1289. +uint16 nameSet;
  1290.  
  1291. +};
  1292.  
  1293. +
  1294.  
  1295. +#endif
  1296.  
  1297. +
  1298.  
  1299. +class adt_MODF
  1300.  
  1301. +{
  1302.  
  1303. + union{
  1304.  
  1305. + uint32 fcc;
  1306.  
  1307. + char fcc_txt[4];
  1308.  
  1309. + };
  1310.  
  1311. + uint32 size;
  1312.  
  1313. +public:
  1314.  
  1315. +
  1316.  
  1317. +
  1318.  
  1319. + SMMapObjDef data;
  1320.  
  1321. + int getCount() { return (size-4)/sizeof(SMMapObjDef);}
  1322.  
  1323. +};
  1324. +
  1325. //
  1326. // Adt file header chunk
  1327. //
  1328. -273,6 +379,8 @@
  1329. bool prepareLoadedData();
  1330. adt_MCIN *getMCIN(){ return (adt_MCIN *)((uint8 *)&pad+offsMCIN);}
  1331. adt_MH2O *getMH2O(){ return offsMH2O ? (adt_MH2O *)((uint8 *)&pad+offsMH2O) : 0;}
  1332. + adt_MWMO *getMWMO(){ return offsMapObejcts ? (adt_MWMO *)((uint8 *)&pad+offsMapObejcts) : 0;}
  1333.  
  1334. + adt_MODF *getMODF(){ return offsObjectsDef ? (adt_MODF *)((uint8 *)&pad+offsObjectsDef) : 0;}
  1335.  
  1336. };
  1337.  
  1338. diff -r ccc441794de0 contrib/extractor/loadlib/wdt.cpp
  1339. --- a/contrib/extractor/loadlib/wdt.cpp Tue Jul 14 01:04:19 2009 +0200
  1340. +++ b/contrib/extractor/loadlib/wdt.cpp Mon Jul 13 22:54:14 2009 -0400
  1341. -58,5 +58,9 @@
  1342. wmo = (wdt_MWMO *)((uint8*)main+ main->size+8);
  1343. if (!wmo->prepareLoadedData())
  1344. return false;
  1345. + if (wmo->size >0)
  1346. + modf = (wdt_MODF *)((uint8*)wmo+ wmo->size+8);
  1347. + else
  1348. + modf=0;
  1349. return true;
  1350. }
  1351. \ No newline at end of file
  1352. diff -r ccc441794de0 contrib/extractor/loadlib/wdt.h
  1353. --- a/contrib/extractor/loadlib/wdt.h Tue Jul 14 01:04:19 2009 +0200
  1354. +++ b/contrib/extractor/loadlib/wdt.h Mon Jul 13 22:54:14 2009 -0400
  1355. -14,7 +14,42 @@
  1356. };
  1357. public:
  1358. uint32 size;
  1359. +
  1360. + uint32 pad;
  1361. +
  1362. + uint8 *getWMO(uint32 idz){return ((uint8 *)&pad+(idz)) ;}
  1363. bool prepareLoadedData();
  1364. +};
  1365. +
  1366. +#ifndef MAP_OBJ
  1367. +#define MAP_OBJ
  1368. +
  1369. +struct SMMapObjDef // 03-29-2005 By ObscuR
  1370.  
  1371. +{
  1372.  
  1373. +uint32 nameId;
  1374.  
  1375. +uint32 uniqueId;
  1376.  
  1377. +float pos[3];
  1378.  
  1379. +float rot[3];
  1380.  
  1381. +float extents[6];
  1382.  
  1383. +uint32 flags;
  1384.  
  1385. +uint32 doodadSet;
  1386.  
  1387. +uint16 nameSet;
  1388.  
  1389. +};
  1390.  
  1391. +
  1392.  
  1393. +#endif
  1394.  
  1395. +
  1396.  
  1397. +class wdt_MODF
  1398.  
  1399. +{
  1400.  
  1401. + union{
  1402.  
  1403. + uint32 fcc;
  1404.  
  1405. + char fcc_txt[4];
  1406.  
  1407. + };
  1408.  
  1409. + uint32 size;
  1410.  
  1411. +public:
  1412.  
  1413. +
  1414.  
  1415. +
  1416.  
  1417. + SMMapObjDef data;
  1418.  
  1419. + int getCount() { return (size-4)/sizeof(SMMapObjDef);}
  1420.  
  1421. };
  1422.  
  1423. class wdt_MPHD{
  1424. -63,6 +98,7 @@
  1425. wdt_MPHD *mphd;
  1426. wdt_MAIN *main;
  1427. wdt_MWMO *wmo;
  1428. + wdt_MODF *modf;
  1429. };
  1430.  
  1431. #endif
  1432. \ No newline at end of file
  1433. diff -r ccc441794de0 contrib/extractor/wmoJuicer.cpp
  1434. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  1435. +++ b/contrib/extractor/wmoJuicer.cpp Mon Jul 13 22:54:14 2009 -0400
  1436. -0,0 +1,436 @@
  1437. +#define _CRT_SECURE_NO_DEPRECATE
  1438.  
  1439. +
  1440.  
  1441. +#include "wmoJuicer.h"
  1442.  
  1443. +
  1444.  
  1445. +#include <math.h>
  1446. +#include <stdio.h>
  1447. +#include <string>
  1448.  
  1449. +
  1450. +
  1451. +bool wmoJuicer::wmo_MOGP::prepareLoadedData()
  1452. +{
  1453. + if (fcc != 'MOGP')
  1454. + return false;
  1455. + return true;
  1456. +}
  1457. +
  1458. +bool wmoJuicer::wmo_MOHD::prepareLoadedData()
  1459. +{
  1460. + if (fcc != 'MOHD')
  1461. + return false;
  1462. + return true;
  1463. +}
  1464. +
  1465. + wmoJuicer::WMO_file::WMO_file()
  1466. +{
  1467. + mogp = 0;
  1468. +}
  1469. +
  1470. + wmoJuicer::WMO_file::~WMO_file()
  1471. +{
  1472. + free();
  1473. +}
  1474. +
  1475. +void wmoJuicer::WMO_file::free()
  1476. +{
  1477. + mogp = 0;
  1478. + FileLoader::free();
  1479. +}
  1480. +
  1481. +bool wmoJuicer::WMO_file::prepareLoadedData()
  1482. +{
  1483. + // Check version
  1484. + version = (file_MVER *) GetData();
  1485. + if (version->fcc != 'MVER')
  1486. + return false;
  1487. + if (version->ver != 17)
  1488. + return false;
  1489. +
  1490. + mohd = (wmo_MOHD *)((uint8*)version+version->size+8);
  1491. + mogp=(wmo_MOGP *)mohd;
  1492. + if (mogp->prepareLoadedData())
  1493. + type=group;
  1494. + else if (mohd->prepareLoadedData())
  1495. + type=root;
  1496. + else
  1497. + return false;
  1498. +
  1499. + if (type==root)
  1500. + {
  1501. + mogi=(wmo_chunk*)mohd;
  1502. + while (mogi->fcc != 'MOGI')
  1503. + {
  1504. + if (mogi->fcc == 'MOGN')
  1505. + mogn=mogi;
  1506. + mogi=(wmo_chunk*)((uint8*)mogi+mogi->size+8);
  1507. + }
  1508. + }
  1509. + else if (mogp->hasWater())
  1510. + {
  1511. + wmo_chunk *w=(wmo_chunk*)((uint8*)mogp+76);
  1512. + while (w->fcc != 'MLIQ')
  1513. + {
  1514. + w=(wmo_chunk*)((uint8*)w+w->size+8);
  1515. + }
  1516. + mliq=(wmo_MLIQ *)w;
  1517. + }
  1518. + return true;
  1519. +}
  1520. +
  1521. +wmoJuicer::wmoJuicer(const char* outdir)
  1522. +{
  1523. + strcpy( path, outdir);
  1524. +}
  1525. +
  1526. +wmoJuicer::~wmoJuicer()
  1527. +{
  1528. +
  1529. +}
  1530. +
  1531. +void wmoJuicer::squeeze(char* wmo_file, SMMapObjDef* wmo_map, bool global)
  1532. +{
  1533. + WMO_file wmog;
  1534. + if (!wmog.loadFile(wmo_file))
  1535. + printf("could not load file %s\n", wmo_file);
  1536. + else
  1537. + {
  1538. + if (wmog.mogp->hasWater())
  1539. + {
  1540. + wmo_MLIQ* water=wmog.mliq;
  1541. +
  1542. + float rad=(wmo_map->rot[1])*3.14592f/180.0f;
  1543. + rad=-rad;
  1544. + for (uint16 ii=0; ii<= water->xt; ii++)
  1545. + for (uint16 jj=0; jj<= water->yt; jj++)
  1546. + {
  1547. + float y=(wmo_map->pos[1])+water->pos[2];
  1548. + //Convert to wmo location to rotate
  1549. + float wmo_x=water->pos[1]+(jj*TILESIZE/ADT_GRID_SIZE);
  1550. + float wmo_y=water->pos[0]+(ii*TILESIZE/ADT_GRID_SIZE);
  1551. + float abs_x=(wmo_map->pos[0]);
  1552. + float abs_y=(wmo_map->pos[2]);
  1553. + //rotate
  1554. + abs_x+=(wmo_x*cos(rad))-(wmo_y*sin(rad));
  1555. + abs_y+=(wmo_y*cos(rad))+(wmo_x*sin(rad));
  1556. + //now find corresponding grid
  1557. + float cx=abs_x*ADT_GRID_SIZE/TILESIZE;
  1558. + float cy=abs_y*ADT_GRID_SIZE/TILESIZE;
  1559. + if (global)
  1560. + {
  1561. + cx+=ADT_GRID_SIZE*(WDT_MAP_SIZE>>1);
  1562. + cy+=ADT_GRID_SIZE*(WDT_MAP_SIZE>>1);
  1563. + }
  1564. + int gx=(int)(cx/ADT_GRID_SIZE);
  1565. + int gy=(int)(cy/ADT_GRID_SIZE);
  1566. + cx-=gx*ADT_GRID_SIZE;
  1567. + cy-=gy*ADT_GRID_SIZE;
  1568. + if (cx > 0 && cy > 0 && gx<WDT_MAP_SIZE && gy<WDT_MAP_SIZE) //just a sanity check
  1569. + {
  1570. + if (jj < water->yt && ii < water->xt)
  1571. + {
  1572. + uint8 c_flag = water->getLiquidFlags(ii,jj);
  1573. + if (!(c_flag & 0x08))
  1574.  
  1575. + {
  1576. + ranged_liquid_show[gy][gx][(int)cy][(int)cx] = true;
  1577. if (cx<ADT_GRID_SIZE-1)
  1578. + {
  1579. + ranged_liquid_show[gy][gx][(int)cy][(int)(cx+0.5f)] = true;
  1580. + if (cy<ADT_GRID_SIZE-1)
  1581. + ranged_liquid_show[gy][gx][(int)(cy+0.5f)][(int)(cx+0.5f)] = true;
  1582. + }
  1583. + if (cy<ADT_GRID_SIZE-1)
  1584. + ranged_liquid_show[gy][gx][(int)(cy+0.5f)][(int)cx] = true;
  1585. if (c_flag&(0x40))
  1586. ranged_liquid_type[gy][gx][(int)(cy/8)][(int)(cx/8)] |= MAP_LIQUID_TYPE_WATER;
  1587.  
  1588. + if (c_flag&(0x01))
  1589. ranged_liquid_type[gy][gx][(int)(cy/8)][(int)(cx/8)] |= MAP_LIQUID_TYPE_SLIME;
  1590.  
  1591. + if (c_flag&(0x02))
  1592. ranged_liquid_type[gy][gx][(int)(cy/8)][(int)(cx/8)] |= MAP_LIQUID_TYPE_MAGMA;
  1593.  
  1594. + }
  1595. + }
  1596. + float high=water->getLiquidData(ii,jj)->height+y;
  1597. + if (high>ranged_liquid_height[gy][gx][(int)cy][(int)cx])
  1598. + {
  1599. + ranged_liquid_height[gy][gx][(int)cy][(int)cx] = high;
  1600. + if (cx<ADT_GRID_SIZE-1)
  1601. + {
  1602. + ranged_liquid_height[gy][gx][(int)cy][(int)(cx+0.5f)] = high;
  1603. + if (cy<ADT_GRID_SIZE-1)
  1604. + ranged_liquid_height[gy][gx][(int)(cy+0.5f)][(int)(cx+0.5f)] = high;
  1605. + }
  1606. + if (cy<ADT_GRID_SIZE-1)
  1607. + ranged_liquid_height[gy][gx][(int)(cy+0.5f)][(int)cx] = high;
  1608. + }
  1609. + }
  1610. + }
  1611. + }
  1612. + }
  1613. +}
  1614. +void wmoJuicer::readADT(char *filename, int cell_x, int cell_y)
  1615. +{
  1616. + ADT_file adt;
  1617.  
  1618. +
  1619.  
  1620. + if (!adt.loadFile(filename))
  1621.  
  1622. + return;
  1623.  
  1624. +
  1625.  
  1626. + adt_MCIN *cells = adt.a_grid->getMCIN();
  1627.  
  1628. + if (!cells)
  1629.  
  1630. + {
  1631.  
  1632. + printf("Can't find cells in '%s'\n", filename);
  1633.  
  1634. + return;
  1635.  
  1636. + }
  1637. +
  1638. + //Get Liquid Data from wmos
  1639.  
  1640. + adt_MWMO* add=adt.a_grid->getMWMO();
  1641. + char* wmo_root;
  1642. + int wmo_idx=0;
  1643. + for (uint32 i=0; i<add->size; i+=strlen(wmo_root)+1)
  1644. + {
  1645. + wmo_root=(char*)(add->getWMO(i));
  1646. +
  1647. + WMO_file wmo;
  1648. + if (!wmo.loadFile(wmo_root))
  1649. +
  1650. + printf("could not load file %s\n", wmo_root);
  1651. + else
  1652. + {
  1653. + SMMapObjDef* wmo_map=&(adt.a_grid->getMODF()->data);
  1654. + for (int j=0; j< adt.a_grid->getMODF()->getCount(); j++)
  1655. + {
  1656. + if (wmo_map->nameId==wmo_idx)
  1657. + break;
  1658. + wmo_map++;
  1659. + }
  1660. + if (wmo_map->nameId!=wmo_idx)
  1661. + continue;
  1662. + for (uint32 j=0; j<wmo.mohd->groups; j++)
  1663. + {
  1664. + char* wmo_fname=new char[256];
  1665. + std::string tmps=((std::string)wmo_root).substr(0,strlen(wmo_root)-4);
  1666. + sprintf(wmo_fname,"%s_%03i.wmo", tmps.c_str(), j);
  1667. + squeeze(wmo_fname, wmo_map, false);
  1668. + }
  1669. + }
  1670. + wmo_idx++;
  1671. + }
  1672.  
  1673. +}
  1674. +
  1675. +void wmoJuicer::readWDT(WDT_file *wdt)
  1676. +{
  1677. +
  1678. + //Get Liquid Data from wmos
  1679.  
  1680. + char* wmo_root;
  1681. + int wmo_idx=0;
  1682. + for (uint32 i=0; i<wdt->wmo->size; i+=strlen(wmo_root)+1)
  1683. + {
  1684. + wmo_root=(char*)(wdt->wmo->getWMO(i));
  1685. + WMO_file wmo;
  1686. + if (!wmo.loadFile(wmo_root))
  1687. +
  1688. + printf("could not load file %s\n", wmo_root);
  1689. + else
  1690. + {
  1691. + SMMapObjDef* wmo_map=&(wdt->modf->data);
  1692. + for (int j=0; j< wdt->modf->getCount(); j++)
  1693. + {
  1694. + if (wmo_map->nameId==wmo_idx)
  1695. + break;
  1696. + wmo_map++;
  1697. + }
  1698. + if (wmo_map->nameId!=wmo_idx)
  1699. + continue;
  1700. + for (uint32 j=0; j<wmo.mohd->groups; j++)
  1701. + {
  1702. + char* wmo_fname=new char[256];
  1703. + std::string tmps=((std::string)wmo_root).substr(0,strlen(wmo_root)-4);
  1704. + sprintf(wmo_fname,"%s_%03i.wmo", tmps.c_str(), j);
  1705. + squeeze(wmo_fname, wmo_map, true);
  1706. + }
  1707. + }
  1708. + wmo_idx++;
  1709. + }
  1710. +}
  1711. +void wmoJuicer::Juice(char* map_name, int map_id, WDT_file* wdt)
  1712. +{
  1713. + char mpq_filename[128]=".";
  1714. + clearLiquid();
  1715. + if (wdt->mphd->data1) //one global WMO
  1716. + {
  1717. + readWDT(wdt);
  1718. + for(int y=0; y < WDT_MAP_SIZE; ++y)
  1719. + for(int x=0; x< WDT_MAP_SIZE; ++x)
  1720. + saveWDT(map_id ,y,x);
  1721. + }
  1722. + //else Someplaces have both
  1723. + {
  1724. + for(int y = 0; y < WDT_MAP_SIZE; ++y)
  1725.  
  1726. + {
  1727. +
  1728.  
  1729. + for(uint32 x = 0; x < WDT_MAP_SIZE; ++x)
  1730.  
  1731. + {
  1732.  
  1733. + if (wdt->main->adt_list[y][x].exist)
  1734.  
  1735. + {
  1736.  
  1737. + sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_name, map_name, x, y);
  1738.  
  1739. + readADT(mpq_filename, x, y);
  1740. + }
  1741.  
  1742. + }
  1743. +
  1744. + // draw progress bar
  1745.  
  1746. + printf("Processing........................%d%%\r", (50 * (y+1)) / WDT_MAP_SIZE);
  1747.  
  1748. + }
  1749. + }
  1750. +}
  1751. +
  1752. +
  1753. +void wmoJuicer::clearLiquid()
  1754. +{
  1755. + memset(ranged_liquid_type, 0, sizeof(uint8)*ADT_CELLS_PER_GRID*ADT_CELLS_PER_GRID*WDT_MAP_SIZE*WDT_MAP_SIZE);
  1756. + memset(ranged_liquid_show, 0, sizeof(bool)*ADT_GRID_SIZE*ADT_GRID_SIZE*WDT_MAP_SIZE*WDT_MAP_SIZE);
  1757. + for (int cy=0; cy< WDT_MAP_SIZE; ++cy)
  1758. + for (int cx=0; cx< WDT_MAP_SIZE; ++cx)
  1759. + for (int y=0; y<= ADT_GRID_SIZE; ++y)
  1760. + for (int x=0; x<= ADT_GRID_SIZE; ++x)
  1761. + ranged_liquid_height[cy][cx][y][x]=-500.f;
  1762. +}
  1763. +
  1764. +bool wmoJuicer::getLiquid(int cell_x, int cell_y, uint8* type, bool* show, float* height)
  1765. +{
  1766. + memcpy(type, ranged_liquid_type[cell_y][cell_x], sizeof(uint8)*ADT_CELLS_PER_GRID*ADT_CELLS_PER_GRID);
  1767. + memcpy(show, ranged_liquid_show[cell_y][cell_x], sizeof(bool)*ADT_GRID_SIZE*ADT_GRID_SIZE);
  1768. + memcpy(height, ranged_liquid_height[cell_y][cell_x], sizeof(float)*(ADT_GRID_SIZE+1)*(ADT_GRID_SIZE+1));
  1769. +
  1770. + return true;
  1771. +}
  1772. +
  1773. +bool wmoJuicer::saveWDT(int map_id, int cell_y, int cell_x)
  1774. +{
  1775. + // Prepare map header
  1776.  
  1777. + map_fileheader map;
  1778.  
  1779. + map.mapMagic = MAP_MAGIC;
  1780.  
  1781. + map.versionMagic = MAP_VERSION_MAGIC;
  1782.  
  1783. +
  1784.  
  1785. + //============================================
  1786.  
  1787. + // Pack liquid data
  1788.  
  1789. + //============================================
  1790.  
  1791. + uint8 type = ranged_liquid_type[cell_y][cell_x][0][0];
  1792.  
  1793. + bool fullType = false;
  1794.  
  1795. + for (int y=0;y<ADT_CELLS_PER_GRID;y++)
  1796.  
  1797. + {
  1798.  
  1799. + for(int x=0;x<ADT_CELLS_PER_GRID;x++)
  1800.  
  1801. + {
  1802.  
  1803. + if (ranged_liquid_type[cell_y][cell_x][y][x]!=type)
  1804.  
  1805. + {
  1806.  
  1807. + fullType = true;
  1808.  
  1809. + y = ADT_CELLS_PER_GRID;
  1810.  
  1811. + break;
  1812.  
  1813. + }
  1814.  
  1815. + }
  1816.  
  1817. + }
  1818.  
  1819. +
  1820.  
  1821. + // no water data (if all grid have 0 liquid type)
  1822.  
  1823. + if (type == 0 && !fullType)
  1824.  
  1825. + {
  1826.  
  1827. + return false;
  1828.  
  1829. + }
  1830.  
  1831. +
  1832.  
  1833. + float maxHeight = -20000;
  1834.  
  1835. + float minHeight = 20000;
  1836.  
  1837. +
  1838.  
  1839. + map.areaMapOffset = sizeof(map);
  1840.  
  1841. + map.areaMapSize = sizeof(map_areaHeader);
  1842.  
  1843. +
  1844.  
  1845. + map_areaHeader areaHeader;
  1846.  
  1847. + areaHeader.fourcc = MAP_AREA_MAGIC;
  1848.  
  1849. + areaHeader.flags = 0;
  1850.  
  1851. + areaHeader.flags = MAP_AREA_NO_AREA;
  1852.  
  1853. + areaHeader.gridArea = 0;
  1854.  
  1855. +
  1856.  
  1857. + map.heightMapOffset = map.areaMapOffset + map.areaMapSize;
  1858.  
  1859. + map.heightMapSize = sizeof(map_heightHeader);
  1860.  
  1861. +
  1862.  
  1863. + map_heightHeader heightHeader;
  1864.  
  1865. + heightHeader.fourcc = MAP_HEIGTH_MAGIC;
  1866.  
  1867. + heightHeader.flags = 0;
  1868.  
  1869. + heightHeader.gridHeight = maxHeight;
  1870.  
  1871. + heightHeader.gridMaxHeight = maxHeight;
  1872.  
  1873. + heightHeader.flags |=MAP_HEIGHT_NO_HIGHT;
  1874.  
  1875. +
  1876.  
  1877. + map_liquidHeader liquidHeader;
  1878.  
  1879. +
  1880.  
  1881. + maxHeight = -20000;
  1882.  
  1883. + minHeight = 20000;
  1884.  
  1885. + int minX = 255, minY = 255;
  1886.  
  1887. + int maxX = 0, maxY = 0;
  1888.  
  1889. + for (int y=0; y<ADT_GRID_SIZE; y++)
  1890.  
  1891. + {
  1892.  
  1893. + for(int x=0; x<ADT_GRID_SIZE; x++)
  1894.  
  1895. + {
  1896.  
  1897. + if (ranged_liquid_show[cell_y][cell_x][y][x])
  1898.  
  1899. + {
  1900.  
  1901. + if (minX > x) minX = x;
  1902.  
  1903. + if (maxX < x) maxX = x;
  1904.  
  1905. + if (minY > y) minY = y;
  1906.  
  1907. + if (maxY < y) maxY = y;
  1908.  
  1909. + float h = ranged_liquid_height[cell_y][cell_x][y][x];
  1910.  
  1911. + if (maxHeight < h) maxHeight = h;
  1912.  
  1913. + if (minHeight > h) minHeight = h;
  1914.  
  1915. + }
  1916.  
  1917. + else
  1918.  
  1919. + ranged_liquid_height[cell_y][cell_x][y][x] = -500.0f;
  1920.  
  1921. + }
  1922.  
  1923. + }
  1924.  
  1925. + map.liquidMapOffset = map.heightMapOffset + map.heightMapSize;
  1926.  
  1927. + map.liquidMapSize = sizeof(map_liquidHeader);
  1928.  
  1929. + liquidHeader.fourcc = MAP_LIQUID_MAGIC;
  1930.  
  1931. + liquidHeader.flags = 0;
  1932.  
  1933. + liquidHeader.liquidType = 0;
  1934.  
  1935. + liquidHeader.offsetX = minX;
  1936.  
  1937. + liquidHeader.offsetY = minY;
  1938.  
  1939. + liquidHeader.width = maxX - minX + 1;
  1940.  
  1941. + liquidHeader.height = maxY - minY + 1;
  1942.  
  1943. + liquidHeader.liquidLevel = minHeight;
  1944.  
  1945. +
  1946.  
  1947. + if (maxHeight == minHeight)
  1948.  
  1949. + liquidHeader.flags|=MAP_LIQUID_NO_HIGHT;
  1950.  
  1951. +
  1952.  
  1953. + // Not need store if flat surface
  1954.  
  1955. + if ((maxHeight - minHeight) < 0.001f)
  1956.  
  1957. + liquidHeader.flags|=MAP_LIQUID_NO_HIGHT;
  1958.  
  1959. +
  1960.  
  1961. + if (!fullType)
  1962.  
  1963. + liquidHeader.flags|=MAP_LIQUID_NO_TYPE;
  1964.  
  1965. +
  1966.  
  1967. + if (liquidHeader.flags&MAP_LIQUID_NO_TYPE)
  1968.  
  1969. + liquidHeader.liquidType = type;
  1970.  
  1971. + else
  1972.  
  1973. + map.liquidMapSize+=sizeof(ranged_liquid_type[cell_y][cell_x]);
  1974.  
  1975. +
  1976.  
  1977. + if (!(liquidHeader.flags&MAP_LIQUID_NO_HIGHT))
  1978.  
  1979. + map.liquidMapSize+=sizeof(float)*liquidHeader.width*liquidHeader.height;
  1980.  
  1981. +
  1982.  
  1983. + char filename[1024];
  1984.  
  1985. + sprintf(filename, "%s/%03u%02u%02u.map", path, map_id, cell_y, cell_x);
  1986. +
  1987.  
  1988. +
  1989.  
  1990. + // Ok all data prepared - store it
  1991.  
  1992. + FILE *output=fopen(filename, "wb");
  1993.  
  1994. + if(!output)
  1995.  
  1996. + {
  1997.  
  1998. + printf("Can't create the output file '%s'\n", filename);
  1999.  
  2000. + return false;
  2001.  
  2002. + }
  2003.  
  2004. + fwrite(&map, sizeof(map), 1, output);
  2005.  
  2006. + // Store area data
  2007.  
  2008. + fwrite(&areaHeader, sizeof(areaHeader), 1, output);
  2009.  
  2010. + // Store height data
  2011.  
  2012. + fwrite(&heightHeader, sizeof(heightHeader), 1, output);
  2013.  
  2014. + // Store liquid data if need
  2015.  
  2016. + if (map.liquidMapOffset)
  2017.  
  2018. + {
  2019.  
  2020. + fwrite(&liquidHeader, sizeof(liquidHeader), 1, output);
  2021.  
  2022. + if (!(liquidHeader.flags&MAP_LIQUID_NO_TYPE))
  2023.  
  2024. + fwrite(ranged_liquid_type[cell_y][cell_x], sizeof(ranged_liquid_type[cell_y][cell_x]), 1, output);
  2025.  
  2026. + if (!(liquidHeader.flags&MAP_LIQUID_NO_HIGHT))
  2027.  
  2028. + {
  2029.  
  2030. + for (int y=0; y<liquidHeader.height;y++)
  2031.  
  2032. + fwrite(&ranged_liquid_height[cell_y][cell_x][y+liquidHeader.offsetY][liquidHeader.offsetX], sizeof(float), liquidHeader.width, output);
  2033.  
  2034. + }
  2035.  
  2036. + }
  2037.  
  2038. + fclose(output);
  2039.  
  2040. + return true;
  2041.  
  2042. +}
  2043. \ No newline at end of file
  2044. diff -r ccc441794de0 contrib/extractor/wmoJuicer.h
  2045. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  2046. +++ b/contrib/extractor/wmoJuicer.h Mon Jul 13 22:54:14 2009 -0400
  2047. -0,0 +1,153 @@
  2048. +/*
  2049. +* Wmo Juicer (Squeezes the liquid from WMOs)
  2050. +* Author: raven_coda
  2051. +*
  2052. +*
  2053. +*/
  2054. +
  2055. +
  2056. +#ifndef WMOJUICER_H
  2057. +#define WMOJUICER_H
  2058. +
  2059. +#include "loadlib/loadlib.h"
  2060. +#include "loadlib/adt.h"
  2061.  
  2062. +#include "loadlib/wdt.h"
  2063. +
  2064. +#define MAP_LIQUID_TYPE_NO_WATER 0x00
  2065. +#define MAP_LIQUID_TYPE_WATER 0x01
  2066. +#define MAP_LIQUID_TYPE_OCEAN 0x02
  2067. +#define MAP_LIQUID_TYPE_MAGMA 0x04
  2068. +#define MAP_LIQUID_TYPE_SLIME 0x08
  2069. +
  2070. +#define MAP_LIQUID_TYPE_DARK_WATER 0x10
  2071. +#define MAP_LIQUID_TYPE_WMO_WATER 0x20
  2072. +
  2073. +
  2074. +#define BLOCK (ADT_CELLS_PER_GRID * ADT_CELLS_PER_GRID) + (ADT_GRID_SIZE * ADT_GRID_SIZE) + (4 * (ADT_GRID_SIZE+1)*(ADT_GRID_SIZE+1))
  2075. +
  2076. +class wmoJuicer{
  2077. +public:
  2078. + class wmo_chunk{
  2079. + public:
  2080. + union{
  2081. + uint32 fcc;
  2082. + char fcc_txt[4];
  2083. + };
  2084. + uint32 size;
  2085. + uint32 pad;
  2086. + };
  2087. +
  2088. + struct liquid_data{
  2089.  
  2090. + uint16 light;
  2091.  
  2092. + uint16 right;
  2093.  
  2094. + float height;
  2095.  
  2096. + };
  2097. +
  2098. + class wmo_MLIQ{
  2099. + union{
  2100. + uint32 fcc;
  2101. + char fcc_txt[4];
  2102. + };
  2103. + public:
  2104. + uint32 size;
  2105. + uint32 xv;
  2106. + uint32 yv;
  2107. + uint32 xt;
  2108. + uint32 yt;
  2109. + float pos[3];
  2110. + uint16 matID;
  2111. + uint32 data;
  2112. + liquid_data* getLiquidData(int x, int y) {return (liquid_data*)((uint8 *)&data+(y*xv+x)*sizeof(liquid_data));}
  2113. + uint8 getLiquidFlags(int x, int y){ return ((uint8 *)&data+(yv*xv)*sizeof(liquid_data))[y*xt+x];}
  2114. + };
  2115. +
  2116. + class wmo_MOGP{
  2117. + union{
  2118. + uint32 fcc;
  2119. + char fcc_txt[4];
  2120. + };
  2121. + public:
  2122. + uint32 size;
  2123. + uint32 groupName;
  2124. + uint32 descName;
  2125. + uint32 flags;
  2126. + uint32 pad;
  2127. + bool prepareLoadedData();
  2128. + bool hasWater(){ return flags & 0x1000;}
  2129. + wmo_chunk* getName(){ return (wmo_chunk*)((uint8 *)&pad+groupName);}
  2130. + wmo_chunk* getDesc(){ return (wmo_chunk*)((uint8 *)&pad+descName);}
  2131. + };
  2132. +
  2133. + class wmo_MOHD{
  2134. + union{
  2135. + uint32 fcc;
  2136. + char fcc_txt[4];
  2137. + };
  2138. + public:
  2139. + uint32 size;
  2140. + uint32 mats;
  2141. + uint32 groups;
  2142. + uint32 portals;
  2143. + uint32 pad;
  2144. + bool prepareLoadedData();
  2145. + };
  2146. +
  2147. + struct group_entry
  2148. + {
  2149. + uint32 flags;
  2150. + float bb1[3];
  2151. + float bb2[3];
  2152. + uint32 nameoffs;
  2153. + };
  2154. +
  2155. + class WMO_file : public FileLoader{
  2156. + public:
  2157. + bool prepareLoadedData();
  2158. +
  2159. + WMO_file();
  2160. + ~WMO_file();
  2161. + void free();
  2162. +
  2163. + union{
  2164. + wmo_MOGP *mogp;
  2165. + wmo_MOHD *mohd;
  2166. + };
  2167. +
  2168. + wmo_chunk *mogi;
  2169. + wmo_chunk *mogn;
  2170. + wmo_MLIQ *mliq;
  2171. +
  2172. + enum wmo_type{
  2173. + root,
  2174. + group
  2175. + };
  2176. +
  2177. + wmo_type type;
  2178. + };
  2179. +
  2180. + wmoJuicer(const char* outdir);
  2181. + ~wmoJuicer();
  2182. +
  2183. + void Juice(char* map_name, int map_id, WDT_file* wdt);
  2184. + bool getLiquid(int cell_x, int cell_y, uint8* type, bool* show, float* height);
  2185. +
  2186. +private:
  2187. + void readADT(char *filename, int cell_y, int cell_x);
  2188. + void readWDT(WDT_file* wdt);
  2189. + bool saveWDT(int map_id, int cell_y, int cell_x);
  2190. +
  2191. + void squeeze(char *wmo_file, SMMapObjDef* wmo_map, bool global);
  2192. +
  2193. + void clearLiquid();
  2194. +
  2195. + uint8 ranged_liquid_type[WDT_MAP_SIZE][WDT_MAP_SIZE][ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
  2196. + bool ranged_liquid_show[WDT_MAP_SIZE][WDT_MAP_SIZE][ADT_GRID_SIZE][ADT_GRID_SIZE];
  2197.  
  2198. + float ranged_liquid_height[WDT_MAP_SIZE][WDT_MAP_SIZE][ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
  2199. + char path[128];
  2200. + char filepath[128];
  2201. +
  2202. +
  2203. +};
  2204. +
  2205. +
  2206. +#endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement