Specific drug types and drug items for background and facilities. (#226)

This commit is contained in:
Andrzej Fałkowski
2023-10-02 19:30:59 +03:00
committed by GitHub
parent 9033e1097a
commit a3be3ecd7e
9 changed files with 227 additions and 41 deletions
+6
View File
@@ -211,6 +211,11 @@ enum {
BG_MAX,
};
enum class BackgroundVectorTypes {
BG_DRUGUSE_TYPES,
BG_DRUGUSE_ITEMS,
};
typedef struct
{
UINT16 uiIndex;
@@ -220,6 +225,7 @@ typedef struct
UINT64 uiFlags; // this flagmask defines what special properties this background has (on/off behaviour)
INT16 value[BG_MAX]; // property values
std::map<BackgroundVectorTypes, std::vector<INT16>> valueVectors; // optional additional data
} BACKGROUND_VALUES;
#define NUM_BACKGROUND 500
+18
View File
@@ -17605,6 +17605,24 @@ INT16 SOLDIERTYPE::GetBackgroundValue( UINT16 aNr )
return 0;
}
const std::vector<INT16>& SOLDIERTYPE::GetBackgroundValueVector(BackgroundVectorTypes backgroundVectorType) const
{
static const std::vector<INT16> emptyVector;
if (UsingBackGroundSystem() && this->ubProfile != NO_PROFILE)
{
const BACKGROUND_VALUES& background = zBackground[gMercProfiles[this->ubProfile].usBackground];
auto iterator = background.valueVectors.find(backgroundVectorType);
if (iterator != background.valueVectors.end())
{
return iterator->second;
}
}
return emptyVector;
}
INT8 SOLDIERTYPE::GetSuppressionResistanceBonus( )
{
INT8 bonus = 0;
+4
View File
@@ -1070,6 +1070,8 @@ public:
INT8 bPathStored; // good for AI to reduct redundancy
};
enum class BackgroundVectorTypes;
class SOLDIERTYPE//last edited at version 102
{
public:
@@ -1954,6 +1956,8 @@ public:
BOOLEAN HasBackgroundFlag( UINT64 aFlag );
INT16 GetBackgroundValue( UINT16 aNr );
const std::vector<INT16>& SOLDIERTYPE::GetBackgroundValueVector(BackgroundVectorTypes backgroundVectorType) const;
INT8 GetSuppressionResistanceBonus(); // bonus to resistance against suppression
INT16 GetMeleeDamageBonus();
INT16 GetAPBonus();
+4 -1
View File
@@ -44,7 +44,10 @@ enum
ELEMENT_DISABILITY_EFFECT,
ELEMENT_DISABILITY_EFFECT_PROPERTY,
ELEMENT_PERSONALITY_EFFECT,
ELEMENT_PERSONALITY_EFFECT_PROPERTY
ELEMENT_PERSONALITY_EFFECT_PROPERTY,
ELEMENT_VECTOR_OF_NUMBERS,
ELEMENT_VECTOR_OF_NUMBERS_NUMBER,
}
typedef PARSE_STAGE;
+44 -6
View File
@@ -41,8 +41,13 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha
{
pData->curElement = ELEMENT_LIST;
if ( !localizedTextOnly_BG )
memset(pData->curArray,0,sizeof(BACKGROUND_VALUES)*pData->maxArraySize);
if (!localizedTextOnly_BG)
{
for (UINT32 i = 0; i < pData->maxArraySize; i++)
{
pData->curArray[i] = BACKGROUND_VALUES();
}
}
pData->maxReadDepth++; //we are not skipping this element
}
@@ -50,8 +55,8 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha
{
pData->curElement = ELEMENT;
if ( !localizedTextOnly_BG )
memset(&pData->curBackground,0,sizeof(BACKGROUND_VALUES));
if (!localizedTextOnly_BG)
pData->curBackground = BACKGROUND_VALUES();
pData->maxReadDepth++; //we are not skipping this element
}
@@ -153,6 +158,27 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha
pData->maxReadDepth++; //we are not skipping this element
}
else if (strcmp(name, "drugtypes") == 0 && pData->curElement == ELEMENT)
{
pData->curElement = ELEMENT_VECTOR_OF_NUMBERS;
pData->curBackground.valueVectors[BackgroundVectorTypes::BG_DRUGUSE_TYPES].clear();
pData->maxReadDepth++; //we are not skipping this element
}
else if (strcmp(name, "drugitems") == 0 && pData->curElement == ELEMENT)
{
pData->curElement = ELEMENT_VECTOR_OF_NUMBERS;
pData->curBackground.valueVectors[BackgroundVectorTypes::BG_DRUGUSE_TYPES].clear();
pData->maxReadDepth++; //we are not skipping this element
}
else if (pData->curElement == ELEMENT_VECTOR_OF_NUMBERS &&
(strcmp(name, "drugtype") == 0 ||
strcmp(name, "drugitem") == 0))
{
pData->curElement = ELEMENT_VECTOR_OF_NUMBERS_NUMBER;
pData->maxReadDepth++; //we are not skipping this element
}
pData->szCharData[0] = '\0';
}
@@ -667,7 +693,19 @@ backgroundEndElementHandle(void *userData, const XML_Char *name)
pData->curElement = ELEMENT;
pData->curBackground.uiFlags |= (UINT16)atol(pData->szCharData) ? BACKGROUND_CIVGROUPLOYAL : 0;
}
else if (strcmp(name, "drugtype") == 0)
{
pData->curElement = ELEMENT_VECTOR_OF_NUMBERS;
INT16 drugValue = (INT16)atol(pData->szCharData);
pData->curBackground.valueVectors[BackgroundVectorTypes::BG_DRUGUSE_TYPES].push_back(drugValue);
}
else if (strcmp(name, "drugitem") == 0)
{
pData->curElement = ELEMENT_VECTOR_OF_NUMBERS;
INT16 drugValue = (INT16)atol(pData->szCharData);
pData->curBackground.valueVectors[BackgroundVectorTypes::BG_DRUGUSE_ITEMS].push_back(drugValue);
}
pData->maxReadDepth--;
}
pData->currentDepth--;
@@ -711,7 +749,7 @@ BOOLEAN ReadInBackgrounds(STR fileName, BOOLEAN localizedVersion)
XML_SetCharacterDataHandler(parser, backgroundCharacterDataHandle);
memset(&pData,0,sizeof(pData));
pData = enemyRankParseData();
pData.curArray = zBackground;
pData.maxArraySize = NUM_BACKGROUND;