Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: apreiml/genieutils
base: aa0c3fae0f
...
head fork: apreiml/genieutils
compare: a4604d57ef
  • 2 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
Commits on Feb 25, 2012
@apreiml scn: resource started cb340fc
Commits on Mar 02, 2012
@apreiml progress scn a4604d5
View
2  CMakeLists.txt
@@ -97,6 +97,8 @@ set(RESOURCE_SRC
set(SCRIPT_SRC
src/script/ScnFile.cpp
+ src/script/scn/ScnResource.cpp
+ src/script/scn/ScnPlayerData.cpp
)
set(UTIL_SRC
View
4 include/genie/file/IFile.h
@@ -92,6 +92,10 @@ class IFile : public ISerializable, boost::noncopyable
protected:
+ //----------------------------------------------------------------------------
+ /// The unload method will be called before loading an object, but only
+ /// if the object was already loaded once.
+ //
virtual void unload(void);
private:
View
26 include/genie/script/ScnFile.h
@@ -24,8 +24,11 @@
#include "genie/file/IFile.h"
#include "genie/file/Compressor.h"
+#include "scn/ScnResource.h"
+
namespace genie
{
+
class ScnPlayerData1;
//------------------------------------------------------------------------------
@@ -80,6 +83,8 @@ class ScnFile : public IFile
std::string originalFileName;
+ ScnResource resource;
+
private:
std::string version_;
@@ -94,27 +99,6 @@ class ScnFile : public IFile
void serializeVersion(void);
void serializeVersion2(void);
};
-
-class ScnPlayerData1 : public ISerializable
-{
-public:
- ScnPlayerData1();
- virtual ~ScnPlayerData1();
-
- /// boolean
- uint32_t active;
-
- /// boolean
- uint32_t human;
-
- uint32_t civilizationId;
-
- /// constant = 4 ??
- uint32_t unknown1;
-
-private:
- virtual void serializeObject(void);
-};
}
View
65 include/genie/script/scn/ScnPlayerData.h
@@ -0,0 +1,65 @@
+/*
+ genieutils - <description>
+ Copyright (C) 2011 Armin Preiml <email>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef GENIE_SCN_PLAYER_DATA_H
+#define GENIE_SCN_PLAYER_DATA_H
+
+#include "genie/file/ISerializable.h"
+
+#include <stdint.h>
+
+namespace genie
+{
+
+class ScnPlayerData1 : public ISerializable
+{
+public:
+ ScnPlayerData1();
+ virtual ~ScnPlayerData1();
+
+ /// boolean
+ uint32_t active;
+
+ /// boolean
+ uint32_t human;
+
+ uint32_t civilizationId;
+
+ /// constant = 4 ??
+ uint32_t unknown1;
+
+private:
+ virtual void serializeObject(void);
+};
+
+class ScnPlayerData2 : public ISerializable
+{
+public:
+ ScnPlayerData2();
+ virtual ~ScnPlayerData2();
+
+
+
+private:
+ virtual void serializeObject(void);
+
+};
+
+}
+
+#endif // GENIE_SCN_PLAYER_DATA_H
View
102 include/genie/script/scn/ScnResource.h
@@ -0,0 +1,102 @@
+/*
+ genieutils - <description>
+ Copyright (C) 2011 Armin Preiml <email>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef GENIE_SCN_RESOURCE_H
+#define GENIE_SCN_RESOURCE_H
+
+#include "genie/file/ISerializable.h"
+
+#include <stdint.h>
+
+namespace genie
+{
+
+class ScnResource : public ISerializable
+{
+public:
+ ScnResource();
+ virtual ~ScnResource();
+
+ /// GV >= AoK
+ uint32_t instructionsStringTable;
+
+ /// GV >= AoK
+ uint32_t hintsStringTable;
+
+ /// GV >= AoK
+ uint32_t victoryStringTable;
+
+ /// GV >= AoK
+ uint32_t lossStringTable;
+
+ /// GV >= AoK
+ uint32_t historyStringTable;
+
+ /// GV >= TC
+ uint32_t scoutsStringTable;
+
+ // Messages
+
+ std::string instructions;
+
+ std::string hints;
+
+ std::string victory;
+
+ std::string loss;
+
+ std::string history;
+
+ /// GV >= TC
+ std::string scouts;
+
+ std::string pregameCinematicFilename;
+
+ std::string victoryCinematicFilename;
+
+ std::string lossCinematicFilename;
+
+ std::string backgroundFilename;
+
+ // Bitmap
+
+ /// Boolean
+ uint32_t bitmapIncluded;
+
+ uint32_t bitmapWidth;
+
+ uint32_t bitmapHeigth;
+
+ /// -1 if there's a bitmap, 1 otherwise
+ int16_t unknown1;
+
+ uint16_t bitmapByteSize;
+
+ char* bitmap;
+
+
+private:
+ virtual void serializeObject(void);
+
+ void serializeBitmap(void);
+
+};
+
+}
+
+#endif // GENIE_SCN_RESOURCE_H
View
55 main.cpp
@@ -77,8 +77,11 @@ void testDrs()
genie::SlpFilePtr slpf = drs.getSlpFile(slp_id);
drs.getSlpFile(slp_id);
+ sf::Image img;
+ img.LoadFromFile("image_part.bmp");
+
text.LoadFromImage(createSfImage(slpf->getFrame(1), pal));
- text2.LoadFromImage(createSfImage(slpf->getFrame(1), pal));
+ text2.LoadFromImage(img);
sf::Sprite Sprite(text);
@@ -117,41 +120,38 @@ void testScn()
genie::ScnFile scn;
// scn.extractRaw("small_crater_lake.scx", "raw.scx");
+ scn.extractRaw("test2.scx", "raw.scx");
- scn.load("small_crater_lake.scx");
-// scn.load("test2.scx");
+// scn.load("small_crater_lake.scx");
+ scn.load("test2.scx");
std::cout << "Original filename: " << scn.originalFileName << std::endl;
- scn.saveAs("xxxx.scx");
+// std::cout << scn.scenarioInstructions << std::endl;
+// std::cout << scn.resource.instructions << std::endl;
+// std::cout << scn.resource.scouts << std::endl;
+// std::cout << scn.resource.bitmapIncluded << std::endl;
+ std::cout << "Bitmap byte size: " << scn.resource.bitmapByteSize << std::endl;
- genie::ScnFile scn2;
- scn2.load("xxxx.scx");
+ sf::Image img;
+ /*
+ std::ofstream ofs;
+ ofs.open("qqq", std::ios::binary);
- std::cout << "Original filename: " << scn2.originalFileName << std::endl;
+ ofs.write(scn.resource.bitmap, scn.resource.bitmapByteSize);
+ ofs.close();
+ */
-}
-
-size_t xxstrnlen(const char *str, size_t maxLen)
-{
-// const char *ptr = 0;
-// for (ptr = str; *ptr != '\0' && maxLen-- != 0; ++ptr);
+// scn.saveAs("xxxx.scx");
-// return (ptr - str);
-
- size_t len = 0;
+// genie::ScnFile scn2;
+// scn2.load("xxxx.scx");
- for (unsigned int i=0; i < maxLen; i++)
- {
- if (str[i] == '\0')
- return len;
-
- len ++;
- }
- return len;
+// std::cout << "Original filename: " << scn2.originalFileName << std::endl;
+
}
int main(int argc, char **argv) {
@@ -162,13 +162,6 @@ int main(int argc, char **argv) {
testScn();
-
-// char x[1];
-//
-// x[0] = 'c';
-//
-// std::cout << xxstrnlen(x, 1) << std::endl;
-
/*
std::ifstream ifs;
std::ofstream ofs;
View
26 src/script/ScnFile.cpp
@@ -18,6 +18,8 @@
#include "genie/script/ScnFile.h"
+#include "genie/script/scn/ScnPlayerData.h"
+
#include <math.h>
#include <boost/iostreams/copy.hpp>
@@ -50,7 +52,6 @@ void ScnFile::extractRaw(const char *from, const char *to)
ifs.read(reinterpret_cast<char *>(&headerLen), 4);
ofs.write(reinterpret_cast<char *>(&headerLen), 4);
- std::cout << headerLen << std::endl;
char header[headerLen];
@@ -84,8 +85,12 @@ void ScnFile::serializeObject(void)
serialize<uint32_t>(unknown2);
serialize<uint32_t>(playerCount);
+ std::cout << "Start compression: " << tellg() << std::endl;
+
compressor_.beginCompression();
+ std::cout << "Start compression: " << tellg() << std::endl;
+
// Compressed header:
serialize<uint32_t>(unknown3);
@@ -118,6 +123,8 @@ void ScnFile::serializeObject(void)
// Messages and cinematics
+ serialize<ISerializable>(resource);
+
compressor_.endCompression();
}
@@ -196,21 +203,4 @@ void ScnFile::serializeVersion2(void)
}
}
-
-ScnPlayerData1::ScnPlayerData1()
-{
-}
-
-ScnPlayerData1::~ScnPlayerData1()
-{
-}
-
-void ScnPlayerData1::serializeObject(void)
-{
- serialize<uint32_t>(active);
- serialize<uint32_t>(human);
- serialize<uint32_t>(civilizationId);
- serialize<uint32_t>(unknown1);
-}
-
}
View
53 src/script/scn/ScnPlayerData.cpp
@@ -0,0 +1,53 @@
+/*
+ genieutils - <description>
+ Copyright (C) 2011 Armin Preiml <email>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "genie/script/scn/ScnPlayerData.h"
+
+namespace genie
+{
+
+ScnPlayerData1::ScnPlayerData1()
+{
+}
+
+ScnPlayerData1::~ScnPlayerData1()
+{
+}
+
+void ScnPlayerData1::serializeObject(void)
+{
+ serialize<uint32_t>(active);
+ serialize<uint32_t>(human);
+ serialize<uint32_t>(civilizationId);
+ serialize<uint32_t>(unknown1);
+}
+
+
+ScnPlayerData2::ScnPlayerData2()
+{
+}
+
+ScnPlayerData2::~ScnPlayerData2()
+{
+}
+
+void ScnPlayerData2::serializeObject(void)
+{
+}
+
+}
View
133 src/script/scn/ScnResource.cpp
@@ -0,0 +1,133 @@
+/*
+ genieutils - <description>
+ Copyright (C) 2011 Armin Preiml <email>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "genie/script/scn/ScnResource.h"
+
+#include <fstream>
+
+namespace genie
+{
+
+ScnResource::ScnResource()
+{
+ instructionsStringTable = 0;
+ hintsStringTable = 0;
+ victoryStringTable = 0;
+ lossStringTable = 0;
+ historyStringTable = 0;
+ scoutsStringTable = 0;
+
+ bitmapIncluded = 0;
+ bitmapWidth = 0;
+ bitmapHeigth = 0;
+ unknown1 = 1;
+
+ bitmapByteSize = 0;
+ bitmap = 0;
+}
+
+ScnResource::~ScnResource()
+{
+ delete bitmap;
+}
+
+void ScnResource::serializeObject(void)
+{
+ std::cout << "Resource start pos: " << tellg() << std::endl;
+
+ if (getGameVersion() >= genie::GV_AoK)
+ {
+ serialize<uint32_t>(instructionsStringTable);
+ serialize<uint32_t>(hintsStringTable);
+ serialize<uint32_t>(victoryStringTable);
+ serialize<uint32_t>(lossStringTable);
+ serialize<uint32_t>(historyStringTable);
+
+ if (getGameVersion() >= genie::GV_TC)
+ serialize<uint32_t>(scoutsStringTable);
+ }
+
+ serializeSizedString<uint16_t>(instructions);
+ serializeSizedString<uint16_t>(hints);
+ serializeSizedString<uint16_t>(victory);
+ serializeSizedString<uint16_t>(loss);
+ serializeSizedString<uint16_t>(history);
+
+ if (getGameVersion() >= genie::GV_TC)
+ serializeSizedString<uint16_t>(scouts);
+
+ serializeSizedString<uint16_t>(pregameCinematicFilename);
+ serializeSizedString<uint16_t>(victoryCinematicFilename);
+ serializeSizedString<uint16_t>(lossCinematicFilename);
+ serializeSizedString<uint16_t>(backgroundFilename);
+
+ serializeBitmap();
+}
+
+void ScnResource::serializeBitmap(void)
+{
+ serialize<uint32_t>(bitmapIncluded);
+
+ serialize<uint32_t>(bitmapWidth);
+ serialize<uint32_t>(bitmapHeigth);
+ serialize<int16_t>(unknown1);
+
+ if (bitmapIncluded == 0)
+ return;
+
+ if (isOperation(OP_READ))
+ {
+// BitmapInfoHeader bmpHeader;
+
+// serialize<BitmapInfoHeader>(bmpHeader);
+
+// TODO generate 1. bitmap header
+
+ char *bmpHeader = 0;
+
+ serialize<char>(&bmpHeader, 0x28); //TODO header size constant (or read!!)
+
+ bitmapByteSize = *reinterpret_cast<uint32_t *>(bmpHeader + 20);
+
+ bitmap = new char[bitmapByteSize];
+
+// strncpy(bitmap, bmpHeader, 0x28);
+ for (unsigned int i=0; i < 0x28; i++)
+ bitmap[i] = bmpHeader[i];
+
+ char *bitmapStart = (bitmap + 0x28);
+
+ serialize<char>(&bitmapStart, bitmapByteSize - 0x28);
+
+ /*
+ if (bmpHeader.headerSize != 0x28)
+ std::cerr << "ScnResource: Unknown header size!" << std::endl;
+
+ bitmap = new char[bmpHeader.bmpByteSize];
+
+ char *bitmapStart = (bitmap + bmpHeader.headerSize);
+
+ strncpy(bitmap, reinterpret_cast<char *>(&bmpHeader), bmpHeader.headerSize);
+
+ serialize<char>(&bitmapStart, bmpHeader.bmpByteSize - bmpHeader.headerSize);
+
+// serialize<uint8_t>(&bitmap, bmpHeader.bmpByteSize - bmpHeader.headerSize);*/
+ }
+}
+
+}

No commit comments for this range

Something went wrong with that request. Please try again.