08 Sep, 2009, Banner wrote in the 1st comment:
Votes: 0
Once again I've run into a spot of code that worked fine before C++ and now it simply refuses to do as intended.

/*                 
* Planet Flags
*/
#define PLANET_NOCAPTURE BV00
#define PLANET_SHIELDED BV01


I have two planet flags, normal bitvectors that save as an integer and whatnot. The nocapture flag, when toggled, works, saves, loads, and is recognized correctly. The SHIELDED flag, however, does not. The code simply refuses to acknowledge that it's been set.

if( IS_SET( planet->flags, PLANET_SHIELDED ) )
{
send_to_char( "&wShield System &RDeactivated.&W\n\r", ch );
sprintf( buf, "&C%s acesses the Shield Network and disables %s's shield system.&W\n\r", ch->name, planet->name );
act( AT_MAGIC, buf, ch, NULL, argument, TO_ROOM );
TOGGLE_BIT( planet->flags, PLANET_SHIELDED );
sprintf( buf2, "%s disabled the Shield System on %s in room %d.", ch->name, planet->name, ch->in_room->vnum );
log_string_plus( buf2, LOG_NORMAL, sysdata.log_level );
}
else
{
send_to_char( "&wShield System &GActivated.&W\n\r", ch );
sprintf( buf, "&C%s acesses the Shield Network and enables %s's shield system.&W\n\r", ch->name, planet->name );
act( AT_PLAIN, buf, ch, NULL, argument, TO_ROOM );
TOGGLE_BIT( planet->flags, PLANET_SHIELDED );
sprintf( buf2, "%s enabled the Shield System on %s in room %d.", ch->name, planet->name, ch->in_room->vnum );
log_string_plus( buf2, LOG_NORMAL, sysdata.log_level );
}

save_planet( planet );
return;
}



pshield
Shield System Activated.
Log: Banner enabled the Shield System on Yavin in room 6100.

[Force]: 26000/26000 [Align]: good
[Health]: 100011/100011 [Move]: 30000/30000 [$$]:[0]|>
pshield
Shield System Activated.
Log: Banner enabled the Shield System on Yavin in room 6100.

[Force]: 26000/26000 [Align]: good
[Health]: 100011/100011 [Move]: 30000/30000 [$$]:[0]|>
pshield
Shield System Activated.
Log: Banner enabled the Shield System on Yavin in room 6100.

[Force]: 26000/26000 [Align]: good
[Health]: 100011/100011 [Move]: 30000/30000 [$$]:[0]|>
pshield
Shield System Activated.
Log: Banner enabled the Shield System on Yavin in room 6100.

[Force]: 26000/26000 [Align]: good
[Health]: 100011/100011 [Move]: 30000/30000 [$$]:[0]|>
pshield
Shield System Activated.
Log: Banner enabled the Shield System on Yavin in room 6100.


EDIT: To further clarify, NOCAPTURE is toggled via TOGGLE_BIT as well and it works, and yes I tried changing the TOGGLE_BIT to REMOVE/SET to no avil, and I swapped NOCAPTURE into the pshield toggling code above and it toggled on and off correctly, so apparently it's just that one flag for some reason.
08 Sep, 2009, David Haley wrote in the 2nd comment:
Votes: 0
This is not enough information to know what's happening. We need to see things like the definition of planet->flags, TOGGLE_BIT, etc. Also, use gdb to follow the code and see what is happening as you attempt to toggle the bit.

By the way, it's rather unlikely that this is because of C++. Clearly it happened during the conversion to C++, but chances are that that is entirely coincidental. People shouldn't be so happy to blame C++ for their problems. :smile:
08 Sep, 2009, Kline wrote in the 3rd comment:
Votes: 0
I'm hoping BV00 == 1 and BV01 == 2? Also, is your C++ side using bitset now or still a plain int with bitwise logic?
08 Sep, 2009, Banner wrote in the 4th comment:
Votes: 0
I uhm.. fixed it.. it's too embarrassing to even say what it was, but it was not my fault! :redface:
0.0/4