Skip to content

Commit 17376f7

Browse files
author
Mark Hutcheson
committed
Update to newest mingw, support LI version 1.2
1 parent 6cdd9a7 commit 17376f7

File tree

11 files changed

+2278
-45
lines changed

11 files changed

+2278
-45
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
SHELL=C:/Windows/System32/cmd.exe
2-
objects = wordPackDict.o sndmanifest.o itemmanifest.o combodb.o residmap.o zpipe.o ogg.o image.o font.o loctex.o parse.o matrix.o
2+
objects = wordPackDict.o sndmanifest.o itemmanifest.o combodb.o residmap.o zpipe.o ogg.o image.o font.o loctex.o parse.o matrix.o tinyxml2.o
33
decompressobjects = $(objects) liDecompress.o threadDecompress.o
44
comressobjects = $(objects) liCompress.o threadCompress.o
55
HEADERPATH = -I./include
66
LIBPATH = -L./libs
7-
LIB = -lpng -lzlib -lttvfs -lvorbis -logg -ltinyxml2
7+
LIB = -lpng -lzlib -lttvfs -lvorbis -logg
88

99
all : liDecompress.exe liCompress.exe recalcSoundManifest.exe strip.exe modManage.exe util/pullpakfiles.exe util/removeresc.exe util/repack.exe util/hash.exe util/WinResource.exe
1010

@@ -13,7 +13,7 @@ liDecompress.exe : $(decompressobjects)
1313
liCompress.exe : $(comressobjects)
1414
g++ -Wall -O2 -o $@ $(comressobjects) $(LIBPATH) $(LIB)
1515
recalcSoundManifest.exe : recalcSoundManifest.o
16-
g++ -Wall -O2 -o $@ $< ogg.o $(LIBPATH) $(LIB)
16+
g++ -Wall -O2 -o $@ $< ogg.o tinyxml2.o $(LIBPATH) $(LIB)
1717
strip.exe : strip.o
1818
g++ -Wall -O2 -o $@ $<
1919
modManage.exe : modManage.o
@@ -27,7 +27,7 @@ util/repack.exe : util/repack.o
2727
util/WinResource.exe : util/WinResource.o
2828
g++ -Wall -O2 -o $@ $<
2929
util/hash.exe : util/hash.o
30-
g++ -Wall -O2 -o $@ $< residmap.o $(LIBPATH) -ltinyxml2
30+
g++ -Wall -O2 -o $@ $< residmap.o tinyxml2.o
3131

3232
%.o: %.cpp
3333
g++ -O2 -c -MMD -o $@ $< $(HEADERPATH)

combodb.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool comboDBToXML(const wchar_t* cFilename)
6969
}
7070
vCombos.push_back(cr);
7171
}
72-
cout << "Done reading combos" << endl;
72+
//cout << "Done reading combos" << endl;
7373

7474
//Read in combo items
7575
vector<comboItemRecord> vComboItems;
@@ -85,7 +85,7 @@ bool comboDBToXML(const wchar_t* cFilename)
8585
vComboItems.push_back(cir);
8686
}
8787

88-
cout << "Done reading items" << endl;
88+
//cout << "Done reading items" << endl;
8989

9090
//Read in string table-----------------------------------------------------------
9191
//Read in string table header
@@ -157,6 +157,9 @@ bool comboDBToXML(const wchar_t* cFilename)
157157
elem->SetAttribute("id", vCombos[i].id); //TODO: What for???
158158
elem->SetAttribute("coinvalue", vCombos[i].value);
159159
elem->SetAttribute("stampvalue", vCombos[i].stampValue);
160+
#ifdef VERSION_12
161+
elem->SetAttribute("stridx", vCombos[i].idStrTblIdx);
162+
#endif
160163

161164
//Write combo name
162165
XMLElement* elem2 = doc->NewElement("name");
@@ -256,14 +259,21 @@ bool XMLToComboDB(const wchar_t* cFilename)
256259
delete doc;
257260
return false;
258261
}
262+
#ifdef VERSION_12
263+
if(elem->QueryIntAttribute("stridx", &cr.idStrTblIdx) != XML_NO_ERROR)
264+
{
265+
cout << "Unable to get idStrTblIdx from XML file " << ws2s(sXMLFile) << endl;
266+
delete doc;
267+
return false;
268+
}
269+
#endif
259270

260271
cr.id = id;
261272
cr.title.key = lStringTable.size();
262273
cr.value = coinval;
263274
cr.stampValue = stampval;
264275
cr.firstItemIdx = lItemRecords.size();
265276
cr.numItems = 0;
266-
//TODO cr.idStrTblIdx = from XML when available
267277
XMLElement* elem2 = elem->FirstChildElement("name");
268278
if(elem2 == NULL) continue;
269279
if(elem2->QueryUnsignedAttribute("strid", &cr.title.id) != XML_NO_ERROR)

image.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,14 @@ bool myPicturesToXML(wstring sFilename)
468468
memcpy(data, &ih, sizeof(ImageHeader)); //Copy in header
469469
memcpy(&data[sizeof(ImageHeader)], &cPictureBytes[i->offset], i->width * i->height * 4); //Copy in image data
470470

471-
wchar_t cName[256];
472-
wsprintf(cName, TEXT("%s.%d.png"), sFilename.c_str(), iCurImg++);
473-
convertToPNG(cName, data, i->width * i->height * 4);
474-
471+
iCurImg++;
472+
wstring sName = sFilename;
473+
sName += TEXT(".");
474+
sName.push_back(iCurImg + L'0');
475+
sName += TEXT(".png");
476+
convertToPNG(sName.c_str(), data, i->width * 4);
475477
XMLElement* elem = doc->NewElement("image");
476-
elem->SetAttribute("filename", ws2s(cName).c_str());
478+
elem->SetAttribute("filename", ws2s(sName).c_str());
477479
root->InsertEndChild(elem);
478480
}
479481

@@ -657,12 +659,14 @@ bool smokeImageToXML(wstring sFilename)
657659
curPtr++;
658660
}
659661

660-
wchar_t cName[256];
661-
wsprintf(cName, TEXT("%s.%d.png"), sFilename.c_str(), iCurImg++);
662-
convertToPNG(cName, data, i->width * i->height * 4);
663-
662+
iCurImg++;
663+
wstring sName = sFilename;
664+
sName += TEXT(".");
665+
sName.push_back(iCurImg + L'0');
666+
sName += TEXT(".png");
667+
convertToPNG(sName.c_str(), data, i->width * 4);
664668
XMLElement* elem = doc->NewElement("image");
665-
elem->SetAttribute("filename", ws2s(cName).c_str());
669+
elem->SetAttribute("filename", ws2s(sName).c_str());
666670
elem->SetAttribute("id", i->id);
667671
root->InsertEndChild(elem);
668672
}
@@ -842,11 +846,14 @@ bool fluidPalettesToXML(wstring sFilename)
842846
memcpy(data, &ih, sizeof(ImageHeader)); //Copy in header
843847
memcpy(&data[sizeof(ImageHeader)], &cPictureBytes[i->offset*4], i->width*4); //Copy in image data
844848

845-
wchar_t cName[256];
846-
wsprintf(cName, TEXT("%s.%d.png"), sFilename.c_str(), iCurImg++);
847-
convertToPNG(cName, data, i->width * 4);
849+
iCurImg++;
850+
wstring sName = sFilename;
851+
sName += TEXT(".");
852+
sName.push_back(iCurImg + L'0');
853+
sName += TEXT(".png");
854+
convertToPNG(sName.c_str(), data, i->width * 4);
848855
XMLElement* elem = doc->NewElement("image");
849-
elem->SetAttribute("filename", ws2s(cName).c_str());
856+
elem->SetAttribute("filename", ws2s(sName).c_str());
850857
elem->SetAttribute("id", i->id);
851858
root->InsertEndChild(elem);
852859
}

include/tinyxml2.h

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ not claim that you wrote the original software. If you use this
1414
software in a product, an acknowledgment in the product documentation
1515
would be appreciated but is not required.
1616
17+
1718
2. Altered source versions must be plainly marked as such, and
1819
must not be misrepresented as being the original software.
1920
@@ -57,6 +58,23 @@ distribution.
5758
# endif
5859
#endif
5960

61+
#ifdef _MSC_VER
62+
# pragma warning(push)
63+
# pragma warning(disable: 4251)
64+
#endif
65+
66+
#ifdef _WIN32
67+
# ifdef TINYXML2_EXPORT
68+
# define TINYXML2_LIB __declspec(dllexport)
69+
# elif defined(TINYXML2_IMPORT)
70+
# define TINYXML2_LIB __declspec(dllimport)
71+
# else
72+
# define TINYXML2_LIB
73+
# endif
74+
#else
75+
# define TINYXML2_LIB
76+
#endif
77+
6078

6179
#if defined(DEBUG)
6280
# if defined(_MSC_VER)
@@ -108,11 +126,9 @@ class XMLDocument;
108126
class XMLElement;
109127
class XMLAttribute;
110128
class XMLComment;
111-
class XMLNode;
112129
class XMLText;
113130
class XMLDeclaration;
114131
class XMLUnknown;
115-
116132
class XMLPrinter;
117133

118134
/*
@@ -408,7 +424,7 @@ class MemPoolT : public MemPool
408424
409425
@sa XMLNode::Accept()
410426
*/
411-
class XMLVisitor
427+
class TINYXML2_LIB XMLVisitor
412428
{
413429
public:
414430
virtual ~XMLVisitor() {}
@@ -554,7 +570,7 @@ class XMLUtil
554570
555571
@endverbatim
556572
*/
557-
class XMLNode
573+
class TINYXML2_LIB XMLNode
558574
{
559575
friend class XMLDocument;
560576
friend class XMLElement;
@@ -820,7 +836,7 @@ class XMLNode
820836
you generally want to leave it alone, but you can change the output mode with
821837
SetCData() and query it with CData().
822838
*/
823-
class XMLText : public XMLNode
839+
class TINYXML2_LIB XMLText : public XMLNode
824840
{
825841
friend class XMLBase;
826842
friend class XMLDocument;
@@ -859,7 +875,7 @@ class XMLText : public XMLNode
859875

860876

861877
/** An XML Comment. */
862-
class XMLComment : public XMLNode
878+
class TINYXML2_LIB XMLComment : public XMLNode
863879
{
864880
friend class XMLDocument;
865881
public:
@@ -897,7 +913,7 @@ class XMLComment : public XMLNode
897913
The text of the declaration isn't interpreted. It is parsed
898914
and written as a string.
899915
*/
900-
class XMLDeclaration : public XMLNode
916+
class TINYXML2_LIB XMLDeclaration : public XMLNode
901917
{
902918
friend class XMLDocument;
903919
public:
@@ -929,7 +945,7 @@ class XMLDeclaration : public XMLNode
929945
930946
DTD tags get thrown into XMLUnknowns.
931947
*/
932-
class XMLUnknown : public XMLNode
948+
class TINYXML2_LIB XMLUnknown : public XMLNode
933949
{
934950
friend class XMLDocument;
935951
public:
@@ -988,7 +1004,7 @@ enum XMLError {
9881004
@note The attributes are not XMLNodes. You may only query the
9891005
Next() attribute in a list.
9901006
*/
991-
class XMLAttribute
1007+
class TINYXML2_LIB XMLAttribute
9921008
{
9931009
friend class XMLElement;
9941010
public:
@@ -1089,7 +1105,7 @@ class XMLAttribute
10891105
and can contain other elements, text, comments, and unknowns.
10901106
Elements also contain an arbitrary number of attributes.
10911107
*/
1092-
class XMLElement : public XMLNode
1108+
class TINYXML2_LIB XMLElement : public XMLNode
10931109
{
10941110
friend class XMLBase;
10951111
friend class XMLDocument;
@@ -1409,7 +1425,7 @@ enum Whitespace {
14091425
All Nodes are connected and allocated to a Document.
14101426
If the Document is deleted, all its Nodes are also deleted.
14111427
*/
1412-
class XMLDocument : public XMLNode
1428+
class TINYXML2_LIB XMLDocument : public XMLNode
14131429
{
14141430
friend class XMLElement;
14151431
public:
@@ -1511,7 +1527,7 @@ class XMLDocument : public XMLNode
15111527
// printer.CStr() has a const char* to the XML
15121528
@endverbatim
15131529
*/
1514-
void Print( XMLPrinter* streamer=0 );
1530+
void Print( XMLPrinter* streamer=0 ) const;
15151531
virtual bool Accept( XMLVisitor* visitor ) const;
15161532

15171533
/**
@@ -1667,7 +1683,7 @@ class XMLDocument : public XMLNode
16671683
16681684
See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects.
16691685
*/
1670-
class XMLHandle
1686+
class TINYXML2_LIB XMLHandle
16711687
{
16721688
public:
16731689
/// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
@@ -1751,7 +1767,7 @@ class XMLHandle
17511767
A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the
17521768
same in all regards, except for the 'const' qualifiers. See XMLHandle for API.
17531769
*/
1754-
class XMLConstHandle
1770+
class TINYXML2_LIB XMLConstHandle
17551771
{
17561772
public:
17571773
XMLConstHandle( const XMLNode* node ) {
@@ -1858,7 +1874,7 @@ class XMLConstHandle
18581874
printer.CloseElement();
18591875
@endverbatim
18601876
*/
1861-
class XMLPrinter : public XMLVisitor
1877+
class TINYXML2_LIB XMLPrinter : public XMLVisitor
18621878
{
18631879
public:
18641880
/** Construct the printer. If the FILE* is specified,
@@ -1867,7 +1883,7 @@ class XMLPrinter : public XMLVisitor
18671883
If 'compact' is set to true, then output is created
18681884
with only required whitespace and newlines.
18691885
*/
1870-
XMLPrinter( FILE* file=0, bool compact = false );
1886+
XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
18711887
~XMLPrinter() {}
18721888

18731889
/** If streaming, write the BOM and declaration. */
@@ -1964,5 +1980,8 @@ class XMLPrinter : public XMLVisitor
19641980

19651981
} // tinyxml2
19661982

1983+
#if defined(_MSC_VER)
1984+
# pragma warning(pop)
1985+
#endif
19671986

19681987
#endif // TINYXML2_INCLUDED

itemmanifest.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ bool XMLToItemManifest(const wchar_t* cFilename)
10951095
list<effectDependency> lEffectDeps;
10961096
list<itemDependency> lItemDeps;
10971097
u32 binDataRunningTally = 0; //Offset into the binary data for each item
1098-
list<itemDataHeader> lItemData;
1098+
vector<itemDataHeader> lItemData; //Everything here and below should be vectors so I can access as needed
10991099
for(list<wstring>::iterator i = lItemManifestFilenames.begin(); i != lItemManifestFilenames.end(); i++)
11001100
{
11011101
doc = new XMLDocument;
@@ -1377,6 +1377,22 @@ bool XMLToItemManifest(const wchar_t* cFilename)
13771377
delete doc;
13781378
return false;
13791379
}
1380+
const char* cVec = elem->Attribute("iconAnimBoundsMin");
1381+
if(cVec == NULL)
1382+
{
1383+
cout << "Unable to read iconAnimBoundsMin from XML file " << ws2s(*i) << endl;
1384+
delete doc;
1385+
return false;
1386+
}
1387+
idh.iconAnimBoundsMin = stringToVec2(cVec);
1388+
cVec = elem->Attribute("iconAnimBoundsMax");
1389+
if(cVec == NULL)
1390+
{
1391+
cout << "Unable to read iconAnimBoundsMax from XML file " << ws2s(*i) << endl;
1392+
delete doc;
1393+
return false;
1394+
}
1395+
idh.iconAnimBoundsMax = stringToVec2(cVec);
13801396

13811397
//TODO iconanimboundsmax/min.x/y
13821398

@@ -1440,9 +1456,7 @@ bool XMLToItemManifest(const wchar_t* cFilename)
14401456
BinHdrPtr bonePartTreeVals;
14411457
BinHdrPtr rgnCells;
14421458
BinHdrPtr stringTableBytes;
1443-
BinHdrPtr burnGridUsedDataBytes;
1444-
vec2 iconAnimBoundsMin;
1445-
vec2 iconAnimBoundsMax;*/
1459+
BinHdrPtr burnGridUsedDataBytes;*/
14461460

14471461

14481462
//...

libs/libtinyxml2.a

-259 KB
Binary file not shown.

libs/libttvfs.a

-9.1 KB
Binary file not shown.

pakDataTypes.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#ifndef PAKDATATYPES_H
44
#define PAKDATATYPES_H
55

6+
#define VERSION_12
7+
68
#include <cstdio>
79
#include <tinyxml2.h>
810
#include <stdint.h>
@@ -531,7 +533,9 @@ typedef struct
531533
typedef struct
532534
{
533535
u32 id;
534-
//i32 idStrTblIdx; //WHOA NELLIE This isn't here any more or something
536+
#ifdef VERSION_12
537+
i32 idStrTblIdx; //This isn't here for version 1.1 or less
538+
#endif
535539
BinLocStrKey title;
536540
i32 value;
537541
i32 stampValue;

0 commit comments

Comments
 (0)