This fixes two race conditions in writing lastbattle.txt:
1) Previously, there could be several calls to `fs.writeFile` on
lastbattle.txt queued at the same time. The order these would run in
was undefined, so lastbattle.txt did not necessarily represent the
actual last battle at any given time.
2) Since `fs.writeFile` clears the file before writing to it, it
was possible to end up with an empty lastbattle.txt if the process
terminated while the call to `fs.writeFile` was being processed
asynchronously. This commit fixes the issue by writing to a file
named logs/lastbattle.txt.0 and then renaming that file to
logs/lastbattle.txt. On POSIX, `rename` changes the target
file's link to point to the soruce file (which is an atomic
operation). Thus, this removes the possibility of ending up with
an empty logs/lastbattle.txt on POSIX.
Unfortunately, on Windows, `rename` will throw an error if the
target file exists, which it will. In case of an error, this
code still writes to logs/lastbattle.txt, but in a way that
has a possibility of a race condition. As such, race conditions
in writing to logs/lastbattle.txt are still possible on Windows, but
they are fixed on POSIX at least.
- /fr and /frt now behave as follows:
1) Regardless of whether they are used in a battle or in the lobby,
both commands show a message to all users in the lobby with the
`receiveauthmessages` permission (which is % and up by default).
2) If used in a battle, the message is also shown to all users in
the battle, even if they are not auth. In addition, the message
is written to the lobby file logs.
- use of /lockdown, /endlockdown, /kill, /crashfixed, and /crashnoted
is now written to the lobby file logs (including the identity of the
person who used the command)
- if you bring a level 50 pokemon to VGC, it'll be treated as level 100
for the purposes of checking level-up moves
- we introduce a new flag 'maxForcedLevel' for this
Encore's `onBeforeTurn` event handler was causing problems with
interactions with Taunt and Torment (and possibly other things)
by changing move decisions from Struggle to the Encored move.
The `onBeforeTurn` event handler is not a necessary part of the
Encore implementation because `battle.parseChoice` already calls
`pokemon.getValidMoves`, which in turn calls `pokemon.getMoves`,
which checks if the selected move is disabled. The `encore` effect
already disables all moves other than the Encored one, so they
cannot be selected even without the `onBeforeTurn` handler.
In the result, this commit deletes the `onBeforeTurn` handler.
- all accuracy is now rounded up to the nearest multiple of 10%
- except for Fire Blast / Blue Flare, which have different changes
- Justified caps base power at 100 mostly: Sacred Sword has a use now!
- Surf has 10% chance to lower Speed
- Refer to the project as 'Pokemon Showdown' rather than 'Showdown'
- Up to date information about the logging features of Pokemon Showdown
- Use UNIX line endings (like the rest of the project does)
This is mainly because there is a chance (however small) that dealing
with the result of /updateserver will require shell access to the
server. There's also a race condition when two people update at once
when there are changes to the working directory or index, and limiting
this to the `console` permission will help avoid that.
This command updates the server code to the upstream repository
version. It requires that `git` be on the PATH, which may not be
the case on a Windows installation.
- When `config.reportjoins` is enabled, joins are no longer included in
the scrollback buffer sent to the client when joining the lobby.
- Leaving the lobby is now included in the lobby file logs.
- The identity of users using /birkal is now included in the lobby file
logs (but still not shown in the content sent to the client).
The gen3 moves.js was throwing an exception on load because it
calls a function which does not exist. This commit does not properly
fix Bide, but it does fix the ReferenceError exception.