1. Лучший говнокод

    В номинации:
    За время:
  2. C++ / Говнокод #4863

    +152

    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
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    //CreatorOfBullshit говорит: следите за руками
    void __fastcall TFORM_MENU::pan_newClick(TObject *Sender) //запуск новой игры
    {
      if(fl_sound)sndPlaySound("Data\\Sounds\\push.wav",SND_ASYNC|SND_NODEFAULT);
      tm_showstarthint->Enabled=false;
      pan_cong->Visible=false;
      pan_hider->Visible=false;
      pan_new->Caption="Еще разок";//меняем надпись на кнопке
      pan_new->Hint="Начать новую сборку";
      pan_sign->Color=clBlack;
      lab_timeleft->Caption="00:00";
      lab_timeleft->Hint="...а время течёт, как вода по трубам...";
      tm_gameseconds->Enabled=false; //сначала останавливаем таймер, и после окончания прорисовки стартового поля запускаем его снова
      Label1->Visible=true;
      lab_timeleft->Visible=true;
      game_time_seconds=0;//сброс времени
      game_time_minutes=0;
    
      pb_viewport->Enabled=true;
      for(int i=0;i<128;i++)
      {
        gameplane.recreate();
        if(gameplane.getclosed()<8)
          break;
      }
      game_start_count=gameplane.getclosed();
      gameplane.drawfield();
      lab_per->Caption=IntToStr( (int)( (float)gameplane.getclosed()*100.f/(float)(game_field_width*game_field_height) ) )+"%";
      tm_gameseconds->Enabled=true;  //запускаем таймер
    }
     ...
    //CreatorOfBullshit говорит: "фрагмент из модуля с определениями для класса объекта gameplane" тот самый recreate()
    ...
    void C_GAMEFIELD::recreate()
    {
    /*
      Создаю игровое поле и расположения 
      */
      int i,j;
      for(i=0;i<width;i++)
      {
        for(j=0;j<height;j++)
        {
          pp_field[i][j]=0;
        }//for j
      }//for i
      //определение центральной точки источника воды:
      if( (width&b0001)==0 )
        start_x=(width>>1)-1;
      else
        start_x=(width>>1);
      //_  _  _  _  _  _  _  _  _  _  _  _
      if( (height&b0001)==0 )
        start_y=(height>>1)-1;
      else
        start_y=(height>>1);
      pp_field[start_x][start_y]|=wALWAYSON;//назначение стартовой метки(поднимается флаг)
      crt_crgf();
      checklinkup();
      for(i=0;i<width;i++)for(j=0;j<height;j++)
      {
        pp_mask[i][j]=pp_field[i][j];
      }//for
    }
    ...
    //CreatorOfBullshit говорит: "Теперь проследуем в crt_crgf()"
    void C_GAMEFIELD::crt_crgf() //Соединяет неправильно построеенные трубы 
    { //Проработать мне нужно алгоритм построения!!!
      unsigned __int8 i,j;
      static int brd_right,
                 brd_bottom,
                 bounds;
      crt_setcell(start_x,start_y, TRIPLE);  ///crt_setcell создает трубу, потом тут же ее поворачиваем
      //далее первый шаг построения: сначала создаются совершенно случайные незаконо-
      //мерные ветви, т.е. могут остаться НЕЗАПОЛНЕННЫЕ участки:
      unsigned __int8 startcell=pp_field[start_x][start_y], tryingcell;
      if( (startcell&UP)==UP )
        crt_connect(start_x,start_y-1,DOWN);
      if( (startcell&DOWN)==DOWN )
        crt_connect(start_x,start_y+1,UP);
      if( (startcell&LEFT)==LEFT )
        crt_connect(start_x-1,start_y,RIGHT);
      if( (startcell&RIGHT)==RIGHT )
        crt_connect(start_x+1,start_y,LEFT);
    }
    //CreatorOfBullshit говорит: "Апофеоз говнокодизма - чуть ниже:"
    inline void C_GAMEFIELD::crt_setcell(unsigned __int8 x, unsigned __int8 y, unsigned __int8 pipetype)
    {
      pp_field[x][y]|=pipetype;
      //создаем трубу по заказу и рандумно поворачиваем
      if(random(2))
        rotate_CW(x,y);
      if(random(2))
        rotate_CW(x,y);
      if(random(2))
        rotate_CW(x,y);
    }

    Говнокод написан лично моими руками на первом курсе института. Писал игру в которой нужно поворачивать трубы так чтобы потом по всему игровому полю текла вода. Писал на Буилдере 5.0. Угощайтесь.
    Алсо это не еще не все - там есть фрагмент в котором китайским методом создаются спрайты игровых текстур.
    С:8444

    CreatorOfBullshit, 08 Декабря 2010

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

    +168

    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
    function IsAlphaNumeric($str)
    {
       $old = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
       $new = Array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
       if (str_replace($str, $old, $new) == "")
       {
          return (true);
       }
       else
       {
          return (false);
       }
    }

    говно + валидация = говнодация

    fork, 08 Декабря 2010

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

    +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
    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
    <!-- saved from url=(0014)about:internet -->
    <?php
    define('WEATHER_FILE_3_DAYS', '/meteoparse/weather.xml');
    define('WEATHER_URL_3_DAYS', 'http://pogoda.by/xml2/xml-kstati.by.php');
    define('BASE_PATH', $_SERVER['DOCUMENT_ROOT']);
    define('DAYS_COUNT', 3);
     
    require_once('include/weather_tools.php');
     
    if (date('d.m.Y.h', filectime(BASE_PATH . WEATHER_FILE_3_DAYS)) != date('d.m.Y.h')) {
            copy(WEATHER_URL_3_DAYS, BASE_PATH . WEATHER_FILE_3_DAYS);      
    }
            $file = file_get_contents ('weather.xml');
            $xmlWeather = simplexml_load_string($file);
            $aXmlForecasts = $xmlWeather->xpath('/pogoda/CITY/FORECAST');
            
    $aWeather = array();
    $curDay = 0;
     
    foreach($aXmlForecasts as $xmlForecast) {
            $attrs = $xmlForecast->attributes();
            $date = $attrs->day . '-' .
                    $attrs->month . '-' .
                    $attrs->year;
            $hour = strval($attrs->hour);
            if (!array_key_exists($date, $aWeather)) {
                    $curDay++;
                    if ($curDay > DAYS_COUNT) break;
                    $aWeather[$date] = array();
            }
            if (!array_key_exists($hour, $aWeather[$date])) {
                    $aWeather[$date][$hour] = array();
            }
            foreach($xmlForecast as $property => $values) {
                    $aWeather[$date][$hour][$property] = '';
                    $valuesAttr = $values->attributes();
                    foreach($valuesAttr as $value) {
                            $aWeather[$date][$hour][$property] .= strval($value);
                    }                               
            }
            
    }
    foreach($aWeather as $dateKey => $date) {
            foreach ($date as $hourKey => $hour) {
                    $aWeather[$dateKey][$hourKey]['DAYTIME'] = getDayTime($hourKey);
                    $aWeather[$dateKey][$hourKey]['PHENOMENA'] = getPhenomeaUrl($hour['PHENOMENA']);
                    $aWeather[$dateKey][$hourKey]['WIND'] = getWind($hour['WIND']);
            }
    }
    ?>
                    <td colspan="<?php echo count($aWeather); ?>">
                            <?php foreach ($aWeather as $date => $hours) : ?>                       
                            <table id="<?php echo 'table' . $date; ?>" class="hide">
                                    <tr class="attrs">
                                            <th></th>
                                            <th></th>
                                            <th>Давление</th>
                                            <th>t, °С</th>
                                            <th>Ветер</th>
                                    </tr>
                                    <?php foreach($hours as $hour => $properties) : ?>
                                    <tr>
                                            <td><?php echo $properties['DAYTIME']; ?></td>
                                            <td><img src="<?php echo $properties['PHENOMENA']; ?>" /></td>
                                            <td class="param"><?php echo $properties['PRESSURE']; ?> гПа </td>
                                            <td class="param1"><?php echo $properties['TEMPERATURE']; ?> °C</td>
                                            <td class="param"><?php echo $properties['WIND']; ?> &nbsp(м/с)</td>
                                    </tr>
                                    <?php endforeach; ?>
                            </table>
                            <?php endforeach; ?>
                    </td>
            </tr>
            </table>
            </div>
            <script type="text/javascript">
                    var weatherBox = document.getElementById('weatherBox');
                    weatherBox.getElementsByTagName('table')[0].getElementsByTagName('table')[0].className = "show";
            </script>

    #4837 Продолжение.

    qbasic, 07 Декабря 2010

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

    +101

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (CoursesString[CoursesString.Length - 1] == '\r')
                    {
                        sb.Remove(CoursesString.Length - 1, 1);
                        CoursesString = sb.ToString();
                    }

    а потом я понял...

    Golovastick, 05 Декабря 2010

    Комментарии (6)
  6. C# / Говнокод #4824

    +126

    1. 1
    2. 2
    3. 3
    public static void Authorize(int id)
    {
    if (id != null)

    вдруг откуда нивозьмись

    ursus, 03 Декабря 2010

    Комментарии (6)
  7. Куча / Говнокод #4784

    +129

    1. 1
    <strong class="textred">&nbsp;* required fiel</strong><strong class="textred">ds</strong>

    lexabug, 29 Ноября 2010

    Комментарии (6)
  8. Java / Говнокод #4781

    +78

    1. 1
    2. 2
    3. 3
    4. 4
    fm.bottom += ( tempBottom - fm.bottom );
    		fm.descent += ( tempDescent - fm.descent );
    		fm.ascent += ( tempAscent - fm.ascent );
    		fm.top += ( tempTop - fm.top );

    mlg7, 29 Ноября 2010

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

    +145

    1. 1
    2. 2
    <!--<form method=post action=bablo.php><input type=hidden name=action value='switchstyle'><td width=70 style='border-bottom-width:0px;'><input type=submit value=' режим: ночь ' style='border-width:0px;'></td><input type=hidden name=cur_style value='night'></form>--><td>account: mary-e</td></tr>
    	<!--<tr><td class=workcell colspan=9></td></tr>-->

    Kolotibablo угарает в который раз.
    Нахера нам невидимая кнопка?

    vedmak3013, 24 Ноября 2010

    Комментарии (6)
  10. C# / Говнокод #4707

    +110

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    void someMethod(Object obj)
    {
    	if(!obj.Equals(null))
    	{
    		...
    	}
    }

    а это я сам когда-то очень-очень давно наклал :))))
    до их пор с теплотой вспоминаю, как сам потом ржал, когда заметил :)

    Pauchok-Anaynckiy, 22 Ноября 2010

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

    +162

    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
    GetFirstFieldWithName(CString szElemName)
    {
        int i = -1;
    
        for (i = 0; i < m_FieldValues.GetSize(); i ++)
        {
            if (m_FieldValues[i]->m_szElemName == szElemName)
                break;
        }
    
        if ((i > 0) && (i < m_FieldValues.GetSize()))
            return m_FieldValues[i];
        else
            return NULL;
    }

    Shumway, 22 Ноября 2010

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