- priority: 5 --> 6
I suspect it is happening all over the code, but the
UserCombat is another fine example of not checking a
state for null before using it.
If any state does not exist in the database for an
actor, an exception will occur if you try to use this
state.
The case I ran into is that a new user does not have a
"spellpending" state in the database, therefore the
code this.State["spellpending"].ToString() throws an
exception (State["spellpending"] does not return an
object for ToString() to work on)
A lot of other states are used in this method as well,
without checking for null.
Suggested fixes:
- create checks for null everywhere you want to use a
state.
- create static methods like GetStateString(actor,
name), GetStateBool(actor, name), etc.
These methods can do the null check and return a
default value if the setting does not exist.
- figure out a way to ensure that all required data is
always in the database