|
47 | 47 |
|
48 | 48 | #define FLAG_LETTERS_SIZE 26
|
49 | 49 |
|
| 50 | +#define AUTO_ADD_SERVER_DISABLED 0 |
| 51 | +#define AUTO_ADD_SERVER_WITH_RCON 2 |
| 52 | + |
50 | 53 | //#define DEBUG
|
51 | 54 |
|
52 | 55 | enum State/* ConfigState */
|
|
94 | 97 | , loadGroups
|
95 | 98 | , loadOverrides
|
96 | 99 | , LateLoaded
|
97 |
| - , AutoAdd |
98 | 100 | , g_bConnecting = false
|
99 | 101 | , requireSiteLogin = false /* Require a lastvisited from SB site */
|
100 | 102 | , backupConfig = true
|
|
104 | 106 | int
|
105 | 107 | g_BanTarget[MAXPLAYERS + 1] = { -1, ... }
|
106 | 108 | , g_BanTime[MAXPLAYERS + 1] = { -1, ... }
|
| 109 | + , AutoAdd = 0 |
107 | 110 | , curLoading
|
108 | 111 | , serverID = -1
|
109 | 112 | , ProcessQueueTime = 5
|
@@ -1580,9 +1583,20 @@ public void ServerInfoCallback(Database db, DBResultSet results, const char[] er
|
1580 | 1583 | if (!results.RowCount)
|
1581 | 1584 | {
|
1582 | 1585 | // get the game folder name used to determine the mod
|
1583 |
| - char desc[64], query[200]; |
| 1586 | + char desc[64], query[200], rcon[128]; |
1584 | 1587 | GetGameFolderName(desc, sizeof(desc));
|
1585 |
| - FormatEx(query, sizeof(query), "INSERT INTO %s_servers (ip, port, rcon, modid) VALUES ('%s', '%s', '', (SELECT mid FROM %s_mods WHERE modfolder = '%s'))", DatabasePrefix, ServerIp, ServerPort, DatabasePrefix, desc); |
| 1588 | + Format(rcon, sizeof(rcon), ""); |
| 1589 | + |
| 1590 | + if (AutoAdd == AUTO_ADD_SERVER_WITH_RCON) |
| 1591 | + { |
| 1592 | + ConVar cvarRconPassword = FindConVar("rcon_password"); |
| 1593 | + if (cvarRconPassword != null) |
| 1594 | + { |
| 1595 | + cvarRconPassword.GetString(rcon, sizeof(rcon)); |
| 1596 | + } |
| 1597 | + } |
| 1598 | + |
| 1599 | + FormatEx(query, sizeof(query), "INSERT INTO %s_servers (ip, port, rcon, modid) VALUES ('%s', '%s', '%s', (SELECT mid FROM %s_mods WHERE modfolder = '%s'))", DatabasePrefix, ServerIp, ServerPort, rcon, DatabasePrefix, desc); |
1586 | 1600 | db.Query(ErrorCheckCallback, query);
|
1587 | 1601 | }
|
1588 | 1602 | }
|
@@ -2236,7 +2250,8 @@ public SMCResult ReadConfig_KeyValue(SMCParser smc, const char[] key, const char
|
2236 | 2250 | }
|
2237 | 2251 | else if (strcmp("AutoAddServer", key, false) == 0)
|
2238 | 2252 | {
|
2239 |
| - AutoAdd = StringToInt(value) == 1; |
| 2253 | + int sAutoAdd = StringToInt(value); |
| 2254 | + AutoAdd = (sAutoAdd < 0 || sAutoAdd > 2) ? 0 : sAutoAdd; |
2240 | 2255 | }
|
2241 | 2256 | else if (strcmp("Unban", key, false) == 0)
|
2242 | 2257 | {
|
@@ -2645,7 +2660,7 @@ stock void InsertServerInfo()
|
2645 | 2660 | FormatEx(ServerIp, sizeof(ServerIp), "%d.%d.%d.%d", pieces[0], pieces[1], pieces[2], pieces[3]);
|
2646 | 2661 | CvarPort.GetString(ServerPort, sizeof(ServerPort));
|
2647 | 2662 |
|
2648 |
| - if (AutoAdd != false) { |
| 2663 | + if (AutoAdd != AUTO_ADD_SERVER_DISABLED) { |
2649 | 2664 | FormatEx(query, sizeof(query), "SELECT sid FROM %s_servers WHERE ip = '%s' AND port = '%s'", DatabasePrefix, ServerIp, ServerPort);
|
2650 | 2665 | DB.Query(ServerInfoCallback, query);
|
2651 | 2666 | }
|
|
0 commit comments