485 changes: 0 additions & 485 deletions data/base/wrf/piestats.wrf

This file was deleted.

9 changes: 0 additions & 9 deletions data/mp/addon.lev
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ data "wrf/vidmem.wrf"
data "wrf/basic.wrf"
data "wrf/cam1.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires.wrf"

Expand All @@ -42,7 +41,6 @@ data "wrf/vidmem2.wrf"
data "wrf/basic.wrf"
data "wrf/cam2.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires.wrf"

Expand All @@ -51,7 +49,6 @@ data "wrf/vidmem3.wrf"
data "wrf/basic.wrf"
data "wrf/cam3.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires.wrf"

Expand Down Expand Up @@ -131,7 +128,6 @@ data "wrf/vidmem.wrf"
data "wrf/basic.wrf"
data "wrf/cam1.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires2.wrf"

Expand All @@ -140,7 +136,6 @@ data "wrf/vidmem2.wrf"
data "wrf/basic.wrf"
data "wrf/cam2.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires2.wrf"

Expand All @@ -149,7 +144,6 @@ data "wrf/vidmem3.wrf"
data "wrf/basic.wrf"
data "wrf/cam3.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires2.wrf"

Expand Down Expand Up @@ -202,7 +196,6 @@ data "wrf/vidmem.wrf"
data "wrf/basic.wrf"
data "wrf/cam1.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires3.wrf"

Expand All @@ -211,7 +204,6 @@ data "wrf/vidmem2.wrf"
data "wrf/basic.wrf"
data "wrf/cam2.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires3.wrf"

Expand All @@ -220,7 +212,6 @@ data "wrf/vidmem3.wrf"
data "wrf/basic.wrf"
data "wrf/cam3.wrf"
data "wrf/audio.wrf"
data "wrf/piestats.wrf"
data "wrf/stats.wrf"
data "wrf/multires3.wrf"

Expand Down
570 changes: 0 additions & 570 deletions data/mp/wrf/piestats.wrf

This file was deleted.

1 change: 0 additions & 1 deletion lib/ivis_opengl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ libivis_opengl_a_SOURCES = \
tex.cpp \
textdraw.cpp \
bitimage.cpp \
imd.cpp \
imdload.cpp \
jpeg_encoder.cpp \
pieclip.cpp \
Expand Down
90 changes: 0 additions & 90 deletions lib/ivis_opengl/imd.cpp

This file was deleted.

15 changes: 2 additions & 13 deletions lib/ivis_opengl/imd.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@
#ifndef _imd_
#define _imd_

#include <QtCore/QString>

#include "ivisdef.h"
#include "lib/framework/frameresource.h"

static inline iIMDShape *modelGet(const QString &filename)
{
return (iIMDShape *) resGetData("IMD", filename.toUtf8().constData());
}

#define PIE_NAME "PIE" // Pumpkin image export data file
#define PIE_VER 2
Expand All @@ -49,15 +41,12 @@ static inline iIMDShape *modelGet(const QString &filename)

// polygon flags b0..b7: col, b24..b31: anim index


#define iV_IMD_TEX 0x00000200 // this is both a polygon and pie flag
#define iV_IMD_TEXANIM 0x00004000 // iV_IMD_TEX must be set also

//*************************************************************************

extern iIMDShape *iV_ProcessIMD(const char **ppFileData, const char *FileDataEnd );

extern bool iV_IMDSave(char *filename, iIMDShape *s, bool PieIMD);
extern void iV_IMDRelease(iIMDShape *s);
void modelShutdown();
iIMDShape *modelGet(const QString &filename);

#endif
126 changes: 121 additions & 5 deletions lib/ivis_opengl/imdload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,134 @@
* Load IMD (.pie) files
*/

#include <QtCore/QMap>
#include <QtCore/QString>

#include "lib/framework/frame.h"
#include "lib/framework/string_ext.h"
#include "lib/framework/frameresource.h"
#include "lib/framework/fixedpoint.h"
#include "lib/framework/file.h"
#include "lib/framework/physfs_ext.h"
#include "lib/ivis_opengl/piematrix.h"
#include "lib/ivis_opengl/piestate.h"

#include "ivisdef.h" // for imd structures
#include "imd.h" // for imd structures
#include "tex.h" // texture page loading

typedef QMap<QString, iIMDShape *> MODELMAP;
static MODELMAP models;

iIMDShape *iV_ProcessIMD(const char **ppFileData, const char *FileDataEnd);

iIMDShape::iIMDShape()
{
flags = 0;
nconnectors = 0; // Default number of connectors must be 0
npoints = 0;
npolys = 0;
points = NULL;
polys = NULL;
connectors = NULL;
next = NULL;
shadowEdgeList = NULL;
nShadowEdges = 0;
texpage = iV_TEX_INVALID;
tcmaskpage = iV_TEX_INVALID;
normalpage = iV_TEX_INVALID;
specularpage = iV_TEX_INVALID;
numFrames = 0;
shaderProgram = 0;
}

static void iV_IMDRelease(iIMDShape *s)
{
unsigned int i;
iIMDShape *d;

if (s)
{
if (s->points)
{
free(s->points);
}
if (s->connectors)
{
free(s->connectors);
}
if (s->polys)
{
for (i = 0; i < s->npolys; i++)
{
if (s->polys[i].texCoord)
{
free(s->polys[i].texCoord);
}
}
free(s->polys);
}
if (s->shadowEdgeList)
{
free(s->shadowEdgeList);
s->shadowEdgeList = NULL;
}
glDeleteBuffers(VBO_COUNT, s->buffers);
// shader deleted later, if any
d = s->next;
delete s;
iV_IMDRelease(d);
}
}

void modelShutdown()
{
for (MODELMAP::iterator i = models.begin(); i != models.end(); i = models.erase(i))
{
iV_IMDRelease(i.value());
}
}

static bool tryLoad(const QString &path, const QString &filename)
{
if (PHYSFS_exists(path + filename))
{
char *pFileData = NULL, *fileEnd;
UDWORD size = 0;
if (!loadFile(QString(path + filename).toUtf8().constData(), &pFileData, &size))
{
debug(LOG_ERROR, "Failed to load model file: %s", QString(path + filename).toUtf8().constData());
return false;
}
fileEnd = pFileData + size;
iIMDShape *s = iV_ProcessIMD((const char **)&pFileData, fileEnd);
if (s)
{
models.insert(filename, s);
}
return true;
}
return false;
}

iIMDShape *modelGet(const QString &filename)
{
QString name(filename.toLower());
if (models.contains(name))
{
return models[name]; // cached
}
else if (tryLoad("structs/", name) || tryLoad("misc/", name) || tryLoad("effects/", name)
|| tryLoad("components/prop/", name) || tryLoad("components/weapons/", name)
|| tryLoad("components/bodies/", name) || tryLoad("features/", name)
|| tryLoad("misc/micnum/", name) || tryLoad("misc/minum/", name) || tryLoad("misc/mivnum/", name) || tryLoad("misc/researchimds/", name))
{
return models[name];
}
debug(LOG_ERROR, "Could not find: %s", name.toUtf8().constData());
return NULL;
}

static bool AtEndOfFile(const char *CurPos, const char *EndOfFile)
{
while ( *CurPos == 0x00 || *CurPos == 0x09 || *CurPos == 0x0a || *CurPos == 0x0d || *CurPos == 0x20 )
Expand Down Expand Up @@ -65,7 +182,7 @@ static bool AtEndOfFile(const char *CurPos, const char *EndOfFile)
* \post s->polys allocated (iFSDPoly * s->npolys)
* \post s->pindex allocated for each poly
*/
static bool _imd_load_polys( const char **ppFileData, iIMDShape *s, int pieVersion)
static bool _imd_load_polys(const char **ppFileData, iIMDShape *s, int pieVersion)
{
const char *pFileData = *ppFileData;
unsigned int i, j;
Expand Down Expand Up @@ -221,7 +338,7 @@ static bool _imd_load_polys( const char **ppFileData, iIMDShape *s, int pieVersi
}


static bool ReadPoints( const char **ppFileData, iIMDShape *s )
static bool ReadPoints(const char **ppFileData, iIMDShape *s)
{
const char *pFileData = *ppFileData;
unsigned int i;
Expand Down Expand Up @@ -421,7 +538,7 @@ void _imd_calc_bounds(iIMDShape *s, Vector3f *p, int size)
// END: tight bounding sphere
}

static bool _imd_load_points( const char **ppFileData, iIMDShape *s )
static bool _imd_load_points(const char **ppFileData, iIMDShape *s)
{
//load the points then pass through a second time to setup bounding datavalues
s->points = (Vector3f*)malloc(sizeof(Vector3f) * s->npoints);
Expand Down Expand Up @@ -652,15 +769,14 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE
return s;
}


/*!
* Load ppFileData into a shape
* \param ppFileData Data from the IMD file
* \param FileDataEnd Endpointer
* \return The shape, constructed from the data read
*/
// ppFileData is incremented to the end of the file on exit!
iIMDShape *iV_ProcessIMD( const char **ppFileData, const char *FileDataEnd )
iIMDShape *iV_ProcessIMD(const char **ppFileData, const char *FileDataEnd)
{
const char *pFileName = GetLastResourceFilename(); // Last loaded filename
const char *pFileData = *ppFileData;
Expand Down
4 changes: 0 additions & 4 deletions lib/ivis_opengl/ivi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
#include "lib/ivis_opengl/tex.h"
#include "lib/ivis_opengl/textdraw.h"

void iV_Reset()
{
}

void iV_ShutDown(void)
{
pie_ShutDown();
Expand Down
1 change: 0 additions & 1 deletion lib/ivis_opengl/ivi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include "piedef.h"

extern void iV_Reset(void);
extern void iV_ShutDown(void);

#endif
3 changes: 1 addition & 2 deletions lib/ivis_opengl/ivis_opengl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="bitimage.cpp" />
<ClCompile Include="imd.cpp" />
<ClCompile Include="imdload.cpp" />
<ClCompile Include="ivi.cpp" />
<ClCompile Include="jpeg_encoder.cpp" />
Expand Down Expand Up @@ -230,4 +229,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
5 changes: 1 addition & 4 deletions lib/ivis_opengl/ivis_opengl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<ClCompile Include="bitimage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="imd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="imdload.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -122,4 +119,4 @@
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
1 change: 0 additions & 1 deletion po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ lib/gamelib/animobj.cpp
lib/gamelib/gtime.cpp
lib/gamelib/hashtable.cpp
lib/ivis_opengl/bitimage.cpp
lib/ivis_opengl/imd.cpp
lib/ivis_opengl/imdload.cpp
lib/ivis_opengl/ivi.cpp
lib/ivis_opengl/jpeg_encoder.cpp
Expand Down
19 changes: 1 addition & 18 deletions src/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,23 +455,6 @@ static void dataSMSGRelease(void *pData)
viewDataShutDown((const char *)pData);
}

/* Load an imd */
static bool dataIMDBufferLoad(const char *pBuffer, UDWORD size, void **ppData)
{
iIMDShape *psIMD;
const char *pBufferPosition = pBuffer;

psIMD = iV_ProcessIMD( &pBufferPosition, pBufferPosition + size );
if (psIMD == NULL) {
debug( LOG_ERROR, "IMD load failed - %s", GetLastResourceFilename() );
return false;
}

*ppData = psIMD;
return true;
}


/*!
* Load an image from file
*/
Expand Down Expand Up @@ -785,7 +768,7 @@ struct RES_TYPE_MIN_BUF
static const RES_TYPE_MIN_BUF BufferResourceTypes[] =
{
{"SMSG", bufferSMSGLoad, dataSMSGRelease},
{"IMD", dataIMDBufferLoad, (RES_FREE)iV_IMDRelease},
{"IMD", NULL, NULL}, // ignored
};

struct RES_TYPE_MIN_FILE
Expand Down
7 changes: 2 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ bool systemInitialise(void)
screen_EnableMissingFunctions();

pie_InitRadar();
iV_Reset(); // Reset the IV library.

readAIs();

Expand Down Expand Up @@ -706,8 +705,6 @@ bool frontendInitialise(const char *ResourceFile)
return false;
}

iV_Reset(); // Reset the IV library.

if (!scrTabInitialise()) // Initialise the script system
{
return false;
Expand Down Expand Up @@ -815,6 +812,7 @@ bool frontendShutdown(void)
}

debug(LOG_TEXTURE, "=== frontendShutdown ===");
modelShutdown();
pie_TexShutDown();
pie_TexInit(); // ready for restart
freeComponentLists();
Expand All @@ -839,8 +837,6 @@ bool stageOneInitialise(void)
return false;
}

iV_Reset(); // Reset the IV library

if (!stringsInitialise()) /* Initialise the string system */
{
return false;
Expand Down Expand Up @@ -983,6 +979,7 @@ bool stageOneShutDown(void)
}

debug(LOG_TEXTURE, "=== stageOneShutDown ===");
modelShutdown();
pie_TexShutDown();

// Use mod_multiplay as the default (campaign might have set it to mod_singleplayer)
Expand Down
7 changes: 1 addition & 6 deletions src/multiint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3225,12 +3225,7 @@ void startMultiplayerGame(void)
{
debug(LOG_NET, "limiter was NOT activated, setting defaults");

// NOTE: master <-> 2.3 difference, we don't load limiter_tex!
if (!resLoad("wrf/piestats.wrf", 502))
{
debug(LOG_INFO, "Unable to load piestats. Defaults not set.");
}
else if (!resLoad("wrf/limiter_data.wrf", 503))
if (!resLoad("wrf/limiter_data.wrf", 503))
{
debug(LOG_INFO, "Unable to load limiter_data.");
}
Expand Down
5 changes: 0 additions & 5 deletions src/multilimit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ bool startLimitScreen(void)
{
initLoadingScreen(true);

if (!resLoad("wrf/piestats.wrf", 502))
{
return false;
}

if (!resLoad("wrf/limiter_data.wrf", 503))
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static iIMDShape *statsGetIMD(WzConfig &ini, BASE_STATS *psStats, QString key, i
if (ini.contains(key))
{
QStringList values = ini.value(key).toStringList();
if (values[index].compare("0") != 0)
if (values.size() > index && values[index].compare("0") != 0)
{
retval = modelGet(values[index]);
ASSERT(retval != NULL, "Cannot find the PIE model %s for stat %s in %s",
Expand Down