2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 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 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
#include <assert.h>
|
2006-11-06 06:40:07 -08:00
|
|
|
#include <string.h>
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/framework/frame.h"
|
2006-09-23 11:38:12 -07:00
|
|
|
#include "lib/framework/frameresource.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "effects.h"
|
|
|
|
#include "structure.h"
|
|
|
|
#include "messagedef.h"
|
|
|
|
#include "miscimd.h"
|
|
|
|
|
|
|
|
/* Our great big array of imds */
|
2006-09-13 14:14:47 -07:00
|
|
|
static MISC_IMD miscImds[] =
|
2007-06-28 10:47:08 -07:00
|
|
|
{ // Previous imd pointer names
|
2006-05-27 09:37:17 -07:00
|
|
|
{NULL,"fxsexp"}, // explosionSmallImd MI_EXPLOSION_SMALL
|
|
|
|
{NULL,"fxlexp"}, // explosionMediumImd MI_EXPLOSION_MEDIUM
|
|
|
|
{NULL,"fxdust"}, // constructionImd MI_CONSTRUCTION
|
|
|
|
{NULL,"fxsmoke"}, // smallSmokeImd MI_SMALL_SMOKE
|
|
|
|
{NULL,"parthead"}, // babaHeadImd MI_BABA_HEAD
|
|
|
|
{NULL,"partlegs"}, // babaLegsImd MI_BABA_LEGS
|
|
|
|
{NULL,"partarm"}, // babaArmImd MI_BABA_ARM
|
|
|
|
{NULL,"partbody"}, // babaBodyImd MI_BABA_BODY
|
|
|
|
{NULL,"cybitrkt"}, // cyborgHeadImd MI_CYBORG_HEAD
|
|
|
|
{NULL,"cybitlg1"}, // cyborgLegsImd MI_CYBORG_LEGS
|
|
|
|
{NULL,"cybitgun"}, // cyborgArmImd MI_CYBORG_ARM
|
|
|
|
{NULL,"cybitbod"}, // cyborgBodyImd MI_CYBORG_BODY
|
|
|
|
{NULL,"fxatexp"}, // waterImd MI_WATER
|
|
|
|
{NULL,"fxssteam"}, // droidDamageImd MI_DROID_DAMAGE
|
|
|
|
{NULL,"fxssteam"}, // smallSteamImd MI_SMALL_STEAM
|
|
|
|
{NULL,"fxplasma"}, // plasmaImd MI_PLASMA
|
|
|
|
{NULL,"fxblip"}, // blipImd MI_BLIP
|
|
|
|
{NULL,"cyshadow"}, // shadowImd MI_SHADOW
|
|
|
|
{NULL,"Mitrnshd"}, // transporterShadowImd MI_TRANSPORTER_SHADOW
|
|
|
|
{NULL,"fxblood"}, // bloodImd MI_BLOOD
|
|
|
|
{NULL,"fxssmoke"}, // trailImd MI_TRAIL
|
|
|
|
{NULL,"fxft"}, // flameImd MI_FLAME
|
|
|
|
{NULL,"fxpower"}, // teslaImd MI_TESLA
|
|
|
|
{NULL,"fxmflare"}, // mFlareImd MI_MFLARE
|
|
|
|
{NULL,"mirain"}, // rainImd MI_RAIN
|
|
|
|
{NULL,"misnow"}, // snowImd MI_SNOW
|
|
|
|
{NULL,"fxssplsh"}, // splashImd MI_SPLASH
|
|
|
|
|
|
|
|
{NULL,"fxexpdrt"}, // kickImd MI_KICK
|
|
|
|
{NULL,"fxlightr"}, // landingImd MI_LANDING
|
|
|
|
{NULL,"fxl3dshk"}, // shockImd MI_SHOCK
|
|
|
|
|
|
|
|
{NULL,"blipenm"}, // proximityImds[0] MI_BLIP_ENEMY
|
|
|
|
{NULL,"blipres"}, // proximityImds[1] MI_BLIP_RESOURCE
|
|
|
|
{NULL,"blipart"}, // proximityImds[2] MI_BLIP_ARTEFACT
|
|
|
|
|
|
|
|
{NULL,"miwrek1"}, // wreckageImds[0] MI_WRECK0
|
|
|
|
{NULL,"miwrek2"}, // wreckageImds[1] MI_WRECK1
|
|
|
|
{NULL,"miwrek3"}, // wreckageImds[2] MI_WRECK2
|
|
|
|
{NULL,"miwrek4"}, // wreckageImds[3] MI_WRECK3
|
|
|
|
{NULL,"miwrek5"}, // wreckageImds[4] MI_WRECK4
|
|
|
|
|
|
|
|
{NULL,"midebr1"}, // debrisImds[0] MI_DEBRIS0
|
|
|
|
{NULL,"midebr2"}, // debrisImds[1] MI_DEBRIS1
|
|
|
|
{NULL,"midebr3"}, // debrisImds[2] MI_DEBRIS2
|
|
|
|
{NULL,"midebr4"}, // debrisImds[3] MI_DEBRIS3
|
|
|
|
{NULL,"midebr5"}, // debrisImds[4] MI_DEBRIS4
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
{NULL,"fxflecht"}, // met hit - for repair centre MI_FIREWORK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{NULL,"END_OF_IMD_LIST"}
|
|
|
|
};
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
// Load up all the imds into an array
|
2006-09-19 18:12:13 -07:00
|
|
|
static BOOL multiLoadMiscImds( void )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
UDWORD i=0;
|
2006-05-27 09:37:17 -07:00
|
|
|
BOOL bMoreToProcess=TRUE;
|
2007-06-28 10:47:08 -07:00
|
|
|
char name[15]; // hopefully!
|
|
|
|
|
|
|
|
/* Go thru' the list */
|
|
|
|
while(bMoreToProcess)
|
|
|
|
{
|
2007-11-11 09:08:41 -08:00
|
|
|
snprintf(name, sizeof(name), "%s.pie", miscImds[i].pName);
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/* see if the resource loader can find it */
|
2007-04-23 15:08:53 -07:00
|
|
|
miscImds[i].pImd = (iIMDShape*)resGetData("IMD",name);
|
2007-06-28 10:47:08 -07:00
|
|
|
/* If it didn't get it then... */
|
|
|
|
if(!miscImds[i].pImd)
|
|
|
|
{
|
|
|
|
/* Say which one and return FALSE */
|
2006-08-22 07:28:49 -07:00
|
|
|
debug( LOG_ERROR, "Can't find misselaneous PIE file : %s", miscImds[i].pName );
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( FALSE,"NULL PIE" );
|
2007-06-28 10:47:08 -07:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
/* If the next one's the end one, then get out now.
|
2006-05-27 09:37:17 -07:00
|
|
|
This is cos strcmp will return 0 only at end of list
|
2007-06-28 10:47:08 -07:00
|
|
|
*/
|
|
|
|
bMoreToProcess = strcmp(miscImds[++i].pName,"END_OF_IMD_LIST");
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
// Returns a pointer to the imd from a #define number passed in - see above
|
|
|
|
iIMDShape *getImdFromIndex(UDWORD index)
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( index<MI_TOO_MANY,"Out of range index in getImdFromIndex" );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
return(miscImds[index].pImd);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
iIMDShape *getRandomWreckageImd( void )
|
|
|
|
{
|
|
|
|
iIMDShape *WreckageIMD;
|
2006-05-27 09:37:17 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
// Get a random wreckage
|
|
|
|
WreckageIMD=(getImdFromIndex(MI_WRECK0 + rand()%((MI_WRECK4-MI_WRECK0)+1)));
|
2006-05-27 09:37:17 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
// if it doesn't exsist (cam2) then get the first one
|
|
|
|
if (WreckageIMD==NULL)
|
|
|
|
{
|
|
|
|
WreckageIMD=(getImdFromIndex(MI_WRECK0));
|
|
|
|
}
|
|
|
|
// check to make sure one exists (will fail on renderfeature if null)
|
|
|
|
assert(WreckageIMD);
|
|
|
|
|
|
|
|
return(WreckageIMD);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
iIMDShape *getRandomDebrisImd( void )
|
|
|
|
{
|
|
|
|
iIMDShape *DebrisIMD;
|
|
|
|
|
|
|
|
DebrisIMD = getImdFromIndex(MI_DEBRIS0 + rand()%((MI_DEBRIS4-MI_DEBRIS0)+1));
|
|
|
|
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( DebrisIMD != NULL,"getRandomDebrisImd : NULL PIE" );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
return DebrisIMD;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//iIMDShape *pAssemblyPointIMDs[NUM_FACTORY_TYPES][MAX_FACTORY];
|
|
|
|
iIMDShape *pAssemblyPointIMDs[NUM_FLAG_TYPES][MAX_FACTORY];
|
|
|
|
|
|
|
|
BOOL initMiscImds( void )
|
|
|
|
{
|
2006-11-03 13:35:50 -08:00
|
|
|
char facName[] = "MINUM0.pie";
|
|
|
|
char cybName[] = "MICNUM0.pie";
|
|
|
|
char vtolName[] = "MIVNUM0.pie";
|
|
|
|
char pieNum[2];
|
2007-06-28 10:47:08 -07:00
|
|
|
UDWORD i;
|
|
|
|
|
|
|
|
/* Do the new loading system */
|
|
|
|
multiLoadMiscImds();
|
|
|
|
|
|
|
|
/* Now load the multi array stuff */
|
|
|
|
for (i=0; i < MAX_FACTORY; i++)
|
|
|
|
{
|
2007-11-11 09:08:41 -08:00
|
|
|
snprintf(pieNum, sizeof(pieNum), "%u", i + 1);
|
|
|
|
|
2006-05-27 09:37:17 -07:00
|
|
|
facName[5] = *pieNum;
|
2007-04-23 15:08:53 -07:00
|
|
|
pAssemblyPointIMDs[FACTORY_FLAG][i] = (iIMDShape*)resGetData("IMD", facName);
|
2007-06-28 10:47:08 -07:00
|
|
|
if (!pAssemblyPointIMDs[FACTORY_FLAG][i])
|
|
|
|
{
|
2006-08-22 07:28:49 -07:00
|
|
|
debug( LOG_ERROR, "Can't find assembly point graphic for factory" );
|
|
|
|
abort();
|
2007-06-28 10:47:08 -07:00
|
|
|
return(FALSE);
|
|
|
|
}
|
2006-05-27 09:37:17 -07:00
|
|
|
cybName[6] = *pieNum;
|
2007-04-23 15:08:53 -07:00
|
|
|
pAssemblyPointIMDs[CYBORG_FLAG][i] = (iIMDShape*)resGetData("IMD", cybName);
|
2007-06-28 10:47:08 -07:00
|
|
|
if (!pAssemblyPointIMDs[CYBORG_FLAG][i])
|
|
|
|
{
|
2006-08-22 07:28:49 -07:00
|
|
|
debug( LOG_ERROR, "Can't find assembly point graphic for cyborg factory" );
|
|
|
|
abort();
|
2007-06-28 10:47:08 -07:00
|
|
|
return(FALSE);
|
|
|
|
}
|
2006-05-27 09:37:17 -07:00
|
|
|
vtolName[6] = *pieNum;
|
2007-04-23 15:08:53 -07:00
|
|
|
pAssemblyPointIMDs[VTOL_FLAG][i] = (iIMDShape*)resGetData("IMD", vtolName);
|
2007-06-28 10:47:08 -07:00
|
|
|
if (!pAssemblyPointIMDs[VTOL_FLAG][i])
|
|
|
|
{
|
2006-08-22 07:28:49 -07:00
|
|
|
debug( LOG_ERROR, "Can't find assembly point graphic for vtol factory" );
|
|
|
|
abort();
|
2007-06-28 10:47:08 -07:00
|
|
|
return(FALSE);
|
|
|
|
}
|
2007-04-23 15:08:53 -07:00
|
|
|
pAssemblyPointIMDs[REPAIR_FLAG][i] = (iIMDShape*)resGetData("IMD", "mirnum1.pie");
|
2007-06-28 10:47:08 -07:00
|
|
|
if (!pAssemblyPointIMDs[REPAIR_FLAG][i])
|
|
|
|
{
|
2006-08-22 07:28:49 -07:00
|
|
|
debug( LOG_ERROR, "Can't find assembly point graphic for repair facility" );
|
|
|
|
abort();
|
2007-06-28 10:47:08 -07:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(TRUE);
|
|
|
|
}
|