Skip to content

Commit

Permalink
Gather the methods of Resfile in a single file.
Browse files Browse the repository at this point in the history
The writing methods were separated so that they could avoid be linked into the main binary, but this didn't work anyway (because of the virtual methods).
  • Loading branch information
pphaneuf committed Feb 20, 2014
1 parent 51ab312 commit 9bf2bbd
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 93 deletions.
3 changes: 0 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ quadra_SOURCES = \
skelton/common/res_compress.cpp \
skelton/common/resfile.cpp \
skelton/common/resmanager.cpp \
skelton/common/reswriter.cpp \
skelton/common/sprite.cpp \
skelton/common/stringtable.cpp \
skelton/common/unicode.cpp \
Expand Down Expand Up @@ -192,7 +191,6 @@ wadder_LDADD = $(SDL2_LIBS) $(BOOST_FILESYSTEM_LIB) $(BOOST_SYSTEM_LIB)
wadder_SOURCES = \
skelton/common/resfile.cpp \
skelton/common/resmanager.cpp \
skelton/common/reswriter.cpp \
skelton/common/stringtable.cpp \
skelton/include/error.h \
skelton/include/res.h \
Expand All @@ -207,7 +205,6 @@ wadder_SOURCES = \
dumpwad_LDADD = $(SDL2_LIBS)
dumpwad_SOURCES = \
skelton/common/resfile.cpp \
skelton/common/reswriter.cpp \
skelton/include/error.h \
skelton/include/res.h \
skelton/include/resfile.h \
Expand Down
22 changes: 0 additions & 22 deletions VisualC++/Skelton.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -833,28 +833,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\skelton\common\reswriter.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\skelton\directx\sound.cpp"
>
Expand Down
3 changes: 0 additions & 3 deletions VisualC++/quadra2003.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@
<File
RelativePath="..\skelton\common\resmanager.cpp">
</File>
<File
RelativePath="..\skelton\common\reswriter.cpp">
</File>
<File
RelativePath="..\source\score.cpp">
</File>
Expand Down
1 change: 0 additions & 1 deletion VisualC++/quadra2012.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
<ClCompile Include="..\skelton\common\res_compress.cpp" />
<ClCompile Include="..\skelton\common\resfile.cpp" />
<ClCompile Include="..\skelton\common\resmanager.cpp" />
<ClCompile Include="..\skelton\common\reswriter.cpp" />
<ClCompile Include="..\source\score.cpp" />
<ClCompile Include="..\source\sons.cpp" />
<ClCompile Include="..\skelton\directx\sound.cpp" />
Expand Down
3 changes: 0 additions & 3 deletions VisualC++/wadder2003.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@
<File
RelativePath="..\skelton\common\resmanager.cpp">
</File>
<File
RelativePath="..\skelton\common\reswriter.cpp">
</File>
<File
RelativePath="..\skelton\directx\sound.cpp">
</File>
Expand Down
1 change: 0 additions & 1 deletion VisualC++/wadder2012.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
<ClCompile Include="..\skelton\common\res_compress.cpp" />
<ClCompile Include="..\skelton\common\resfile.cpp" />
<ClCompile Include="..\skelton\common\resmanager.cpp" />
<ClCompile Include="..\skelton\common\reswriter.cpp" />
<ClCompile Include="..\skelton\directx\sound.cpp" />
<ClCompile Include="..\skelton\common\sprite.cpp" />
<ClCompile Include="..\skelton\common\stringtable.cpp" />
Expand Down
36 changes: 36 additions & 0 deletions skelton/common/resfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,30 @@ Resfile::~Resfile() {
delete res;
}

void Resfile::freeze() {
int resnamelen;
Resdata *ptr;
uint32_t d;

res->write(&signature, sizeof(signature));

ptr = list;

while(ptr != NULL) {
resnamelen = strlen(ptr->name)+1;
d = INTELDWORD(resnamelen);
res->write(&d, sizeof(d));
res->write(ptr->name, resnamelen);
d = INTELDWORD(ptr->size);
res->write(&d, sizeof(d));
res->write(ptr->data, ptr->size);
ptr = ptr->next;
}

resnamelen = 0;
res->write(&resnamelen, sizeof(resnamelen));
}

void Resfile::thaw() {
char sig[sizeof(signature)];
int resnamelen;
Expand Down Expand Up @@ -101,6 +125,18 @@ void Resfile::clear() {
list = NULL;
}

void Resfile::add(const char *resname, const int size, const char *resdata) {
char *myname;
uint8_t *mydata;

myname = new char[strlen(resname)+1];
memcpy(myname, resname, strlen(resname)+1);
mydata = new uint8_t[size];
memcpy(mydata, resdata, size);

list = new Resdata(myname, size, mydata, list);
}

int Resfile::get(const char *resname, uint8_t **resdata) {
Resdata *ptr;

Expand Down
60 changes: 0 additions & 60 deletions skelton/common/reswriter.cpp

This file was deleted.

0 comments on commit 9bf2bbd

Please sign in to comment.