Fixed six different incidences where different laws, including nuclear power and animal research, would be set to L+ instead of checking if they were L+.
The thing to understand here is that the equals symbol in C++ does not mean what it means in math. The equals symbol means "Take what's on the right and assign its value to the stuff on the left." It is called the assignment operator. The statement "one = two" will force the variable named "one" to be equal to the variable named "two". If you write "if(1=2)" the compiler will choke, because it can't change a constant value (the number 1), and you've just ordered the code to set 1 to be equal to 2 every time this statement is evaluated.
For an LCS example:
if(law[LAW_NUCLEARPOWER]=2) // or if(law[LAW_NUCLEARPOWER]=ALIGN_ELITELIBERAL)
{
addstr("nuclear power is illegal");
}
This code will force nuclear power to always be L+ whenever this code block is hit, and it will always, always print the text "nuclear power is illegal" to the screen.
To check if two values are equal to one another, you can't ever use a single equals sign. That's the assignment operator. You need to stack two equals signs together to create a new symbol, the equality operator. The code "if(1==2)" won't cause the compiler to choke -- it'll just always evaluate to false, because 1 isn't equal to 2.
For the LCS example:
if(law[LAW_NUCLEARPOWER]==2) // or if(law[LAW_NUCLEARPOWER]==ALIGN_ELITELIBERAL)
{
addstr("nuclear power is illegal");
}
This no longer forces nuclear power to be L+ every time the if statement is encountered. It also no longer always dumps the text nuclear power is illegal to the screen -- now it only happens if nuclear power is already at L+.
In math, we're used to = meaning that the two sides are equal. But C++ is its own language, and in C++, that's not what it means. When coding, you have to be very careful of this.