Fix crash when `names.txt` does not contain template name.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@10499 4a71c877-e1ca-e34f-864e-861f7616d084
master
Guangcong Luo 2010-04-06 18:57:52 +00:00 committed by Git SVN Gateway
parent aecdd1805a
commit 2b6a34c67c
1 changed files with 13 additions and 5 deletions

View File

@ -83,6 +83,7 @@
#include "research.h"
#include "combat.h"
#include "scriptfuncs.h" //for ThreatInRange()
#include "design.h" //for GetDefaultTemplateName
#define DEFAULT_RECOIL_TIME (GAME_TICKS_PER_SEC/4)
#define DROID_DAMAGE_SPREAD (16 - rand()%32)
@ -1550,11 +1551,6 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
pDroidDesign->pName = templName;
sstrcpy(templName, componentName);
// Store translated name in aName
if (!getDroidResourceName(componentName))
{
return false;
}
sstrcpy(pDroidDesign->aName, componentName);
//read in Body Name
@ -1816,6 +1812,18 @@ BOOL loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
//check that not allocating more weapons than allowed
ASSERT_OR_RETURN(false, pDroidDesign->numWeaps <= DROID_MAXWEAPS, "Too many weapons have been allocated for droid Template: %s", pDroidDesign->aName);
// Store translated name in aName
sstrcpy(componentName, pDroidDesign->aName);
if (getDroidResourceName(componentName))
{
sstrcpy(pDroidDesign->aName, componentName);
}
else
{
sstrcpy(pDroidDesign->aName, GetDefaultTemplateName(pDroidDesign));
}
pDroidDesign->ref = REF_TEMPLATE_START + line;
// Store global default design if found else store in the appropriate array
if ( pDroidDesign->droidType == DROID_DEFAULT )