1. Си / Говнокод #25766

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    case 1342:
    	    {
    	        if(!response) return true;
    	        //ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    	        switch(listitem)
    	        {
    				case 0:
    				{
                        //if(!IsAtFishPlace(playerid)) return SendClientMessage(playerid,0x81DA99AA,"Вы должны находиться возле причала");
    	   				if(!GetPVarInt(playerid,"fish_began"))
    	   				{
    	   				    if(!GetPVarInt(playerid,"fish_rod")) return SendClientMessage(playerid,0x81DA99AA,"У вас нет удочки");
    				    	if(!GetPVarInt(playerid,"fish_gear")) return SendClientMessage(playerid,0x81DA99AA,"У вас нет снастей");
    				    	if(!GetPVarInt(playerid,"fish_worms")) return SendClientMessage(playerid,0x81DA99AA,"У вас нет червей");
    	   				    UpdateFish(playerid);
    	   				    PlayerTextDrawShow(playerid,FishingText[playerid]);
    	   				    SetPlayerAttachedObject(playerid, 0,18632,6,0.079376,0.037070,0.007706,181.482910,0.000000,0.000000,1.000000,1.000000,1.000000);
    				   		SetPVarInt(playerid,"fish_began",1);
    				   		DeletePVar(playerid,"fish_time");
    						DeletePVar(playerid,"fish_ready");
    					}
    					else
    					{
    					    //if(ribachit[playerid] == 1) return SendClientMessage(playerid,0x81DA99AA,"В данный момент нельзя завершить рыбалку");
                            RemovePlayerAttachedObject(playerid,0);
                            DeletePVar(playerid,"fish_began");
                            DeletePVar(playerid,"fish_ready");
                            DeletePVar(playerid,"fish_time");
                            ClearAnimations(playerid);
                            PlayerTextDrawHide(playerid,FishingText[playerid]);
    					}
    				}
    				case 1:
    				{
    				    if(!IsPlayerInRangeOfPoint(playerid, 25,1957.3359,206.6625,30.5146) && !IsPlayerInRangeOfPoint(playerid, 25,10.2461,-85.6648,3.1094) &&
    					!IsPlayerInRangeOfPoint(playerid, 25,-200.7619,6.3196,3.1094) && !IsPlayerInRangeOfPoint(playerid, 25,-1120.5344,-997.0002,129.2188) && !IsPlayerInRangeOfPoint(playerid, 25,-224.8588,-1363.7963,7.2658)) return SendClientMessage(playerid,0x81DA99AA,"Неудачное место для поиска");
    					if(random(2) == 1) ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 6.1, 0, 0, 0, 0, 0,1),  SetPVarInt(playerid,"fish_worms",GetPVarInt(playerid,"fish_worms")+10), SendClientMessage(playerid,0x81DA99AA,"Вы нашли 10 червей!"), ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    					else return ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 6.1, 0, 0, 0, 0, 0,1), SendClientMessage(playerid,0x81DA99AA,"Вы ничего не нашли"), ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    				}
    				case 2:
    				{
    				    if(PTEMP[playerid][pFishesPach] >= 25) return SendClientMessage(playerid,0x81DA99AA,"У вас 25 / 25 пачек рыбы");
    				    if(PTEMP[playerid][pFishes] < 20) return SendClientMessage(playerid,0x81DA99AA,"Для создания требуется 20 кг. рыбы");
    				    PTEMP[playerid][pFishesPach]++;
    				    PTEMP[playerid][pFishes]-=float(20);
    				    SendMes(playerid,0x81DA99AA,"Вы приготовили рыбу. У вас %i / 25 пачек.",PTEMP[playerid][pFishesPach]);
    				    ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    				}
    				case 3:
    				{
                        if(PTEMP[playerid][pFishesPach] < 1) return SendClientMessage(playerid,0x81DA99AA,"Недостаточно рыбы");
                        PTEMP[playerid][pFishesPach]--;
                        PTEMP[playerid][pSatiety]=100;
                        SendMes(playerid,0x81DA99AA,"«Сытость» пополнена до 100. У вас %i / 25 пачек.",PTEMP[playerid][pFishesPach]);
                        ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    				}
    				case 4:
    				{
    				    for(new i = 1; i <= TotalBizz; i++)
    					{
    						if(PTEMP[playerid][pFishes] < 2) return SendClientMessage(playerid,0x81DA99AA,"Недостаточно рыбы");
    						if (PlayerToPoint(10, playerid,BizzInfo[i][bBarX], BizzInfo[i][bBarY], BizzInfo[i][bBarZ]) && BizzInfo[i][bType] == 2 && GetPlayerVirtualWorld(playerid) == BizzInfo[i][bVirtualWorld])
    						{
    							PTEMP[playerid][pCash] +=floatround(PTEMP[playerid][pFishes])*5;
    							if(BizzInfo[i][bProducts]+floatround(PTEMP[playerid][pFishes]) < 2000) BizzInfo[i][bProducts]+=floatround(PTEMP[playerid][pFishes]);
    							else BizzInfo[i][bProducts]=2000;
    							format(YCMDstr,sizeof(YCMDstr), "Вы продали %.1f кг. рыбы. Выручка: %i вирт",PTEMP[playerid][pFishes],floatround(PTEMP[playerid][pFishes]));
    							SendClientMessage(playerid,0x81DA99AA,YCMDstr);
    							PTEMP[playerid][pFishes] = 0;
    							ShowPlayerDialogEx(playerid,1342,DIALOG_STYLE_LIST, "Рыбалка","Начать / Закончить рыбалку\nНакопать червей\nПриготовить рыбу\nСъесть рыбу\nПродать рыбу\nИнформация\nПомощь", "Выбор", "Выход");
    							break;
    						}
    					}
    				}

    И так ещё 2мб кода. Кому интересно глянуть полный перл - добро пожаловать на пастбин https://pastebin.com/JCyBWUVy. Язык - обрубок C для неумеющих в управление памятью, который называется Small. Сам кусок перла - часть хайлоад проекта с 1000 игроков онлайн одновременно(http://samp-rp.ru).

    monobogdan, 16 Августа 2019

    Комментарии (54)
  2. PHP / Говнокод #25764

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $products = $this->cart->getProducts();
    foreach ($products as $product) {
    	$product_total = 0;
    	foreach ($products as $product_2) {
    		if ($product_2['product_id'] == $product['product_id']) {
    			$product_total += $product_2['quantity'];
    		}
    	}
    ....
    }

    Поечему опенкарт так странно вычисляет количество товаров в корзине? неужели нет способа изящней?

    pseudoJun, 14 Августа 2019

    Комментарии (23)
  3. PHP / Говнокод #25763

    0

    1. 1
    2. 2
    list($msec, $sec) = explode(chr(32), microtime()); // время запуска скрипта
    $conf['headtime'] = $sec + $msec;

    Stallman, 12 Августа 2019

    Комментарии (16)
  4. Куча / Говнокод #25762

    0

    1. 1
    IT Оффтоп #18

    #1: http://govnokod.ru/18142 https://govnokod.xyz/_18142
    #2: http://govnokod.ru/18378 https://govnokod.xyz/_18378
    #3: http://govnokod.ru/19667 https://govnokod.xyz/_19667
    #4: http://govnokod.ru/21160 https://govnokod.xyz/_21160
    #5: http://govnokod.ru/21772 https://govnokod.xyz/_21772
    #6: http://govnokod.ru/24063 (потёр пидор сракер) https://govnokod.xyz/_24063
    #7: http://govnokod.ru/24538 https://govnokod.xyz/_24538
    #8: http://govnokod.ru/24815 (потёр пидор сракер) https://govnokod.xyz/_24815
    #9: http://govnokod.ru/24867 https://govnokod.xyz/_24867
    #10: http://govnokod.ru/25328 https://govnokod.xyz/_25328
    #11: https://govnokod.xyz/_25436 http://govnokod.ru/25436 (потёр пидор сракер)
    #12: https://govnokod.xyz/_25471
    #13: https://govnokod.xyz/_25590 (потёр пидор сракер)
    #14: https://govnokod.xyz/_25684
    #15: https://govnokod.xyz/_25694
    #16: https://govnokod.xyz/_25725
    #17: https://govnokod.xyz/_25731/

    syoma, 12 Августа 2019

    Комментарии (567)
  5. Куча / Говнокод #25761

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    # сие есть AWK
            format = $2
            sub(/-.+$/, "", format)
            sub(/^.+?:[ \t]?/, "")
            output_format[format] = $0

    Какая падла придумала эту функцию?

    petux, 10 Августа 2019

    Комментарии (89)
  6. PHP / Говнокод #25760

    0

    1. 1
    Есть ли какие-нибудь соревнования для PHP разработчиков?

    Perevedi_na_PHP, 09 Августа 2019

    Комментарии (31)
  7. PHP / Говнокод #25759

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    switch($ext) {
            case 'bmp':
            case 'BMP':
                $img = imagecreatefrombmp($file_name);
                break;
            case 'gif':
            case 'GIF';
                $img = imagecreatefromgif($file_name);
                break;
            case 'JPG'
            case 'jpg':
            case 'JPEG':
            case 'jpeg':
                $img = imagecreatefromjpeg($file_name);
                break;
            
            case 'PNG':
            case 'png':
                $img = imagecreatefrompng($file_name);
                break;
        }

    Сойдет.

    OlegUP, 09 Августа 2019

    Комментарии (35)
  8. JavaScript / Говнокод #25758

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    // где-то в классе MyTable
    
    public next() {
      if (this.firstVisibleRow + this.currentRow < this.sortedData.length) {
        this.firstVisibleRow = this.firstVisibleRow + this.currentRow;
      }
      this.sortTable();
    }
    
    public prev() {
      if (this.firstVisibleRow - this.currentRow > 0) {
        this.firstVisibleRow = this.firstVisibleRow - this.currentRow;
      } else {
        this.firstVisibleRow = 0;
      }
      this.sortTable();
    }
    
    public sortTable() {
      this.sortedData.forEach((item, index) => {
        for (let i = this.firstVisibleRow; i < (this.firstVisibleRow + this.currentRow); i++) {
          if (i === index) {
            this.visiblilityList[index] = true;
    
            return;
          }
        }
        this.visiblilityList[index] = false;
      });
    }

    Коллега не прекращает удивлять )
    Код компонента Таблица для Vue.
    Кажется, в этом коде прекрасно всё.
    Обратите внимание, как красиво выполняется метод sortTable.
    Здесь visiblilityList используется для определения какие ряды в таблице нужно рисовать при пагинации. Про существование переменных page и rowsPerPage не слышал.
    Удивительно, но это говно работает!
    Планируем нашему коллеге по итогам года подарить грамоту "Качественный говнокод года" )

    igpo, 09 Августа 2019

    Комментарии (6)
  9. JavaScript / Говнокод #25757

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    function sortWithIndeces(toSort: any) {
      for (let i = 0; i < toSort.length; i++) {
        toSort[i] = [toSort[i], i];
      }
      toSort.sort(function(left: any[], right: any[]) {
        return left[0] < right[0] ? -1 : 1;
      });
      toSort.sortIndices = [];
      for (let j = 0; j < toSort.length; j++) {
        toSort.sortIndices.push(toSort[j][1]);
        toSort[j] = toSort[j][0];
      }
    
      return toSort;
    }
    
    sortWithIndeces(arr);
    
    arr.sortIndices.forEach((item: any, index: number) => {
      result[index] = data[item];
    });

    Нашёл в гите у нас на проекте этот божественный код )
    Сортировка выглядит так, ни одного коммента в коде.
    В ходе анализа стало понятно что таким образом автор пытался восстановить порядок сортировки.

    igpo, 09 Августа 2019

    Комментарии (24)
  10. PHP / Говнокод #25755

    0

    1. 1
    Как так получается, что после json_encode($massiv) у меня то "{}", то "[]"?

    OCETuHCKuu_nemyx, 08 Августа 2019

    Комментарии (27)