1. C++ / Говнокод #1620

    +13.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
    ...
    
    class TCar
    {
    public:
    	TCar(int Speed)
    	{
    		...
    	};
    };
    
    ...
    
    void destroy_Car(TCar Car)
    {
    	...
    };
    
    ...
    
    void GameLogic()
    {
    	...
    	
    	destroy_Car(50);
    	
    	...
    };
    
    ...

    Хорошая логика...

    Говногость, 18 Августа 2009

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

    +161.1

    1. 1
    2. 2
    3. 3
    4. 4
    $w="";
    foreach(array("id_page","id_point","id") as $i)
    $w.=$$i?(($w?" and ":"")."$i=".$$i):"";
    $sql="select * from ".$this->_name." where $w order by ordr,ts desc";

    и без комментов, ага.

    voblasoul, 18 Августа 2009

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

    +12.2

    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
    TMutex CriticalGlobalRTOSMutex;
    
    ...
    
    void CriticalDoing()
    {
    	CriticalGlobalRTOSMutex.Lock();
    
    	...
    
    	if( !HorriblyDoing(...) )
    	{
    		throw FatalException;
    	};
    
    	...
    
    	CriticalGlobalRTOSMutex.UnLock();
    };
    
    ...

    Мне уже страшно...

    Говногость, 18 Августа 2009

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

    +12.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
    class TIntArray
    {
    	char buf[10000];
    	int operator[](int Index);
    };
    
    ...
    
    void main()
    {
    	TIntArray a;
    	...
    	memset(&a[1],0.0f,sizeof(TIntArray));
    	...
    };

    Меня этот кот довёл до слёз...

    Говногость, 18 Августа 2009

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

    +13.1

    1. 1
    2. 2
    3. 3
    #define REGISTER_PACKET(cls, type)\
    __declspec(selectany) PacketType cls::s_type = CPacketFactory::RegisterPacket(type, cls::CreateNew); \
    __pragma(comment(linker, "/include:?s_type@##cls##@@2W4PacketType@@C"))

    Очень правильный код... Делать можно только так.

    Говногость, 18 Августа 2009

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

    +152.8

    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
    function verify()
    {	
    	 //1
      if(event.clientX >= 20 && event.clientX <= 113 && event.clientY >= 20 && event.clientY <= 90 && trigger == 1)	
         {
         name.style.top=21
         name.style.left=21
         name.border=0
         if(name.name == "one"){counter1=1; document.all.ok.style.visibility = 'visible'; document.all.no.style.visibility = 'hidden'}
    	 else{counter1=0; document.all.no.style.visibility = 'visible'; document.all.ok.style.visibility = 'hidden'; errors++}
    	 trigger = 0
    	 movements++ 
         document.all.movements.value = movements
    	
    	 
         }
    	 //2
    	 if(event.clientX >= 113 && event.clientX <= 206 && event.clientY >= 20 && event.clientY <= 90 && trigger == 1)	
         {
         name.style.top=21
         name.style.left=114
         name.border=0
         if(name.name == "two"){counter2=1; document.all.ok.style.visibility = 'visible'; document.all.no.style.visibility = 'hidden'; errors++}else{counter2=0; document.all.no.style.visibility = 'visible'; document.all.ok.style.visibility = 'hidden'; errors++}
    	 trigger = 0
    	 movements++ 
         document.all.movements.value = movements
    	 
         }
    	 //3
    	 if(event.clientX >= 206 && event.clientX <= 299 && event.clientY >= 20 && event.clientY <= 90 && trigger == 1)	
         {
         name.style.top=21
         name.style.left=207
         name.border=0
    	 if(name.name == "three"){counter3=1; document.all.ok.style.visibility = 'visible'; document.all.no.style.visibility = 'hidden'}else{counter3=0; document.all.no.style.visibility = 'visible'; document.all.ok.style.visibility = 'hidden'; errors++}
         trigger = 0
    	 movements++ 
         document.all.movements.value = movements
    	 
         }
    	 //4
    	 if(event.clientX >= 299 && event.clientX <= 392 && event.clientY >= 20 && event.clientY <= 90 && trigger == 1)	
         {
         name.style.top=21
         name.style.left=300
         name.border=0
    	 if(name.name == "four"){counter4=1; document.all.ok.style.visibility = 'visible'; document.all.no.style.visibility = 'hidden'}else{counter4=0; document.all.no.style.visibility = 'visible'; document.all.ok.style.visibility = 'hidden'; errors++}
         trigger = 0
    	 movements++ 
         document.all.movements.value = movements
    	 
     //И так - 30 раз:))

    Говнокодил давно, еще в школе. Года через 4, в универе, вернулся к этому коду и ничего не смог понять:) Новое решение заняло примерно в 10 раз меньше места.

    huzik, 18 Августа 2009

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

    +7.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    float *val32;
    val32 = new(float);
    *val32 = 0.0f;
    memcpy((float*)(((char*)val32)+0), buf+(i*4)+0, 1);
    memcpy((float*)(((char*)val32)+1), buf+(i*4)-1, 1);
    memcpy((float*)(((char*)val32)+2), buf+(i*4)+2, 1);
    memcpy((float*)(((char*)val32)+3), buf+(i*4)+1, 1);
    
    int value = device->DownValue32(*val32, start + (i*2) - 2);
    
    free (val32);

    Заводить переменные с стеке это для лохов. Реальные пацаны все выделяют в стеке.

    pathfinder, 18 Августа 2009

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

    +7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    std::string s1;
    std::string s2;
    
    int ret = strcmp(s1.c_str(), s2.c_str());  //А здесь мы сравниваем строки
    if (ret == 0)
    {
        .... 
    }

    pathfinder, 18 Августа 2009

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

    +7

    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
    if(isMoving)
    {
    	std::map<int, unsigned char> dirToFrame = boost::assign::map_list_of(1, 10)(2, 5)(3, 6)(4, 7)(5, 8)(6, 9)(7, 12)(8, 11);
    	if(dir >= 1 && dir <= 10)
    		return dirToFrame[dir];
    
    	throw std::string("Something very wrong1.");
    }
    else //if(isMoving)
    {
    	std::map<int, unsigned char> dirToFrame = boost::assign::map_list_of(1, 13)(2, 0)(3, 1)(4, 2)(5, 3)(6, 4)(7, 15)(8, 14);
    	if(dir >= 1 && dir <= 10)
    		return dirToFrame[dir];
    
    	throw std::string("Something very wrong1.");
    }

    Кусок кода из open source игры. Выбирает кадр спрайта, в зависимости от направления героя. В ревизии, предшествующей этой, использовался switch.

    just_geek, 18 Августа 2009

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

    +166.4

    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
    <?
    $query="SELECT * FROM Communicators WHERE phoneID=$phoneID";
    $dba->query($query);
    list($phoneID, $brandID, $phoneModel, $phoneDate, $phonePriceRetail, $phonePriceWS,$phonePriceWS1, $phoneDescrShort, $phoneDescrFull, $phonePicShort, $phonePicFull,
    $phonePriceWSComment, $groupDefaultprice1, $groupDefaultprice2, $groupGroup2price1, $groupGroup2price2, $grouptempprice1, $grouptempprice2, $groupGorodprice1, $groupGorodprice2, $groupClientsprice1, $groupClientsprice2,
    $standards, $height, $width, $thickness, $weight, $batteryType, $batteryMAH, $standbyTime, $talkTime, $phoneBookSize, $video, $processor, $calendar, $wap, $OS, $GPRS, $EDGE, $java, $FMradio, $memcard, $bluetooth, $modem, $irda, $EMS, $MMS, $USB, $dictaphone, $camera, $colorDisplay, $twoDisplays, $outlookSynchro, $otherDescription, $games, $ringFileFormat, $innerMemory, $mp3player, $corpus, $WiFi, $videoCall, $GPS, $xtraDescr, $id_article)=$dba->get_row();
    ?>
    <h2>Описание <?=$brandName?> <?=$phoneModel?></h2>
    <b>Основные характеристики</b><br>
    <?if( $standards != "" ){?>Стандарт: <?=$standards?><br><?}?>
    <?if( $corpus != "" ){?>Тип корпуса: <?=$corpus?><br><?}?>
    Размеры, мм (Ш×В×Г): <?=$width?>×<?=$height?>×<?=$thickness?><br>
    <?if( $weight != "" ){?>Вес: <?=$weight?> г<br><?}?>
    Аккумулятор: <?if( $batteryType != "" ){?><?=$batteryType?>, <?}?><?if( $batteryMAH != "" ){?><?=$batteryMAH?> мА·ч<br><?}?>
    <?if( $processor != "" ){?>Процессор: <?=$processor?><br><?}?>
    <?if( ($innerMemory != "0") && ($innerMemory != 0) && ($innerMemory != "") ){?>Память RAM/ROM: <?=$innerMemory?><br><?}?>
    <?if( $memcard != "" ){?>Слоты расширения: <?=str_replace("+","есть",str_replace("-","нет",$memcard))?><br><?}?>
    <?if( $OS != "" ){?>Операционная система: <?=$OS?><br><?}?>
    <?if( $calendar != "" ){?>Органайзер: <?=str_replace("+","есть",str_replace("-","нет",$calendar))?><br><?}?>
    <br>
    <b>Связь</b><br>
    <?if( $USB != "" ){?>USB: <?=str_replace("+","есть",str_replace("-","нет",$USB))?><br><?}?>
    <?if( $irda != "" ){?>Инфракрасный порт: <?=str_replace("+","есть",str_replace("-","нет",$irda))?><br><?}?>
    <?if( $GPRS != "" ){?>GPRS: <?=str_replace("+","есть",str_replace("-","нет",$GPRS))?><br><?}?>
    <?if( $EDGE != "" ){?>EDGE: <?=str_replace("+","есть",str_replace("-","нет",$EDGE))?><br><?}?>
    <?if( $bluetooth != "" ){?>Bluetooth: <?=str_replace("+","есть",str_replace("-","нет",$bluetooth))?><br><?}?>
    <?if( $WiFi != "" ){?>Wi-Fi: <?=str_replace("+","есть",str_replace("-","нет",$WiFi))?><br><?}?>
    <?if( $GPS != "" ){?>GPS: <?=str_replace("+","есть",str_replace("-","нет",$GPS))?><br><?}?>
    <br>
    <b>Экран</b><br>
    <?if( $colorDisplay != "" ){?>Экран: <?=str_replace("+","есть",str_replace("-","нет",$colorDisplay))?><br><?}?>
    <?if( $twoDisplays != "" ){?>Сенсорный дисплей: <?=str_replace("+","есть",str_replace("-","нет",$twoDisplays))?><br><?}?>
    <br>
    <b>Мультимедийные возможности</b><br>
    <?if( $mp3player != "" ){?>MP3-плеер: <?=str_replace("+","есть",str_replace("-","нет",$mp3player))?><br><?}?>
    <?if( $ringFileFormat != "" ){?>Аудио форматы: <?=$ringFileFormat?><br><?}?>
    <?if( $FMradio != "" ){?>FM радио: <?=str_replace("+","есть",str_replace("-","нет",$FMradio))?><br><?}?>
    <?if( $dictaphone != "" ){?>Диктофон: <?=str_replace("+","есть",str_replace("-","нет",$dictaphone))?><br><?}?>
    <?if( $camera != "" ){?>Камера: <?=str_replace("+","есть",str_replace("-","нет",$camera))?><br><?}?>
    <?if( $video != "" ){?>Съемка видео: <?=str_replace("+","есть",str_replace("-","нет",$video))?><br><?}?>
    <?if( $videoCall != "" ){?>Видеозвонок: <?=str_replace("+","есть",str_replace("-","нет",$videoCall))?><br><?}?>
    <?if( $games != "" ){?>Игры: <?=str_replace("+","есть",str_replace("-","нет",$games))?><br><?}?>
    <?if( $otherDescription != "" ){?>
    <br>
    <b>Прочее</b><br>
    <?=nl2br($otherDescription)?>
    <?}?>

    Разгребаю это говно... Тот кто так пишет - недостоин жить :(

    Yozheg, 17 Августа 2009

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