1. C# / Говнокод #17166

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    void _device_ChangeStsConnect(bool Conn)								
    {
    	switch (Conn)
    	{
    		case true: Start(); break;
    		case false: Stop(); break;
    		default: break;
    	}
    }

    "Классический" switch булевой переменной.

    Qetu107, 25 Ноября 2014

    Комментарии (16)
  2. Pascal / Говнокод #17165

    +88

    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
    function TCalc.getRewardItems(items : AnsiString; countItems : integer; userId : Integer; from:integer) : ISuperObject;
    var tmpFirstOdds : integer;
        strLines, extrLines : TStringList;
        strItems, strOdds, strOdds2: TIntegerList;
        i, j, tmpCountItems : integer;
        tmpOddsItems, sum : Integer;
        str: ansistring;
    begin
      Result := nil;
    
      // parse items line [id1,odd1],[id2,odd2],[id3,odd3]
      strLines := TStringList.Create;
      extrLines := TStringList.Create;
      strItems := TIntegerList.Create;
      strOdds := TIntegerList.Create;
      ExtractStrings(['[', ']'],[','], PChar(items), strLines);
      for i := 0 to strLines.Count - 1 do
      begin
        ExtractStrings([','],[' '], PChar(strLines[i]), extrLines);
        strItems.Add(StrToInt(extrLines[0]));
        strOdds.Add(StrToInt(extrLines[1]));
        extrLines.Clear;
      end;
    
      // calculate odds [a,b,c,d] as [a,a+b,a+b+c,a+b+c+d]
      sum := 0;
      strOdds2 := TIntegerList.Create;
      for i := 0 to strOdds.Count-1 do
      begin
        sum := sum + strOdds.Items[i];
        strOdds2.Add(sum);
      end;
    
      // select items
      str := '';
      for i := 0 to countItems - 1 do
      begin
        tmpFirstOdds := Random(101); // 0-100
        for j := 0 to strOdds2.Count-1 do
        begin
          if tmpFirstOdds < strOdds2.Items[j] then
          begin
            str := str + IntToStr(strItems[j]) + ',';
            break;
          end;
        end;
      end;
      str := '['+Copy(str,1,Length(str)-1)+']';
      // from monster
      if from=0 then Result := so('{"part":"battle","func":"itemsdropped","data":'+str+'}');
      // from chest
      if from=1 then Result := so('{"part":"battle","func":"itemsdroppedchest","data":'+str+'}');
      strLines.Free;
      extrLines.Free;
      strItems.Free;
      strOdds.Free;
      strOdds2.Free;
    end;

    У меня чуть глаза не вытекли от такого решения. Код по идее сообщает клиенту, что выпало из монстра после победы над ним.

    Cynicrus, 24 Ноября 2014

    Комментарии (1)
  3. JavaScript / Говнокод #17163

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function updateClock()
    {
        var date = new Date();
        var day = date.getDate();
        var month = date.getMonth() + 1;
        var year = date.getFullYear();
        var hours = date.getHours();
        var minutes = date.getMinutes();
        var seconds = date.getSeconds();
        var dateTimeString = day + "." + month + "." + year + " " + hours + ":" + minutes + ":" + seconds;
        $('#clock').html("Сейчас " + dateTimeString);
    }

    Трибьют классике.

    pushistayapodmyshka, 24 Ноября 2014

    Комментарии (45)
  4. Pascal / Говнокод #17162

    +94

    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
    function TMyDb.getUserItemsINTOMarkt(userid: Int64; marktid: String): SOString;
    var
      Query : TZQuery;
    begin
     Result := '';
     try
     lock;
     Query := TZQuery.Create(nil);
     if not isConnected() then
            connect();
       Query.Connection := SQLCon;
          Query.SQL.TEXT:='SELECT mi.markt_id, mi.price, mi.item_id,ui.used_limit,'+
                               'ui.max_limit,ui.inv_id,ui.inv_min_damage, ui.inv_max_damage,'+
                               'ui.inv_options,ui.inv_bonuses,ui.inv_mods,ui.modifed,'+
                               'i.name FROM bkheroes.markt_items mi '+
                               'JOIN user_inventory ui ON mi.user_id='+IntToStr(userid)+' AND '+
                               'mi.user_inv_id=ui.inv_id AND mi.markt_id='''+marktid+
                              ''' AND ui.userSellItem=''yes'' JOIN items i ON i.id=mi.item_id';
    
       if SQLCon.Connected = True then
      begin
        Query.Open;
        if Query.RecordCount > 0 then
        begin
          while not Query.EOF do
          begin
              Result := Result+'{"marktid":'+Query.FieldByName('markt_id').AsString+
                        ',"inv_id":'+Query.FieldByName('inv_id').AsString+
                        ',"price":'+Query.FieldByName('price').AsString+
                        ',"itemid":'+Query.FieldByName('item_id').AsString+
                        ',"used_limit":'+Query.FieldByName('used_limit').AsString+
                        ',"max_limit":'+Query.FieldByName('max_limit').AsString+
                        ',"min_damage":'+Query.FieldByName('inv_min_damage').AsString+
                        ',"max_damage":'+Query.FieldByName('inv_max_damage').AsString+
                        ',"options":'+explodeParams(query.FieldByName('inv_options').AsString,',',':').AsString+
                        ',"bonuses":'+explodeParams(Query.FieldByName('inv_bonuses').AsString,',',':').AsString+
                        ',"mods":'+explodeParams(Query.FieldByName('inv_mods').AsString,',',':').AsString+
                        ',"modifed":"'+Query.FieldByName('modifed').AsString+
                        '","name":"'+Query.FieldByName('name').AsString+'"},';
              query.Next;
          end;
        end;
      Result:='{"marktid":'+marktid+',"items":['+Copy(Result,1,Length(Result)-1)+']}';
      end;
      TLogger.GeneralLog('getUserItemsINTOMarkt: '+Result,'TMyDBUnit',ltTrace);
      finally
      Query.Close;
      Query.Free;
      unlock;
      end;
    end;

    О боже! Как можено такое писать за деньги? Да вообще, как можно писать такое??

    Cynicrus, 24 Ноября 2014

    Комментарии (26)
  5. C# / Говнокод #17161

    +135

    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
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    public void ValidateValue( ref object value ) {
                bool b;
                if ( value == null ) return;
                var typeName = BaseType.Name;
                var valueType = value.GetType();
                if ( valueType.Name == "String" ) {
                    if ( BaseType == valueType ) return;
                    if ( BaseType == Constants.Types.Boolean ) {
                        if ( string.Compare( "yes", (string) value, StringComparison.OrdinalIgnoreCase ) == 0 ) value = true;
                        else if ( string.Compare( "no", (string) value, StringComparison.OrdinalIgnoreCase ) == 0 ) value = false;
    #if !CF
                        else if ( Boolean.TryParse( value.ToString(), out b ) ) value = b;
    #else
              else if (TryParseUtility.TryParse(value.ToString(), out b)) value = b;
    #endif
                        else throw new ArgumentException( String.Format( Resources.ValueNotCorrectType, value ) );
                        return;
                    }
                }
    
    #if !CF
                if ( typeName == "Boolean"
                     && Boolean.TryParse( value.ToString(), out b ) ) {
                    value = b;
                    return;
                }
    
                UInt64 uintVal;
                if ( typeName.StartsWith( "UInt64" )
                     && UInt64.TryParse( value.ToString(), out uintVal ) ) {
                    value = uintVal;
                    return;
                }
    
                UInt32 uintVal32;
                if ( typeName.StartsWith( "UInt32" )
                     && UInt32.TryParse( value.ToString(), out uintVal32 ) ) {
                    value = uintVal32;
                    return;
                }
    
                long intVal;
                if ( typeName.StartsWith( "long" )
                     && long.TryParse( value.ToString(), out intVal ) ) {
                    value = intVal;
                    return;
                }
    
                int intVal32;
                if ( typeName.StartsWith( "Int32" )
                     && Int32.TryParse( value.ToString(), out intVal32 ) ) {
                    value = intVal32;
                    return;
                }
    #else
          if (typeName == "Boolean" && TryParseUtility.TryParse(value.ToString(), out b)) { value = b; return; }
    
          UInt64 uintVal;
          if (typeName.StartsWith("UInt64") && TryParseUtility.TryParse(value.ToString(), out uintVal)) { value = uintVal; return; }
    
          UInt32 uintVal32;
          if (typeName.StartsWith("UInt32") && TryParseUtility.TryParse(value.ToString(), out uintVal32)) { value = uintVal32; return; }
    
          long intVal;
          if (typeName.StartsWith("long") && TryParseUtility.TryParse(value.ToString(), out intVal)) { value = intVal; return; }
    
          Int32 intVal32;
          if (typeName.StartsWith("Int32") && TryParseUtility.TryParse(value.ToString(), out intVal32)) { value = intVal32; return; }
    #endif
    
                object objValue;
    #if RT
          Type baseType = BaseType.GetTypeInfo().BaseType;
    #else
                var baseType = BaseType.BaseType;
    #endif
                if ( baseType != null
                     && baseType.Name == "Enum"
                     && ParseEnum( value.ToString(), out objValue ) ) {
                    value = objValue;
                    return;
                }
    
                throw new ArgumentException( String.Format( Resources.ValueNotCorrectType, value ) );
            }

    MySql.Data 6.9.5, MySqlConnectionStringBuilder.cs

    kasthack, 24 Ноября 2014

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

    +161

    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
    function getGeneralOfficesStats(&$stats_year, &$stats_office_logo, &$stats_quant_client, &$stats_summ_client, &$stats_summ_supplier, &$stats_summ_delivery, &$stats_without_complex_price, &$quant_position, &$top_quant_client, &$top_summ_client, &$top_summ_supplier, &$top_summ_delivery, &$top_stats_without_complex_price, &$top_quant_position, $date_start_time=0, $date_end_time=0, $office_logo="")
       {
         $sql="SELECT t1.month, t1.year, t1.office_logo, t1.quant_client, t1.summ_client, t1.summ_supplier, 
    	       t1.summ_delivery, t1.stats_without_complex_price,
               t1.quant_position, t1.top_quant_client, t1.top_summ_client, 
               t1.top_summ_supplier, t1.top_summ_delivery, t1.top_stats_without_complex_price, t1.top_quant_position
    	       FROM stats_offices AS t1
    	       INNER JOIN offices AS t2 ON t1.office_logo=t2.name AND t1.currency_logo=t2.currency
    	       WHERE 1=1
    	       ".(($date_start_time>0 && $date_end_time>0)?" AND STR_TO_DATE(CONCAT(t1.year,'-',IF(LENGTH(t1.month)=1,'0',''),t1.month,'-01 01:01:01'), '%Y-%m-%d %H:%i:%s') BETWEEN STR_TO_DATE('".date("Y-m-01 00:00:00",$date_start_time)."', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE('".date("Y-m-d 23:59:59",$date_end_time)."', '%Y-%m-%d %H:%i:%s') ":"")."
    	       ".((!empty($office_logo))?" AND t1.office_logo='".mysql_escape_string($office_logo)."' ":"")."
    	       ORDER BY t1.office_logo, t1.year DESC, t1.month DESC";	
    	 list($stats_month, $stats_year, $stats_office_logo, $stats_quant_client, $stats_summ_client, $stats_summ_supplier, $stats_summ_delivery, $stats_without_complex_price, $quant_position, $top_quant_client, $top_summ_client, $top_summ_supplier, $top_summ_delivery, $top_stats_without_complex_price, $top_quant_position)=$this->query($sql);
    	 return $stats_month;   
       }

    Сменил работу. Стал знакомится с кодом. Тихо охуеваю.

    Vasiliy, 24 Ноября 2014

    Комментарии (29)
  7. JavaScript / Говнокод #17159

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    formatDate: function (oSignDate) {
      "use strict";
      return oSignDate.getFullYear().toString() + (1 + oSignDate.getMonth()).toString() + oSignDate.getDate().toString() + "T" + oSignDate.getHours().toString() + oSignDate.getMinutes().toString() + oSignDate.getSeconds().toString() + (oSignDate.getTimezoneOffset() > 0 ? "-" : "+") + ("0000" + (-1 * oSignDate.getTimezoneOffset() / 60) * 100).toString().substr(-4, 4);
    }

    Представление даты в формате YYYYMMDDThhmmss±hhmm

    Yaruson, 24 Ноября 2014

    Комментарии (8)
  8. C++ / Говнокод #17158

    +51

    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
    std::list<COptions *> COptions::m_InstanceList;
    ..........
    COptions::COptions()
    {
    	for (int i = 0; i < OPTIONS_NUM; ++i)
    		m_OptionsCache[i].bCached = FALSE;
    	m_pOptionsHelperWindow = new COptionsHelperWindow(this);
    	simple_lock lock(m_mutex);
    #ifdef _DEBUG
    	for (std::list<COptions *>::iterator iter=m_InstanceList.begin(); iter != m_InstanceList.end(); ++iter)
    		ASSERT(*iter != this);
    #endif _DEBUG
    	m_InstanceList.push_back(this);
    	m_SpeedLimits[0] = m_sSpeedLimits[0];
    	m_SpeedLimits[1] = m_sSpeedLimits[1];
    }
    
    COptions::~COptions()
    {
    	{
    		simple_lock lock(m_mutex);
    		std::list<COptions *>::iterator iter;
    		for (iter=m_InstanceList.begin(); iter != m_InstanceList.end(); ++iter) {
    			if (*iter == this)
    				break;
    		}
    
    		ASSERT(iter != m_InstanceList.end());
    		if (iter != m_InstanceList.end())
    			m_InstanceList.erase(iter);
    	}
    
    	if (m_pOptionsHelperWindow)
    		delete m_pOptionsHelperWindow;
    	m_pOptionsHelperWindow=0;
    }
    .......

    В отладке включается тяжелый героиновый бред разработчиков FileZilla

    fsmoke, 24 Ноября 2014

    Комментарии (1)
  9. Pascal / Говнокод #17157

    +87

    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
    class function TTransfer.getCreditStateOFCreditPoints(creditPoints:Int64):Integer;
    begin
      Result := 0;
      if (creditPoints>=0) AND (creditPoints <200) then
         begin
              Result := 1;
              exit;
         end;
      if (creditPoints>=200) AND (creditPoints <600) then
         begin
              Result := 2;
              exit;
         end;
      if (creditPoints>=600) AND (creditPoints <1200) then
         begin
              Result := 3;
              exit;
         end;
      if (creditPoints>=1200) AND (creditPoints <2000) then
         begin
              Result := 4;
              exit;
         end;
      if (creditPoints>=2000) AND (creditPoints <3700) then
         begin
              Result := 5;
              exit;
         end;
      if (creditPoints>=3700) AND (creditPoints <7000) then
         begin
              Result := 6;
              exit;
         end;
      if (creditPoints>=7000) AND (creditPoints <15000) then
         begin
              Result := 7;
              exit;
         end;
      if (creditPoints>=15000) AND (creditPoints <25000) then
         begin
              Result := 8;
              exit;
         end;
      if (creditPoints>=25000) AND (creditPoints < 100000) then
         begin
              Result := 9;
              exit;
         end;
      if (creditPoints>=100000) then
         begin
              Result := 10;
              exit;
         end;
    end;

    Типа Ы-нтерпрайз код. Где таких делают только.

    Cynicrus, 24 Ноября 2014

    Комментарии (76)
  10. JavaScript / Говнокод #17156

    +156

    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
    var old = 47;
    
            function getRate() {
                $.ajax({
                      url: "http://query.yahooapis.com/v1/public/yql?q=select%20%2a%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22USDRUB%22%29&env=store://datatables.org/alltableswithkeys",
                      dataType: "text"
                }).done(function(msg) {
                    var value = /<Rate>(.+)<\/Rate>/.exec(msg)[1];
                    //$("#p-rate").html(/<Rate>(.+)<\/Rate>/.exec(msg)[1]);
                    $("#p-rate").html(value);
                    if(value > old) $("#p-message").html("МНЕ ОТ ЭТОГО ТОЛЬКО ЛУЧШЕ! ТОЛЬКО НА ПОЛЬЗУ!");
                    else if(value < old) $("#p-message").html("СКАЛЕН! СКАЛЕН!");
                    else $("#p-message").html("МНОГОХОДОВОЧКА!");
                    old = value;
                });
            }
    
            setInterval(getRate,1500);

    gost, 24 Ноября 2014

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