@@ -1334,10 +1334,11 @@ public void Query_UnBlockSelect(Database db, DBResultSet results, const char[] e
1334
1334
dataPack .Reset ();
1335
1335
int adminUserID = dataPack .ReadCell ();
1336
1336
int targetUserID = dataPack .ReadCell ();
1337
- int type = dataPack .ReadCell (); // not in use unless DEBUG
1337
+ int type = dataPack .ReadCell ();
1338
1338
dataPack .ReadString (adminAuth , sizeof (adminAuth ));
1339
1339
dataPack .ReadString (targetAuth , sizeof (targetAuth ));
1340
1340
dataPack .ReadString (reason , sizeof (reason ));
1341
+ delete dataPack ;
1341
1342
1342
1343
int admin = GetClientOfUserId (adminUserID );
1343
1344
int target = GetClientOfUserId (targetUserID );
@@ -1355,7 +1356,8 @@ public void Query_UnBlockSelect(Database db, DBResultSet results, const char[] e
1355
1356
if (DB_Conn_Lost (results ) || error [0 ] != ' \0 ' )
1356
1357
{
1357
1358
LogError (" Query_UnBlockSelect failed: %s " , error );
1358
- if (admin && IsClientInGame (admin ))
1359
+
1360
+ if (admin )
1359
1361
{
1360
1362
PrintToChat (admin , " %s%T " , PREFIX , " Unblock Select Failed" , admin , targetAuth );
1361
1363
PrintToConsole (admin , " %s%T " , PREFIX , " Unblock Select Failed" , admin , targetAuth );
@@ -1364,13 +1366,13 @@ public void Query_UnBlockSelect(Database db, DBResultSet results, const char[] e
1364
1366
{
1365
1367
PrintToServer (" %s%T " , PREFIX , " Unblock Select Failed" , LANG_SERVER , targetAuth );
1366
1368
}
1369
+
1367
1370
hasErrors = true ;
1368
1371
}
1369
-
1370
- // If there was no results then a ban does not exist for that id
1371
- if (! DB_Conn_Lost (results ) && ! results .RowCount )
1372
+ // If there were no results then a ban does not exist for that id
1373
+ else if (! results .RowCount )
1372
1374
{
1373
- if (admin && IsClientInGame ( admin ) )
1375
+ if (admin )
1374
1376
{
1375
1377
PrintToChat (admin , " %s%t " , PREFIX , " No blocks found" , targetAuth );
1376
1378
PrintToConsole (admin , " %s%t " , PREFIX , " No blocks found" , targetAuth );
@@ -1379,6 +1381,7 @@ public void Query_UnBlockSelect(Database db, DBResultSet results, const char[] e
1379
1381
{
1380
1382
PrintToServer (" %s%T " , PREFIX , " No blocks found" , LANG_SERVER , targetAuth );
1381
1383
}
1384
+
1382
1385
hasErrors = true ;
1383
1386
}
1384
1387
@@ -1388,8 +1391,10 @@ public void Query_UnBlockSelect(Database db, DBResultSet results, const char[] e
1388
1391
PrintToServer (" Calling TempUnBlock from Query_UnBlockSelect" );
1389
1392
#endif
1390
1393
1391
- TempUnBlock (dataPack ); // Datapack closed inside.
1392
- return ;
1394
+ if (target )
1395
+ {
1396
+ TempUnBlock (admin , target , type , adminAuth , targetAuth , reason );
1397
+ }
1393
1398
}
1394
1399
else
1395
1400
{
@@ -1422,12 +1427,13 @@ public void Query_UnBlockSelect(Database db, DBResultSet results, const char[] e
1422
1427
#endif
1423
1428
1424
1429
// Checking - has we access to unblock?
1425
- if (iAID == cAID || ( ! admin && StrEqual ( adminAuth , " STEAM_ID_SERVER " )) || AdmHasFlag (admin ) || (DisUBImCheck == 0 && (GetAdmImmunity (admin ) > cImmunity )))
1430
+ if (iAID == cAID || ! adminUserID || AdmHasFlag (admin ) || (DisUBImCheck == 0 && (GetAdmImmunity (admin ) > cImmunity )))
1426
1431
{
1427
1432
// Ok! we have rights to unblock
1428
1433
b_success = true ;
1434
+
1429
1435
// UnMute/UnGag, Show & log activity
1430
- if (target && IsClientInGame ( target ) )
1436
+ if (target )
1431
1437
{
1432
1438
switch (cType )
1433
1439
{
@@ -1499,7 +1505,7 @@ public void Query_UnBlockSelect(Database db, DBResultSet results, const char[] e
1499
1505
}
1500
1506
}
1501
1507
1502
- if (b_success && target && IsClientInGame ( target ) )
1508
+ if (b_success && target )
1503
1509
{
1504
1510
#if defined DEBUG
1505
1511
PrintToServer (" Showing activity to server in Query_UnBlockSelect" );
@@ -1509,25 +1515,17 @@ public void Query_UnBlockSelect(Database db, DBResultSet results, const char[] e
1509
1515
if (type == TYPE_UNSILENCE )
1510
1516
{
1511
1517
// check result for possible combination with temp and time punishments (temp was skipped in code above)
1512
-
1513
- dataPack .Position = view_as <DataPackPos >(16 );
1514
-
1515
1518
if (g_MuteType [target ] > bNot )
1516
1519
{
1517
- dataPack .WriteCell (TYPE_UNMUTE );
1518
- TempUnBlock (dataPack );
1520
+ TempUnBlock (admin , target , TYPE_UNMUTE , adminAuth , targetAuth , reason );
1519
1521
}
1520
1522
else if (g_GagType [target ] > bNot )
1521
1523
{
1522
- dataPack .WriteCell (TYPE_UNGAG );
1523
- TempUnBlock (dataPack );
1524
+ TempUnBlock (admin , target , TYPE_UNGAG , adminAuth , targetAuth , reason );
1524
1525
}
1525
1526
}
1526
1527
}
1527
1528
}
1528
-
1529
- if (dataPack != null )
1530
- delete dataPack ;
1531
1529
}
1532
1530
1533
1531
public void Query_UnBlockUpdate (Database db , DBResultSet results , const char [] error , DataPack dataPack )
@@ -2467,18 +2465,18 @@ stock void ProcessUnBlock(int client, int targetId = 0, int type, char[] sReason
2467
2465
}
2468
2466
}
2469
2467
2470
- // Pack everything into a data pack so we can retain it
2471
- DataPack dataPack = new DataPack ();
2472
- dataPack .WriteCell (GetClientUserId2 (client ));
2473
- dataPack .WriteCell (GetClientUserId (target ));
2474
- dataPack .WriteCell (type );
2475
- dataPack .WriteString (adminAuth );
2476
- dataPack .WriteString (targetAuth );
2477
- dataPack .WriteString (reason );
2478
-
2479
- // Check current player status. If player has temporary punishment - don't get info from DB
2468
+ // Check current player status. If player has temporary punishment - don't get info from DB.
2480
2469
if (DB_Connect ())
2481
2470
{
2471
+ // Pack everything into a data pack so we can retain it
2472
+ DataPack dataPack = new DataPack ();
2473
+ dataPack .WriteCell (GetClientUserId2 (client ));
2474
+ dataPack .WriteCell (GetClientUserId (target ));
2475
+ dataPack .WriteCell (type );
2476
+ dataPack .WriteString (adminAuth );
2477
+ dataPack .WriteString (targetAuth );
2478
+ dataPack .WriteString (reason );
2479
+
2482
2480
char sAdminAuthEscaped [sizeof (adminAuth ) * 2 + 1 ];
2483
2481
char sAdminAuthYZEscaped [sizeof (adminAuth ) * 2 + 1 ];
2484
2482
char sTargetAuthEscaped [sizeof (targetAuth ) * 2 + 1 ];
@@ -2517,35 +2515,18 @@ stock void ProcessUnBlock(int client, int targetId = 0, int type, char[] sReason
2517
2515
PrintToServer (" Calling TempUnBlock from ProcessUnBlock" );
2518
2516
#endif
2519
2517
2520
- if (TempUnBlock (dataPack ))
2518
+ if (TempUnBlock (client , target , type , adminAuth , targetAuth , reason ))
2521
2519
ShowActivityToServer (client , type + TYPE_TEMP_SHIFT , _ , _ , g_sName [target ], _ );
2522
2520
}
2523
2521
}
2524
2522
}
2525
2523
2526
- stock bool TempUnBlock (DataPack dataPack )
2524
+ stock bool TempUnBlock (const int admin , const int target , const int type , const char [] adminAuth , const char [] targetAuth , const char [] reason )
2527
2525
{
2528
- char adminAuth [30 ], targetAuth [30 ];
2529
- char reason [256 ];
2530
-
2531
- dataPack .Reset ();
2532
- int adminUserID = dataPack .ReadCell ();
2533
- int targetUserID = dataPack .ReadCell ();
2534
- int type = dataPack .ReadCell ();
2535
- dataPack .ReadString (adminAuth , sizeof (adminAuth ));
2536
- dataPack .ReadString (targetAuth , sizeof (targetAuth ));
2537
- dataPack .ReadString (reason , sizeof (reason ));
2538
- delete dataPack ; // Need to close datapack
2539
-
2540
2526
#if defined DEBUG
2541
- PrintToServer (" TempUnBlock(adminUID : %d , targetUID : %d , type: %d , adminAuth: %s , targetAuth: %s , reason: %s )" , adminUserID , targetUserID , type , adminAuth , targetAuth , reason );
2527
+ PrintToServer (" TempUnBlock(admin : %u , target : %u , type: %d , adminAuth: %s , targetAuth: %s , reason: %s )" , admin , target , type , adminAuth , targetAuth , reason );
2542
2528
#endif
2543
2529
2544
- int admin = GetClientOfUserId (adminUserID );
2545
- int target = GetClientOfUserId (targetUserID );
2546
- if (! target )
2547
- return false ; // target has gone away
2548
-
2549
2530
int AdmImmunity = GetAdmImmunity (admin );
2550
2531
bool AdmImCheck = (DisUBImCheck == 0
2551
2532
&& ((type == TYPE_UNMUTE && AdmImmunity >= g_iMuteLevel [target ])
@@ -2564,7 +2545,7 @@ stock bool TempUnBlock(DataPack dataPack)
2564
2545
#endif
2565
2546
2566
2547
// Check access for unblock without db changes (temporary unblock)
2567
- bool bHasPermission = ( ! admin && StrEqual ( adminAuth , " STEAM_ID_SERVER " )) || AdmHasFlag (admin ) || AdmImCheck ;
2548
+ bool bHasPermission = ! admin || AdmHasFlag (admin ) || AdmImCheck ;
2568
2549
// can, if we are console or have special flag. else - deep checking by issuer authid
2569
2550
if (! bHasPermission ) {
2570
2551
switch (type )
0 commit comments