@@ -216,6 +216,108 @@ void CMUSHclientDoc::HandleLoadException (const char * sComment, CException* e)
216
216
217
217
#endif
218
218
219
+ // comparison for avoiding loading duplicates
220
+ bool CAlias::operator == (const CAlias & rhs) const
221
+ {
222
+ if (
223
+ bEchoAlias == rhs.bEchoAlias &&
224
+ bEnabled == rhs.bEnabled &&
225
+ bExpandVariables == rhs.bExpandVariables &&
226
+ bIgnoreCase == rhs.bIgnoreCase &&
227
+ bKeepEvaluating == rhs.bKeepEvaluating &&
228
+ bMenu == rhs.bMenu &&
229
+ bOmitFromCommandHistory == rhs.bOmitFromCommandHistory &&
230
+ bOmitFromLog == rhs.bOmitFromLog &&
231
+ bOmitFromOutput == rhs.bOmitFromOutput &&
232
+ bOneShot == rhs.bOneShot &&
233
+ bRegexp == rhs.bRegexp &&
234
+ contents == rhs.contents &&
235
+ iSendTo == rhs.iSendTo &&
236
+ iSequence == rhs.iSequence &&
237
+ name == rhs.name &&
238
+ strGroup == rhs.strGroup &&
239
+ strLabel == rhs.strLabel &&
240
+ strProcedure == rhs.strProcedure &&
241
+ strVariable == rhs.strVariable
242
+ ) return true ;
243
+
244
+ return false ;
245
+ } // end of CAlias::operator==
246
+
247
+ // comparison for avoiding loading duplicates
248
+ bool CTrigger::operator == (const CTrigger & rhs) const
249
+ {
250
+ if (
251
+ bEnabled == rhs.bEnabled &&
252
+ bExpandVariables == rhs.bExpandVariables &&
253
+ bKeepEvaluating == rhs.bKeepEvaluating &&
254
+ bLowercaseWildcard == rhs.bLowercaseWildcard &&
255
+ bMultiLine == rhs.bMultiLine &&
256
+ bOmitFromOutput == rhs.bOmitFromOutput &&
257
+ bOneShot == rhs.bOneShot &&
258
+ bRegexp == rhs.bRegexp &&
259
+ bRepeat == rhs.bRepeat &&
260
+ bSoundIfInactive == rhs.bSoundIfInactive &&
261
+ colour == rhs.colour &&
262
+ contents == rhs.contents &&
263
+ iClipboardArg == rhs.iClipboardArg &&
264
+ iColourChangeType == rhs.iColourChangeType &&
265
+ iLinesToMatch == rhs.iLinesToMatch &&
266
+ iMatch == rhs.iMatch &&
267
+ iOtherBackground == rhs.iOtherBackground &&
268
+ iOtherForeground == rhs.iOtherForeground &&
269
+ iSendTo == rhs.iSendTo &&
270
+ iSequence == rhs.iSequence &&
271
+ iStyle == rhs.iStyle &&
272
+ iUserOption == rhs.iUserOption &&
273
+ ignore_case == rhs.ignore_case &&
274
+ omit_from_log == rhs.omit_from_log &&
275
+ sound_to_play == rhs.sound_to_play &&
276
+ strGroup == rhs.strGroup &&
277
+ strLabel == rhs.strLabel &&
278
+ strProcedure == rhs.strProcedure &&
279
+ strVariable == rhs.strVariable &&
280
+ trigger == rhs.trigger
281
+
282
+ ) return true ;
283
+
284
+ return false ;
285
+ } // end of CTrigger::operator==
286
+
287
+
288
+ // comparison for avoiding loading duplicates
289
+ bool CTimer::operator == (const CTimer & rhs) const
290
+ {
291
+ if (
292
+ bActiveWhenClosed == rhs.bActiveWhenClosed &&
293
+ bEnabled == rhs.bEnabled &&
294
+ bOmitFromLog == rhs.bOmitFromLog &&
295
+ bOmitFromOutput == rhs.bOmitFromOutput &&
296
+ bOneShot == rhs.bOneShot &&
297
+ fAtSecond == rhs.fAtSecond &&
298
+ fEverySecond == rhs.fEverySecond &&
299
+ fOffsetSecond == rhs.fOffsetSecond &&
300
+ iAtHour == rhs.iAtHour &&
301
+ iAtMinute == rhs.iAtMinute &&
302
+ iEveryHour == rhs.iEveryHour &&
303
+ iEveryMinute == rhs.iEveryMinute &&
304
+ iOffsetHour == rhs.iOffsetHour &&
305
+ iOffsetMinute == rhs.iOffsetMinute &&
306
+ iSendTo == rhs.iSendTo &&
307
+ iType == rhs.iType &&
308
+ iUserOption == rhs.iUserOption &&
309
+ strContents == rhs.strContents &&
310
+ strGroup == rhs.strGroup &&
311
+ strLabel == rhs.strLabel &&
312
+ strProcedure == rhs.strProcedure &&
313
+ strVariable == rhs.strVariable
314
+
315
+ ) return true ;
316
+
317
+ return false ;
318
+ } // end of CTimer::operator==
319
+
320
+
219
321
UINT CMUSHclientDoc::Load_World_XML (CArchive& ar,
220
322
const unsigned long iMask,
221
323
const unsigned long iFlags,
@@ -1068,7 +1170,7 @@ UINT CMUSHclientDoc::Load_Triggers_XML (CXMLelement & parent,
1068
1170
} // end of CMUSHclientDoc::Load_Triggers_XML
1069
1171
1070
1172
1071
- void CMUSHclientDoc::Load_One_Trigger_XML (CXMLelement & node,
1173
+ bool CMUSHclientDoc::Load_One_Trigger_XML (CXMLelement & node,
1072
1174
const unsigned long iMask,
1073
1175
const long iVersion,
1074
1176
bool bUseDefault,
@@ -1257,14 +1359,33 @@ CString strVariable;
1257
1359
throw ;
1258
1360
}
1259
1361
1362
+ // check if this exact alias already exists (suggested by Fiendish 12 Dec 2011)
1363
+ // version: 4.81
1364
+ if (t->strLabel .IsEmpty ())
1365
+ {
1366
+ CTrigger * pExistingTrigger;
1367
+ CString strExistingTriggerName;
1368
+
1369
+ for (POSITION pos = GetTriggerMap ().GetStartPosition (); pos; )
1370
+ {
1371
+ GetTriggerMap ().GetNextAssoc (pos, strExistingTriggerName, pExistingTrigger);
1372
+ if (*pExistingTrigger == *t)
1373
+ {
1374
+ delete t; // get rid of duplicate trigger
1375
+ return false ; // and don't add it
1376
+ } // end of duplicate
1377
+ } // end of for loop
1378
+
1379
+ } // end of un-named trigger
1380
+
1260
1381
// now add to our internal trigger map
1261
1382
1262
1383
t->nUpdateNumber = App.GetUniqueNumber (); // for concurrency checks
1263
1384
t->strInternalName = strTriggerName; // for deleting one-shot triggers
1264
1385
GetTriggerMap ().SetAt (strTriggerName, t);
1265
1386
1266
1387
CheckUsed (node); // check we used all attributes
1267
-
1388
+ return true ; // loaded OK
1268
1389
} // end of CMUSHclientDoc::Load_One_Trigger_XML
1269
1390
1270
1391
@@ -1282,8 +1403,8 @@ UINT count = 0;
1282
1403
1283
1404
try
1284
1405
{
1285
- Load_One_Alias_XML (*pElement, iMask, iVersion, bUseDefault, iFlags);
1286
- count++;
1406
+ if ( Load_One_Alias_XML (*pElement, iMask, iVersion, bUseDefault, iFlags))
1407
+ count++;
1287
1408
}
1288
1409
catch (CException* e)
1289
1410
{
@@ -1302,7 +1423,7 @@ UINT count = 0;
1302
1423
} // end of CMUSHclientDoc::Load_Aliases_XML
1303
1424
1304
1425
1305
- void CMUSHclientDoc::Load_One_Alias_XML (CXMLelement & node,
1426
+ bool CMUSHclientDoc::Load_One_Alias_XML (CXMLelement & node,
1306
1427
const unsigned long iMask,
1307
1428
const long iVersion,
1308
1429
bool bUseDefault,
@@ -1470,14 +1591,33 @@ CString strVariable;
1470
1591
throw ;
1471
1592
}
1472
1593
1594
+ // check if this exact alias already exists (suggested by Fiendish 12 Dec 2011)
1595
+ // version: 4.81
1596
+ if (a->strLabel .IsEmpty ())
1597
+ {
1598
+ CAlias * pExistingAlias;
1599
+ CString strExistingAliasName;
1600
+
1601
+ for (POSITION pos = GetAliasMap ().GetStartPosition (); pos; )
1602
+ {
1603
+ GetAliasMap ().GetNextAssoc (pos, strExistingAliasName, pExistingAlias);
1604
+ if (*pExistingAlias == *a)
1605
+ {
1606
+ delete a; // get rid of duplicate alias
1607
+ return false ; // and don't add it
1608
+ } // end of duplicate
1609
+ } // end of for loop
1610
+
1611
+ } // end of un-named alias
1612
+
1473
1613
// now add to our internal alias map
1474
1614
1475
1615
a->nUpdateNumber = App.GetUniqueNumber (); // for concurrency checks
1476
1616
a->strInternalName = strAliasName; // for deleting one-shot aliases
1477
1617
GetAliasMap ().SetAt (strAliasName, a);
1478
1618
1479
1619
CheckUsed (node); // check we used all attributes
1480
-
1620
+ return true ; // loaded OK
1481
1621
} // end of CMUSHclientDoc::Load_One_Alias_XML
1482
1622
1483
1623
@@ -1515,7 +1655,7 @@ UINT count = 0;
1515
1655
} // end of CMUSHclientDoc::Load_Timers_XML
1516
1656
1517
1657
1518
- void CMUSHclientDoc::Load_One_Timer_XML (CXMLelement & node,
1658
+ bool CMUSHclientDoc::Load_One_Timer_XML (CXMLelement & node,
1519
1659
const unsigned long iMask,
1520
1660
const long iVersion,
1521
1661
bool bUseDefault,
@@ -1657,6 +1797,25 @@ CString strTimerName,
1657
1797
throw ;
1658
1798
}
1659
1799
1800
+ // check if this exact timer already exists (suggested by Fiendish 12 Dec 2011)
1801
+ // version: 4.81
1802
+ if (t->strLabel .IsEmpty ())
1803
+ {
1804
+ CTimer * pExistingTimer;
1805
+ CString strExistingTimerName;
1806
+
1807
+ for (POSITION pos = GetTimerMap ().GetStartPosition (); pos; )
1808
+ {
1809
+ GetTimerMap ().GetNextAssoc (pos, strExistingTimerName, pExistingTimer);
1810
+ if (*pExistingTimer == *t)
1811
+ {
1812
+ delete t; // get rid of duplicate timer
1813
+ return false ; // and don't add it
1814
+ } // end of duplicate
1815
+ } // end of for loop
1816
+
1817
+ } // end of un-named timer
1818
+
1660
1819
// now add to our internal timer map
1661
1820
1662
1821
t->nUpdateNumber = App.GetUniqueNumber (); // for concurrency checks
@@ -1665,7 +1824,7 @@ CString strTimerName,
1665
1824
ResetOneTimer (t); // make sure it is reset
1666
1825
1667
1826
CheckUsed (node); // check we used all attributes
1668
-
1827
+ return true ; // loaded OK
1669
1828
} // end of CMUSHclientDoc::Load_One_Timer_XML
1670
1829
1671
1830
0 commit comments