Skip to content

[2.0.4] Ban time resetting on map change fix, and some quick fixes

Compare
Choose a tag to compare
@azalty azalty released this 01 Sep 00:58
· 7 commits to main since this release
  • Removed a useless query that was causing a ban duration reset when a map change occured (discrepancy between ban time variable and data from the database due to a problem with the order of the queries)
  • Fixed (re)loading the plugin mid game preventing banned players from having their ban time properly loaded, thus making the plugin think it was a permanent ban. Reconnecting fixed that, but now it shouldn't happen anymore (I hope).
  • Fixed a typo :)

Q: Why is the plugin so much smaller?
A: I used a different hosties.inc file from a semi-fixed version of SM Hosties. As far as I know, it didn't change any function from ct-bans (i'm pretty sure it only uses 1 from it), it only makes the plugin file smaller! Win, win :)


Q: What was the problem with the order of the queries?
A: I'll try to answer you, but I really suck at using the right vocabulary.
In short, queries in sourcemod are stored in a queue. First in, first out: they are processed one by one in the order they were added. This is good, since you will wait for the first query to be done before doing the second one, which might need the first one, or might have newer infos. If it wasn't working like that, it could update the newer infos (query 2, latest) and then the old ones (query 1, old).
The problem that was in the plugin is:

  • Player disconnects: add a (useless - logging only) query to the queue.
  • Once the callback arrives (the query just executed), add another query to the queue.
    The problem here is that it adds the other query WHEN the first query calls back, rather than right after the first query was added to the queue! This meant that if you were quick enough to reconnect before that first query was finished (which happens when a mapchange occurs), the plugin would add a query to the queue to get your ban infos, and that query would thus be between the first useless, logging only query AND the one that actually updated your ban time.

Result: your ban time variable is the old value from the database (the one you had on your initial connection, before the map change) and your ban time on the database is up to date. Disconnecting then would push your old values to the database and boom, you get a never-ending CT Ban.

Congratulations on reading this explanatory nightmare. Understanding it, on the other hand, is on a whole other level.