@@ -1400,7 +1400,8 @@ void control_enable_hook(IoActionId id, bool enable) {
14001400}
14011401
14021402/* *
1403- * Stuffs the CCF flags into the given char. Needs item_id for validation
1403+ * Stuffs the CCF flags into the given char. Needs item_id for validation.
1404+ * @details Unknown, unrecognized, or excessive flags are silently ignored on Release builds. Debug builds complain.
14041405 */
14051406void stuff_CCF (char & flags, size_t item_id) {
14061407 Assert (item_id < Control_config.size ());
@@ -1414,7 +1415,9 @@ void stuff_CCF(char& flags, size_t item_id) {
14141415 SCP_string flag_str;
14151416 size_t pos = 0 ;
14161417 size_t len = 0 ;
1417-
1418+
1419+ // Lambda to add flags.
1420+ // Debug version Eats the substring as it is found.
14181421 auto ADD_FLAG = [&](char id) {
14191422 flag_str = ValToCCF (id);
14201423 pos = szTempBuffer.find (flag_str);
@@ -1425,6 +1428,8 @@ void stuff_CCF(char& flags, size_t item_id) {
14251428 }
14261429 };
14271430#else
1431+ // Lambda to add flags.
1432+ // Release version doesn't modify szTempBuffer as it searches for substrings.
14281433 auto ADD_FLAG = [&](char id) {
14291434 if (szTempBuffer.find (ValToCCF (id)) != SCP_string::npos)
14301435 flags |= id;
@@ -1438,13 +1443,38 @@ void stuff_CCF(char& flags, size_t item_id) {
14381443 ADD_FLAG (CCF_HAT);
14391444 ADD_FLAG (CCF_BALL);
14401445
1446+
14411447#ifndef NDEBUG
1448+ // Eat the "CCF_NONE" and "NONE" substrings
1449+ auto EAT_FLAG = [&](SCP_string str) {
1450+ pos = szTempBuffer.find (str);
1451+ len = str.length ();
1452+ if (pos != SCP_string::npos) {
1453+ if (flags != 0 ) {
1454+ // Complain about bad habits
1455+ error_display (0 ,
1456+ " Flag 'NONE' passed to config item %i along with other flags, ignoring: \n '%s'" ,
1457+ static_cast <int >(item_id),
1458+ szTempBuffer.c_str ()
1459+ );
1460+ }
1461+ szTempBuffer.erase (pos, len);
1462+ }
1463+ };
1464+
1465+ EAT_FLAG (" CCF_NONE" );
1466+ EAT_FLAG (" NONE" );
1467+
14421468 // Complain about any unknown flag strings
14431469 replace_all (szTempBuffer, " ," , " " );
14441470 drop_white_space (szTempBuffer);
14451471
14461472 if (!szTempBuffer.empty ()) {
1447- error_display (0 , " Unknown flags passed to config item %i, ignoring: \n '%s'" , static_cast <int >(item_id), szTempBuffer.c_str ());
1473+ error_display (0 ,
1474+ " Unknown (or excessive) flags passed to config item %i, ignoring: \n '%s'" ,
1475+ static_cast <int >(item_id),
1476+ szTempBuffer.c_str ()
1477+ );
14481478 }
14491479#endif
14501480
@@ -2276,7 +2306,7 @@ SCP_string ValToCCF(char id) {
22762306 }
22772307
22782308 if (str.empty ()) {
2279- // If unsupported flags, or no flags at all , list as "None"
2309+ // If unsupported flags, or (id == CCF_NONE) , list as "None"
22802310 str = " NONE" ;
22812311 }
22822312
0 commit comments