th3-z / kf2-magicked-admin

:spider: Mutator-free management, statistics, and in-game bot for ranked Killing Floor 2 servers
https://kf2-ma.th3-z.xyz
MIT License
32 stars 7 forks source link

[BUG] Total stats aren't working #142

Closed Lartza closed 4 years ago

Lartza commented 4 years ago

Describe the bug Stat totals aren't tracked. Greeter shows zeroes and !kills etc show current round as both values.

To Reproduce Steps to reproduce the behavior:

  1. Finish a map and let the server load a new one
  2. Join the server with the example greeter or issue !kills during the round
  3. Greeter shows all values always as zero, !kills shows what you've killed during the current round as both values

Expected behavior Greeter and commands show correct totals for kills, time and sessions

Server:

Log

New game on server_one, map: KF-Containment Station, mode: Survival
internal_command@server_one: !new_game
Player banlo joined server_one from Unknown
internal_command@server_one: !player_join banlo
D.A.R.@server_one: Welcome  banlo.
You've killed 0 ZEDs, (#69)
earned $0 (#69) and
played for 00:00:00 over 1 sessions.
Player Lartza joined server_one from Unknown
internal_command@server_one: !player_join Lartza
D.A.R.@server_one: Welcome  Lartza.
You've killed 0 ZEDs, (#70)
earned $0 (#70) and
played for 00:00:00 over 1 sessions.
Player Diss joined server_one from Unknown
internal_command@server_one: !player_join Diss
D.A.R.@server_one: Welcome  Diss.
You've killed 0 ZEDs, (#71)
earned $0 (#71) and
played for 00:00:00 over 1 sessions.
internal_command@server_one: !new_wave 1
Player Kurlito joined server_one from Unknown
internal_command@server_one: !player_join Kurlito
 [#] Flushing players on server_one
 [#] Updated the MOTD!
D.A.R.@server_one: Welcome  Kurlito.
You've killed 0 ZEDs, (#72)
earned $0 (#72) and
played for 00:00:00 over 1 sessions.
Player Kurlito died on server_one
internal_command@server_one: !t_open 1
D.A.R.@server_one: Player Lartza killed the most ZEDs this wave: 31
internal_command@server_one: !t_close 1
internal_command@server_one: !new_wave 2
internal_command@server_one: !t_open 2
D.A.R.@server_one: Player Diss killed the most ZEDs this wave: 28
internal_command@server_one: !t_close 2
internal_command@server_one: !new_wave 3
 [#] Flushing players on server_one
 [#] Updated the MOTD!
internal_command@server_one: !t_open 3
D.A.R.@server_one: Player Diss killed the most ZEDs this wave: 29
internal_command@server_one: !t_close 3
internal_command@server_one: !new_wave 4
internal_command@server_one: !t_open 4
D.A.R.@server_one: Player banlo killed the most ZEDs this wave: 34
internal_command@server_one: !t_close 4
internal_command@server_one: !new_wave 5
 [#] Flushing players on server_one
 [#] Updated the MOTD!
Player Lartza died on server_one
internal_command@server_one: !t_open 5
D.A.R.@server_one: Player Diss killed the most ZEDs this wave: 62
internal_command@server_one: !t_close 5
internal_command@server_one: !new_wave 6
 [#] Flushing players on server_one
 [#] Updated the MOTD!
internal_command@server_one: !t_open 6
D.A.R.@server_one: Player Diss killed the most ZEDs this wave: 45
internal_command@server_one: !t_close 6
internal_command@server_one: !new_wave 7
Player Diss died on server_one
internal_command@server_one: !t_open 7
D.A.R.@server_one: Player banlo killed the most ZEDs this wave: 49
internal_command@server_one: !t_close 7
internal_command@server_one: !new_wave 8
 [#] Flushing players on server_one
 [#] Updated the MOTD!
Player Diss died on server_one
Player Lartza died on server_one
Lartza@server_one: rip me
 [#] Flushing players on server_one
 [#] Updated the MOTD!
Player Diss left server_one
internal_command@server_one: !player_quit Diss
Player banlo left server_one
internal_command@server_one: !player_quit banlo
Player Lartza left server_one
internal_command@server_one: !player_quit Lartza
 [#] ConnectionError getting http://localhost:8080/ServerAdmin/current/info. Retrying in 6s
 [#] ConnectionError posting http://localhost:8080/ServerAdmin/current/chat+data. Retrying in 6s
Player banlo joined server_one from Unknown
internal_command@server_one: !player_join banlo
 [#] End game on server_one, map: KF-CONTAINMENTSTATION, mode: kfgamecontent.KFGameInfo_Survival, victory: False
 [#] Writing game to database (KF-Containment Station)
New game on server_one, map: KF-Tyro, mode: Survival
internal_command@server_one: !new_game
Player Kurlito joined server_one from Unknown
internal_command@server_one: !player_join Kurlito
Player Lartza joined server_one from Unknown
internal_command@server_one: !player_join Lartza
D.A.R.@server_one: Welcome  banlo.
You've killed 0 ZEDs, (#73)
earned $0 (#73) and
played for 00:00:00 over 1 sessions.
D.A.R.@server_one: Welcome  Kurlito.
You've killed 0 ZEDs, (#74)
earned $0 (#74) and
played for 00:00:00 over 1 sessions.
D.A.R.@server_one: Welcome  Lartza.
You've killed 0 ZEDs, (#75)
earned $0 (#75) and
played for 00:00:00 over 1 sessions.
internal_command@server_one: !new_wave 1
internal_command@server_one: !t_open 1
D.A.R.@server_one: Player Lartza killed the most ZEDs this wave: 31
Lartza commented 4 years ago

I also noticed operator status isn't being saved, so this could mean anything database related just doesn't work for some reason. But the bot isn't complaining

th3-z commented 4 years ago

Hi, thanks for the bug report, I'll have a look at it soon. Have you tried deleting conf/server_one.sqlite?

Lartza commented 4 years ago

Thanks, no rush :) Hadn't had much time to debug apart from updating to the dev version after first trying 0.1.5.

Argh I wrote all of the quoted below before figuring out the issue, and it was pretty much my fault, and I even thought about it but just had no time to figure things out. The webadmin tweaks I applied were breaking magicked's ability to read steamid from the webadmin. Joys of games with subpar administration tools <3

Now, it's kind of impossible to spot this because the bot never says anything, without knowing how to look inside the sqlite database. Even when the bot is working it console prints "Player Lartza joined server_one from Unknown" where I assume Unknown is supposed to be a country? I can also see spots like https://github.com/th3-z/kf2-magicked-admin/blob/690faa8d82d1962b111720a95eb3e983b27334e5/magicked_admin/server/server.py#L173-L179 can print the steamid out but don't? Even in debug mode?

Would probably be worthwhile to look at what debug info is currently being printed and add more to it to prevent cases like this.

I took a look inside the database first before doing anything and at least maps and map_records seem to be stored correctly. Now players though...

sqlite> select * from players where username = 'Lartza';
256_0x011000010162CAC3_2064.6575|Lartza|7|1|299|0|1|1|0|147.900616645813
257_0x011000010162CAC3_12.8046|Lartza|25|0|630|0|0|1|0|209.638657331467
281_0x011000010162CAC3_558.2925|Lartza|39|1|1109|0|0|3|0|351.008404254913
293_0x011000010162CAC3_4.8015|Lartza|168|0|5745|0|0|1|0|1202.80857086182
297_0x011000010162CAC3_12.4046|Lartza|32|0|1055|0|2|1|0|670.59761762619
306_0x011000010162CAC3_28.2106|Lartza|48|0|6817|0|0|1|0|1498.77288746834
310_0x011000010162CAC3_13.8053|Lartza|116|0|5473|0|0|1|0|1442.45944404602
259_0x011000010162CAC3_85.8332|Lartza|186|0|7487|0|2|1|0|1684.60661411285
264_0x011000010162CAC3_8.0027|Lartza|232|0|6638|0|1|1|0|1270.26294612885
403_0x011000010162CAC3_768.2405|Lartza|89|0|4935|0|1|1|0|1261.55472183228
407_0x011000010162CAC3_15.0617|Lartza|137|0|7578|0|0|1|0|1627.53972911835
413_0x011000010162CAC3_20.0389|Lartza|118|0|8911|0|1|1|0|1836.99426627159
422_0x011000010162CAC3_4.0013|Lartza|117|0|5987|0|0|1|0|1369.3295943737
431_0x011000010162CAC3_22.4081|Lartza|107|0|7002|0|0|1|0|1536.63228058815

So it seems there is an issue with the steam_id value?

I let the bot create a new database and this was the result. Attached debug output of the bot too but I doubt it's useful. I'm fluent with Python but the codebase is alien so I couldn't immediately spot an easy mistake in the code.

sqlite> .tables
map_records  maps         players
sqlite> select * from map_records;
KF-BIOTICSLAB|0.0|7|1.0000|0|0|0
KF-BURNINGPARIS|419.569530010223|4|0.0000|5|0|0
KF-BIOTICSLAB|16.3524153232574|7|1.0000|1|0|0
KF-OUTPOST|0.0|7|1.0000|0|0|0
sqlite> select * from maps;
KF-BIOTICSLAB|Biotics Lab|3|0|0|0|0|1
KF-BURNINGPARIS|Burning Paris|1|0|0|0|0|5
KF-OUTPOST|Outpost|1|0|0|0|0|0
sqlite> select * from players;
256_0x011000010162CAC3_43.4277|Lartza|127|0|11238|0|0|1|0|828.75891828537
257_0x011000010162CAC3_17.4070|Lartza|0|0|250|0|0|1|0|37.5251090526581
th3-z commented 4 years ago

Yeah, (unknown) is supposed to be a country, the API I use for it started rejecting my requests so I need something new.

Your logs have a player or network id where there should be a Steam ID. KF2-MA thinks its the Steam ID because the indexes have been misaligned by modifications. That is, it assumes that the Steam ID is in column X, but another modification shifted it into column Y. If you want to keep both you can probably work around it for now by moving the modification's new columns (country/city) to the end of the table. That said, I'm not sure if it will play nice with the links it adds to the SteamID column, you may be able to fiddle with the IDs to make it work, not sure.

The network/player keys change all the time so that's why nothing was saving, it thought you were a new player with the same name each time you joined believing that value to be your SteamID.

Theres an easy solution this, I need to look for a column heading that looks like "Steam ID" and use that index rather than assume it to be static. The code for this is already in place for the server_info page because people commonly modify it. I'll sort that out soon, I want KF2-MA to be as flexible as it can be to these sort of modifications.

You're right in saying there should be more debug for this too, it would've been obvious if the Steam ID was presented upon player join in debug mode. That's a simple enough thing to add.

I'll close the issue once the above is done so I don't forget about it.

th3-z commented 4 years ago

Addressed in 14b0da202fc10570e36a54188f6260dbb1161868