Fix Trace Node bug when new junction added

This commit is contained in:
Lew Rossman
2025-02-17 08:44:28 -05:00
parent 03cbb89e05
commit a5bce31b13

View File

@@ -1790,6 +1790,7 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualType, const char *chemName,
qual->Ctol *= Ucf[QUALITY];
if (qual->Qualflag == CHEM) // Chemical analysis
{
qual->TraceNode = 0;
strncpy(qual->ChemName, chemName, MAXID);
strncpy(qual->ChemUnits, chemUnits, MAXID);
strncpy(rpt->Field[QUALITY].Units, qual->ChemUnits, MAXID);
@@ -1807,10 +1808,16 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualType, const char *chemName,
}
if (qual->Qualflag == AGE) // Water age analysis
{
qual->TraceNode = 0;
strncpy(qual->ChemName, w_AGE, MAXID);
strncpy(qual->ChemUnits, u_HOURS, MAXID);
strcpy(rpt->Field[QUALITY].Units, u_HOURS);
}
if (qual->Qualflag == NONE)
{
qual->TraceNode = 0;
strcpy(qual->ChemName, "");
}
// When changing from CHEM to AGE or TRACE, nodes initial quality
// values must be returned to their original ones
@@ -1916,6 +1923,8 @@ int DLLEXPORT EN_addnode(EN_Project p, const char *id, int nodeType, int *index)
}
// adjust indices of tanks/reservoirs in Rule premises (see RULES.C)
adjusttankrules(p, 1);
// adjust index of trace node
if (qual->TraceNode > net->Njuncs - 1) qual->TraceNode += 1;
}
// Actions taken when a new Tank/Reservoir is added