@@ -34,10 +34,9 @@ fn_info_game_ini() {
34
34
configtype=" ini"
35
35
}
36
36
37
- # Config Type: custom
37
+ # Config Type: Key Value Pairs (Equals Delimited)
38
38
# Comment: ; or #
39
- # Note: this ini filter does not filter by section. Can cause issues with some games that have multiple sections with the same variable name.
40
- fn_info_game_keyvalue_pairs () {
39
+ fn_info_game_keyvalue_pairs_equals () {
41
40
# sed is used to process the file.
42
41
# -n: Suppresses automatic printing of pattern space.
43
42
# /^\<'"${2}"'\>/: Matches lines starting with the word provided as the second argument ($2), considering it as a whole word.
@@ -60,6 +59,31 @@ fn_info_game_keyvalue_pairs() {
60
59
configtype=" keyvalue_pairs"
61
60
}
62
61
62
+ # Config Type: Key Value Pairs (Space Delimited)
63
+ # Comment: ; or #
64
+ fn_info_game_keyvalue_pairs_space () {
65
+ # sed is used to process the file.
66
+ # -n: Suppresses automatic printing of pattern space.
67
+ # /^\<'"${2}"'\>/: Matches lines starting with the word provided as the second argument ($2), considering it as a whole word.
68
+ # { s/.* *"\?\([^"]*\)"\?/\1/p;q }: Command block executed for lines that match the pattern.
69
+ # - s/.* *"\?\([^"]*\)"\?/\1/: Matches and captures the value after an space ( ), possibly surrounded by optional double quotes.
70
+ # - .*: Matches any characters before the space.
71
+ # - = *"\?: Matches the space and any optional spaces before an optional double quote.
72
+ # - \([^"]*\): Captures any characters that are not double quotes.
73
+ # - "\?: Matches an optional double quote.
74
+ # - /1: Replaces the entire matched pattern with the captured value.
75
+ # - p: Prints the modified line.
76
+ # - q: Quits processing after modifying and printing the line.
77
+
78
+ if [ -n " ${3} " ]; then
79
+ servercfgparse=" ${3} "
80
+ else
81
+ servercfgparse=" ${servercfgfullpath} "
82
+ fi
83
+ eval " ${1} =\" $( sed -n ' /^\<' " ${2} " ' \>/ { s/.* *\"\?\([^"]*\)\"\?/\1/p;q }' " ${servercfgparse} " | tr -d ' \r' ) \" "
84
+ configtype=" keyvalue_pairs"
85
+ }
86
+
63
87
# Config Type: QuakeC
64
88
# Comment: // or /* */
65
89
fn_info_game_quakec () {
@@ -896,11 +920,11 @@ fn_info_game_armar() {
896
920
# Filetype: con
897
921
fn_info_game_bf1942 () {
898
922
if [ -f " ${servercfgfullpath} " ]; then
899
- fn_info_game_keyvalue_pairs " configip" " game.serverIp "
900
- fn_info_game_keyvalue_pairs " maxplayers" " game.serverMaxPlayers"
901
- fn_info_game_keyvalue_pairs " port" " game.serverPort"
902
- fn_info_game_keyvalue_pairs " servername" " game.serverName"
903
- fn_info_game_keyvalue_pairs " serverpassword" " game.serverPassword"
923
+ fn_info_game_keyvalue_pairs_space " configip" " game.serverIP "
924
+ fn_info_game_keyvalue_pairs_space " maxplayers" " game.serverMaxPlayers"
925
+ fn_info_game_keyvalue_pairs_space " port" " game.serverPort"
926
+ fn_info_game_keyvalue_pairs_space " servername" " game.serverName"
927
+ fn_info_game_keyvalue_pairs_space " serverpassword" " game.serverPassword"
904
928
fi
905
929
configip=" ${configip:- " 0.0.0.0" } "
906
930
maxplayers=" ${maxplayers:- " 0" } "
@@ -917,11 +941,11 @@ fn_info_game_bf1942() {
917
941
# Filetype: con
918
942
fn_info_game_bfv () {
919
943
if [ -f " ${servercfgfullpath} " ]; then
920
- fn_info_game_keyvalue_pairs " configip" " game.serverIp"
921
- fn_info_game_keyvalue_pairs " maxplayers" " game.serverMaxPlayers"
922
- fn_info_game_keyvalue_pairs " port" " game.serverPort"
923
- fn_info_game_keyvalue_pairs " servername" " game.serverName"
924
- fn_info_game_keyvalue_pairs " serverpassword" " game.serverPassword"
944
+ fn_info_game_keyvalue_pairs_space " configip" " game.serverIp"
945
+ fn_info_game_keyvalue_pairs_space " maxplayers" " game.serverMaxPlayers"
946
+ fn_info_game_keyvalue_pairs_space " port" " game.serverPort"
947
+ fn_info_game_keyvalue_pairs_space " servername" " game.serverName"
948
+ fn_info_game_keyvalue_pairs_space " serverpassword" " game.serverPassword"
925
949
fi
926
950
configip=" ${configip:- " 0.0.0.0" } "
927
951
maxplayers=" ${maxplayers:- " 0" } "
@@ -1750,14 +1774,14 @@ fn_info_game_rust() {
1750
1774
1751
1775
fn_info_game_rw () {
1752
1776
if [ -f " ${servercfgfullpath} " ]; then
1753
- fn_info_game_keyvalue_pairs " configip" " Server_IP"
1754
- fn_info_game_keyvalue_pairs " gamemode" " World_GameMode"
1755
- fn_info_game_keyvalue_pairs " maxplayers" " Server_MaxPlayers"
1756
- fn_info_game_keyvalue_pairs " port" " Server_Port"
1757
- fn_info_game_keyvalue_pairs " rconport" " RCON_Port"
1758
- fn_info_game_keyvalue_pairs " seed" " World_Seed"
1759
- fn_info_game_keyvalue_pairs " servername" " Server_Name"
1760
- fn_info_game_keyvalue_pairs " worldname" " World_Name"
1777
+ fn_info_game_keyvalue_pairs_equals " configip" " Server_IP"
1778
+ fn_info_game_keyvalue_pairs_equals " gamemode" " World_GameMode"
1779
+ fn_info_game_keyvalue_pairs_equals " maxplayers" " Server_MaxPlayers"
1780
+ fn_info_game_keyvalue_pairs_equals " port" " Server_Port"
1781
+ fn_info_game_keyvalue_pairs_equals " rconport" " RCON_Port"
1782
+ fn_info_game_keyvalue_pairs_equals " seed" " World_Seed"
1783
+ fn_info_game_keyvalue_pairs_equals " servername" " Server_Name"
1784
+ fn_info_game_keyvalue_pairs_equals " worldname" " World_Name"
1761
1785
fi
1762
1786
configip=" ${configip:- " 0.0.0.0" } "
1763
1787
gamemode=" ${gamemode:- " NOT SET" } "
@@ -1994,12 +2018,12 @@ fn_info_game_spark() {
1994
2018
# Filetype: cfg
1995
2019
fn_info_game_squad () {
1996
2020
if [ -f " ${servercfgfullpath} " ]; then
1997
- fn_info_game_keyvalue_pairs " servername" " ServerName"
1998
- fn_info_game_keyvalue_pairs " maxplayers" " MaxPlayers"
2021
+ fn_info_game_keyvalue_pairs_equals " servername" " ServerName"
2022
+ fn_info_game_keyvalue_pairs_equals " maxplayers" " MaxPlayers"
1999
2023
fi
2000
2024
if [ -f " ${servercfgdir} /Rcon.cfg" ]; then
2001
- fn_info_game_keyvalue_pairs " rconport" " Port" " ${servercfgdir} /Rcon.cfg"
2002
- fn_info_game_keyvalue_pairs " rconpassword" " Password" " ${servercfgdir} /Rcon.cfg"
2025
+ fn_info_game_keyvalue_pairs_equals " rconport" " Port" " ${servercfgdir} /Rcon.cfg"
2026
+ fn_info_game_keyvalue_pairs_equals " rconpassword" " Password" " ${servercfgdir} /Rcon.cfg"
2003
2027
fi
2004
2028
maxplayers=" ${maxplayers:- " 0" } "
2005
2029
port=" ${port:- " 0" } "
@@ -2017,10 +2041,10 @@ fn_info_game_squad() {
2017
2041
# Filetype: cfg
2018
2042
fn_info_game_terraria () {
2019
2043
if [ -f " ${servercfgfullpath} " ]; then
2020
- fn_info_game_keyvalue_pairs " maxplayers" " maxplayers"
2021
- fn_info_game_keyvalue_pairs " port" " port"
2022
- fn_info_game_keyvalue_pairs " servername" " worldname"
2023
- fn_info_game_keyvalue_pairs " worldname" " world"
2044
+ fn_info_game_keyvalue_pairs_equals " maxplayers" " maxplayers"
2045
+ fn_info_game_keyvalue_pairs_equals " port" " port"
2046
+ fn_info_game_keyvalue_pairs_equals " servername" " worldname"
2047
+ fn_info_game_keyvalue_pairs_equals " worldname" " world"
2024
2048
fi
2025
2049
queryport=" ${port:- " 0" } "
2026
2050
servername=" ${servername:- " NOT SET" } "
0 commit comments