Skip to content

Commit

Permalink
first attempt ecm.txt -> ecm.ini still incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
epilef committed Nov 9, 2012
1 parent 3b3a282 commit 2254faf
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 19 deletions.
24 changes: 24 additions & 0 deletions data/base/stats/ecm.ini
@@ -0,0 +1,24 @@
[ZNULLECM]
buildPower = 0
buildPoints = 0
weight = 0
body = 0

This comment has been minimized.

Copy link
@Cjkjvfnby

Cjkjvfnby Dec 19, 2012

Contributor

Wrong param name, should be bodyPoints
in src/stats.cpp
psStats->body = ini.value("bodyPoints", 0).toInt();

GfxFile = 0
mountGfx = 0
location = DEFAULT
power = 0
range = 0
designable = 0

[RepairCentre]
buildPower = 0
buildPoints = 0
weight = 0
body = 0
GfxFile = GNHREPAR.PIE
mountGfx = 0
location = TURRET
power = 0
range = 0
designable = 0

2 changes: 0 additions & 2 deletions data/base/stats/ecm.txt

This file was deleted.

2 changes: 1 addition & 1 deletion data/base/wrf/stats.wrf
Expand Up @@ -11,7 +11,7 @@ file SBODY "body.ini"
file SBRAIN "brain.ini"
file SPROP "propulsion.ini"
file SSENSOR "sensor.txt"
file SECM "ecm.txt"
file SECM "ecm.ini"
file SREPAIR "repair.txt"
file SCONSTR "construction.txt"
file SPROPTYPES "propulsiontype.txt"
Expand Down
24 changes: 24 additions & 0 deletions data/mp/stats/ecm.ini
@@ -0,0 +1,24 @@
[ZNULLECM]
buildPower = 0
buildPoints = 0
weight = 0
body = 0
GfxFile = 0
mountGfx = 0
location = DEFAULT
power = 0
range = 0
designable = 0

[RepairCentre]
buildPower = 0
buildPoints = 0
weight = 0
body = 0
GfxFile = GNHREPAR.PIE
mountGfx = 0
location = TURRET
power = 0
range = 0
designable = 0

3 changes: 0 additions & 3 deletions data/mp/stats/ecm.txt

This file was deleted.

2 changes: 1 addition & 1 deletion data/mp/wrf/stats.wrf
Expand Up @@ -11,7 +11,7 @@ file SBODY "body.ini"
file SBRAIN "brain.ini"
file SPROP "propulsion.ini"
file SSENSOR "sensor.txt"
file SECM "ecm.txt"
file SECM "ecm.ini"
file SREPAIR "repair.txt"
file SCONSTR "construction.txt"
file SPROPTYPES "propulsiontype.txt"
Expand Down
4 changes: 2 additions & 2 deletions src/data.cpp
Expand Up @@ -193,11 +193,11 @@ static bool bufferSCONSTRLoad(const char *pBuffer, UDWORD size, void **ppData)
}

/* Load the ECM stats */
static bool bufferSECMLoad(const char *pBuffer, UDWORD size, void **ppData)
static bool bufferSECMLoad(const char *fileName, void **ppData)
{
calcDataHash((uint8_t *)pBuffer, size, DATA_SECM);

if (!loadECMStats(pBuffer, size)
if (!loadECMStats(fileName)
|| !allocComponentList(COMP_ECM, numECMStats))
{
return false;
Expand Down
31 changes: 22 additions & 9 deletions src/stats.cpp
Expand Up @@ -1456,26 +1456,38 @@ bool loadSensorStats(const char *pSensorData, UDWORD bufferSize)
}

/*Load the ECM stats from the file exported from Access*/
bool loadECMStats(const char *pECMData, UDWORD bufferSize)
bool loadECMStats(const char *fileName)
{
const unsigned int NumECM = numCR(pECMData, bufferSize);
// const unsigned int NumECM = numCR(pECMData, bufferSize);
ECM_STATS sStats, * const psStats = &sStats;
unsigned int i = 0, designable;
// unsigned int i = 0, designable;
char ECMName[MAX_STR_LENGTH], location[MAX_STR_LENGTH],
GfxFile[MAX_STR_LENGTH];
char mountGfx[MAX_STR_LENGTH], dummy[MAX_STR_LENGTH];
UDWORD dummyVal;
//UDWORD dummyVal;

if (!statsAllocECM(NumECM))
WzConfig ini(pFileName);
if (ini.status() != QSettings::NoError)
{
debug(LOG_ERROR, "Could not open %s", pFileName);
}
if (!statsAllocECM(list.size()))
{
return false;
}

for (i=0; i < NumECM; i++)
// Hack to make sure ZNULLECM is always first in list
int nullecm = list.indexOf("ZNULLECM");
ASSERT_OR_RETURN(false, nullbrain >= 0, "ZNULLECM is mandatory");
if (nullecm > 0)
{
list.swap(nullecm, 0);
}
for (int i=0; i < list.size(); i++)
{
ini.beginGroup(list[i]);
memset(psStats, 0, sizeof(ECM_STATS));

ECMName[0] = '\0';
/* ECMName[0] = '\0';
GfxFile[0] = '\0';
mountGfx[0] = '\0';
location[0] = '\0';
Expand All @@ -1486,7 +1498,8 @@ bool loadECMStats(const char *pECMData, UDWORD bufferSize)
&psStats->weight, &dummyVal, &dummyVal,
&psStats->body, GfxFile, mountGfx, location, &psStats->power,
&psStats->range, &designable);

*/
psStats->pName = strdup(list[i].toUtf8().constData());
if (!allocateStatName((BASE_STATS *)psStats, ECMName))
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/stats.h
Expand Up @@ -167,7 +167,7 @@ extern bool loadPropulsionStats(const char *pFileName);
extern bool loadSensorStats(const char *pSensorData, UDWORD bufferSize);

/*Load the ecm stats from the file exported from Access*/
extern bool loadECMStats(const char *pECMData, UDWORD bufferSize);
extern bool loadECMStats(const char *fileName);

/*Load the repair stats from the file exported from Access*/
extern bool loadRepairStats(const char *pRepairData, UDWORD bufferSize);
Expand Down

0 comments on commit 2254faf

Please sign in to comment.