Worldstone
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
PaletteTests.cpp
Go to the documentation of this file.
1 
5 #include <Platform.h>
6 #include <FileStream.h>
7 #include <Palette.h>
8 #include <SystemUtils.h>
9 #include <doctest.h>
10 
12 using WorldStone::PL2;
14 
15 TEST_CASE("PL2 creation")
16 {
17  Palette basePalette;
18  bool ok = basePalette.decode("pal.dat");
19  REQUIRE(ok);
20 
21  std::unique_ptr<PL2> pl2 = PL2::CreateFromPalette(basePalette);
22  FileStream fs("pal.pl2");
23  REQUIRE(fs.good());
24  std::unique_ptr<PL2> pl2File = std::make_unique<PL2>();
25  fs.read(pl2File.get(), sizeof(PL2));
26 
27  const bool sameBase = pl2->basePalette == pl2File->basePalette;
28  REQUIRE(sameBase);
29  CHECK(pl2->basePalette == pl2File->basePalette);
30  for (size_t i = 0; i < 32; i++)
31  CHECK(pl2->lightLevelVariations[i].indices == pl2File->lightLevelVariations[i].indices);
32  for (size_t i = 0; i < 16; i++)
33  CHECK(pl2->invColorVariations[i].indices == pl2File->invColorVariations[i].indices);
34 
35  CHECK(pl2->selectedUnitShift.indices == pl2File->selectedUnitShift.indices);
36  for (size_t blendLevel = 0; blendLevel < 3; blendLevel++)
37  for (size_t i = 0; i < 256; i++)
38  CHECK(pl2->alphaBlend[blendLevel][i].indices
39  == pl2File->alphaBlend[blendLevel][i].indices);
40 
41  for (size_t i = 0; i < 256; i++)
42  CHECK(pl2->additiveBlend[i].indices == pl2File->additiveBlend[i].indices);
43 
44  for (size_t i = 0; i < 256; i++)
45  CHECK(pl2->multiplicativeBlend[i].indices == pl2File->multiplicativeBlend[i].indices);
46 
47  for (size_t i = 0; i < 111; i++)
48  CHECK(pl2->hueVariations[i].indices == pl2File->hueVariations[i].indices);
49 
50  // Probably unsused ? Always 0
51  for (size_t i = 0; i < 14; i++)
52  CHECK(pl2->unknownColorVariations[i].indices == pl2File->unknownColorVariations[i].indices);
53 
54  CHECK(pl2->redTones.indices == pl2File->redTones.indices);
55  CHECK(pl2->greenTones.indices == pl2File->greenTones.indices);
56  CHECK(pl2->blueTones.indices == pl2File->blueTones.indices);
57 
58  for (size_t i = 0; i < 256; i++)
59  CHECK(pl2->maxComponentBlend[i].indices == pl2File->maxComponentBlend[i].indices);
60 
61  CHECK(pl2->darkenedColorShift.indices == pl2File->darkenedColorShift.indices);
62  for (size_t i = 0; i < 13; i++)
63  {
64  CHECK(pl2->textColors[i] == pl2File->textColors[i]);
65  CHECK(pl2->textColorShifts[i].indices == pl2File->textColorShifts[i].indices);
66  }
67 }
Precomputed palette variations in the form of palette shifts.
Definition: Palette.h:67
TEST_CASE("DCC decoding BaalSpirit.dcc")
Try to decode BaalSpirit.dcc.
Wrapper around POSIX file io, same as ifstream but without iostream formatting.
Definition: FileStream.h:16
Platform specific tools and macros.
Helper to load a Diablo 2 palette (.pal/.dat format)
Definition: Palette.h:21