This makes how classes are defined in the client less consistent
than before, but the new client, which doesn't have this problem, is
well underway, so this isn't a big deal in the long term.
PS the server will ignore all messages above ~150 KB. To protect against
DoS attacks, this is done silently, with no response at all.
Note that this is is not at all a problem for normal teams with 6
Pokemon, which come in at around 1KB.
Users sometimes make a mistake and send corrupt teams above this limit,
such as an import error causing a team with 1000 Pokemon or whatever.
This used to happen silently, confusing users and causing them to retry,
but this change gives it an error message.
I really do have to investigate more closely exactly what this code is
doing, but I remember the last time I tried to simplify this, it broke
Unicode support.
The username on the password field is now a visible read-only textbox,
instead of a hidden textbox.
This is apparently required for Chrome to realize that it's a username
field for the purposes of its password manager.
We now just use JSON.parse and JSON.stringify - it's supported by all
browsers supported by the client.
Tools.safeJSON has also been moved to Storage.safeJSON, since it's not
used in replays at all.
The Toxic turn tracker is now 1 off from previously; it now counts the
previous Toxic turn rather than the next one. This makes "0" more
intuitively represent the state before any Toxic damage is taken.
This fix mainly just fixes the type issue by removing the need for a
null value at all.
This doesn't change debuggability and saves a bit of bandwidth.
But most importantly, it might help Windows users who are having
trouble compiling because Babel runs out of memory.
Restoring a backup previously required all teams to be packed, or all
teams to be unpacked. Now, we support pasting a mix of packed and
unpacked teams.
I absolutely refuse to believe there's any risk at all to using
document.write with a constant string.
But it's fair that it's non-standard, and won't work if the script
is loaded dynamically/asynchronously, so let's switch to the standard
way to dynamically load scripts and styles.
I'm still using `.src = foo` instead of `.setAttribute('src', foo)`
because there's no reason to write modern code when old-school code
works and is arguably more readable.
I know, I know, unused code should be removed, not commented out. In
my defense:
1. This kind of code is really annoying to dig out of Git.
2. This kind of code will be used when this is refactored for use for
an external messages file, which is planned (and necessary for
translation support.)
Team backup/restore was previously always unpacked, which is good for
readability but bad for memory usage. At high team counts, this can be a
serious problem, so with this change, if you have more than 350 teams,
your teams will be backed up in packed format.