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

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

    +11

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    for (_i = 1;_i <= int(strlen(Query10->FieldValue("pattern").c_str()));_i++) {
        // ...
    }
    
    if (strlen(Query10->FieldValue("pattern_before").c_str()) == strlen(Query10->FieldValue("pattern_short").c_str())) {
        // ...
    }

    Nuff said.

    bormand, 29 Мая 2014

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

    +11

    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
    QString Factory::lifeEqual(WidgetEnum::SearchWidgetSet param) {
        switch (param) {
        case WidgetEnum::station:
            return "Станция";
        case WidgetEnum::water_area:
            return "Акватория";
        case WidgetEnum::station_coordinates:
            return "Координаты станции";
        case WidgetEnum::volume_of_filtered_water:
            return "Объем отфильтрованной воды";
        case WidgetEnum::chlorophyll_a_concentration:
            return "Концентрация хлорофила а";
        case WidgetEnum::chlorophyll_b_concentration:
            return "Концентрация хлорофила b";
        case WidgetEnum::chlorophyll_c_concentration:
            return "Концентрация хлорофила c";
        case WidgetEnum::A665k:
            return "A(665k";
        case WidgetEnum::pigment_index:
            return "Индекс пигмента";
        case WidgetEnum::pheopigments:
            return "Феопигменты";
        case WidgetEnum::upholding_sample_time:
            return "Время выдержки образца";
        case WidgetEnum::concetrated_sample_volume:
            return "Объемная концентрация образца";
        case WidgetEnum::cameras_viewed_number:
            return "Качество камеры";
        case WidgetEnum::total:
            return "Общая численость";
        case WidgetEnum::total_species:
            return "Число видов в пробе";
        case WidgetEnum::total_biomass:
            return "Общая биомасса";
        case WidgetEnum::total_percent:
            return "Итоговый процент";
        case WidgetEnum::biomass_percent:
            return "Процент биомасс";
        case WidgetEnum::percentage_of_total:
            return  "Процент от общего числа";
        case WidgetEnum::percentage_of_the_total_biomass:
            return "Процент от общего числа биомассы";
        case WidgetEnum::number:
            return "Номер";
        case WidgetEnum::biomass:
            return "Биомасса";
        case WidgetEnum::total_species_in_group:
            return "Всего видов в группе";
        case WidgetEnum::name:
            return "Название";
        case WidgetEnum::name_alt:
            return "Альтернативное название";
        case WidgetEnum::name_rus:
            return "Русское название";
        case WidgetEnum::fishing_gear:
            return "Рыболовный аппарат";
        case WidgetEnum::assessment_of_zooplankton:
            return "Оценка зоопланктона";
        case WidgetEnum::date:
            return "Дата";
        case WidgetEnum::Station_water_area:
            return "";
        case WidgetEnum::groupsOfPh_name:
            return "Название группы";
        case WidgetEnum::groups:
            return "Вид";
        case WidgetEnum::error:
            return "errorA";
        case WidgetEnum::chlorinity:
            return "chlorinity";
        case WidgetEnum::density:
            return "density";
        case WidgetEnum::volume:
            return "volume";
        case WidgetEnum::o2_mg_l:
            return "o2_mg_l";
        case WidgetEnum::o2_ml_l:
            return "o2_ml_l";
        case WidgetEnum::bod5:
            return "bod5";
        case WidgetEnum::ph:
            return "ph";
        case WidgetEnum::alk:
            return "alk";
        case WidgetEnum::no2:
            return "no2";
        case WidgetEnum::no3:
            return "no3";
        case WidgetEnum::total_n:
            return "total_n";
        case WidgetEnum::po4:
            return "po4";
        case WidgetEnum::total_p:
            return "total_p";
        case WidgetEnum::si:
            return "si";
    And etc.....

    В таком духе имеется строк 300, и если бы выход здравого смысла из спячки и наличие базы данных, 50 строчек которыми все это стало, с течением времени могло бы превратиться в 1000 строк, если не больше.
    И хоть это банальный гавногод, жалко трудов и времени на него затраченных. А так хоть канет в бездне говногода, а не в бездне моего винта.

    smith599, 25 Мая 2014

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

    +11

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    int FCEUI_SetCheat(....)
    {
      ...
      if((t=(char *)realloc(next->name,strlen(name+1))))
      ...
    }

    А пасиму оно на 2 байта меньше выделяет, насяльника?

    http://www.viva64.com/ru/examples/V518/

    gost, 19 Мая 2014

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

    +11

    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
    float fNumber;
    //...
    //Куча бреда
    //...
       if(fNumber == +0)
          cout << "Неверно.;
       else if(fNumber == -0)
          cout << "Неверно.;
       else if(fNumber < +0 && fNumber > -0)
          cout << "У вас неправильная система счисления.";
       else{
          //...
       }

    Ignat776, 26 Марта 2014

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

    +11

    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
    #define EDGE_EDGE_TEST(V0,U0,U1)                      \
    	Bx=U0[i0]-U1[i0];                                   \
    	By=U0[i1]-U1[i1];                                   \
    	Cx=V0[i0]-U0[i0];                                   \
    	Cy=V0[i1]-U0[i1];                                   \
    	f=Ay*Bx-Ax*By;                                      \
    	d=By*Cx-Bx*Cy;                                      \
    	if((f>0 && d>=0 && d<=f) || (f<0 && d<=0 && d>=f))  \
    {                                                   \
    	e=Ax*Cy-Ay*Cx;                                    \
    	if(f>0)                                           \
    {                                                 \
    	if(e>=0 && e<=f) return 1;                      \
    	}                                                 \
    	else                                              \
    {                                                 \
    	if(e<=0 && e>=f) return 1;                      \
    	}                                                 \
    	}
    
    #define POINT_IN_TRI(V0,U0,U1,U2)           \
    {                                           \
    	double a,b,c,d0,d1,d2;                     \
    	/* is T1 completly inside T2? */          \
    	/* check if V0 is inside tri(U0,U1,U2) */ \
    	a=U1[i1]-U0[i1];                          \
    	b=-(U1[i0]-U0[i0]);                       \
    	c=-a*U0[i0]-b*U0[i1];                     \
    	d0=a*V0[i0]+b*V0[i1]+c;                   \
    	\
    	a=U2[i1]-U1[i1];                          \
    	b=-(U2[i0]-U1[i0]);                       \
    	c=-a*U1[i0]-b*U1[i1];                     \
    	d1=a*V0[i0]+b*V0[i1]+c;                   \
    	\
    	a=U0[i1]-U2[i1];                          \
    	b=-(U0[i0]-U2[i0]);                       \
    	c=-a*U2[i0]-b*U2[i1];                     \
    	d2=a*V0[i0]+b*V0[i1]+c;                   \
    	if(d0*d1>0.0)                             \
    {                                         \
    	if(d0*d2>0.0) return 1;                 \
    	}                                         \
    	}
    
    #define NEWCOMPUTE_INTERVALS(VV0,VV1,VV2,D0,D1,D2,D0D1,D0D2,A,B,C,X0,X1) \
    { \
    	if(D0D1>0.0f) \
    { \
    	/* here we know that D0D2<=0.0 */ \
    	/* that is D0, D1 are on the same side, D2 on the other or on the plane */ \
    	A=VV2; B=(VV0-VV2)*D2; C=(VV1-VV2)*D2; X0=D2-D0; X1=D2-D1; \
    	} \
    	else if(D0D2>0.0f)\
    { \
    	/* here we know that d0d1<=0.0 */ \
    	A=VV1; B=(VV0-VV1)*D1; C=(VV2-VV1)*D1; X0=D1-D0; X1=D1-D2; \
    	} \
    	else if(D1*D2>0.0f || D0!=0.0f) \
    { \
    	/* here we know that d0d1<=0.0 or that D0!=0.0 */ \
    	A=VV0; B=(VV1-VV0)*D0; C=(VV2-VV0)*D0; X0=D0-D1; X1=D0-D2; \
    	} \
    	else if(D1!=0.0f) \
    { \
    	A=VV1; B=(VV0-VV1)*D1; C=(VV2-VV1)*D1; X0=D1-D0; X1=D1-D2; \
    	} \
    	else if(D2!=0.0f) \
    { \
    	A=VV2; B=(VV0-VV2)*D2; C=(VV1-VV2)*D2; X0=D2-D0; X1=D2-D1; \
    	} \
    	else \
    { \
    	/* triangles are coplanar */ \
    	return coplanar_tri_tri(N1,V0,V1,V2,U0,U1,U2); \
    	} \
    	}

    Макросы макросики. Inline? Нет, не слышал.

    Abbath, 25 Января 2014

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

    +11

    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
    /// Represents the model of a Writer document.
    class SW_DLLPUBLIC SwDoc :
        public IInterface,
        public IDocumentSettingAccess,
        public IDocumentDeviceAccess,
        public IDocumentRedlineAccess,
        public IDocumentLinksAdministration,
        public IDocumentFieldsAccess,
        public IDocumentContentOperations,
        public IDocumentStylePoolAccess,
        public IDocumentLineNumberAccess,
        public IDocumentStatistics,
        public IDocumentState,
        public IDocumentDrawModelAccess,
        public IDocumentLayoutAccess,
        public IDocumentTimerAccess,
        public IDocumentChartDataProviderAccess,
        public IDocumentListItems,
        public IDocumentOutlineNodes,
        public IDocumentListsAccess,
        public IDocumentExternalData
    {
    ...

    Вот это монстрище!

    http://opengrok.libreoffice.org/xref/core/sw/inc/doc.hxx

    Sauron, 23 Декабря 2013

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

    +11

    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
    void run(std::map<QString, QString> params,QTextStream &os) const
    	{
    
    		static int ko=0;
    			ko++;
    			//r->method_="GET";
    			srand(time(0));// без этого числа будут одинаковые
    			QString  randomData="["+ (QString::number(ko))+" , "+ (QString::number(rand()%100))+ "]";
    			//int index= params["idChpu"].toInt();
    			std::list<QString> idsparams=getIdsDataRequest(params["dataRequestIds"]);
    			QString dataInIds="";
    			//for (auto idParam=idsparams.begin();idParam!=idsparams.end();idParam++)
    			for (const auto &idParam : idsparams)
    			{
    				qDebug()<<idParam;
    				auto kokoFunction=[](const std::function<QString()> & function){QString date; for(auto i=0 ;i<10;i++){date+= function()+QString(" , ");} ; return date;};
    				if (idParam==QString("id0"))
    				{dataInIds=dataInIds+QString("\"")+(idParam)+QString("\"")+QString(":[")+kokoFunction([](){return QString::number((ko++));})+QString::number((ko++))+QString("],");}
    				else
    				{dataInIds=dataInIds+QString("\"")+(idParam)+QString("\"")+QString(":[")+kokoFunction([](){return QString::number(rand()%100);})+QString::number(rand()%100)+QString("],");}
    			};
    			QString jsonData=QString("{")+
    						QString("\"idLastKey\":\"10\",")+dataInIds+QString("}");
    
    		qDebug()<<"TgetDataOnRequest run</h1>";
    		os << "HTTP/1.0 200 Ok\r\n"
    				"Content-Type: text/html; charset=\"windows-1251\"\r\n"
    				"\r\n"<<jsonData<<//randomData<<
    				"\n";
    
    //				  << QDateTime::currentDateTime().toString() << connectionSettings.getUrl()<<"\r\n"<<connectionSettings.getViewRequest()<<"\n";
    	}

    Надеюсь это временный код, но очень сомневаюсь.

    laMer007, 20 Ноября 2013

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

    +11

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // This is an example of an exported function.
    SCCONNECT_API int fnSCConnect(void)
    {
    	return 42;
    }

    Не говно, но не мог промолчать!
    Вот такой шаблон функции генерирует MSVC при создании DLL.

    MSVC даёт ответ на самый главный вопрос жизни, вселенной и всего такого!

    Little-Horny, 21 Октября 2013

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

    +11

    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
    AbstractMessageFrame * DataLength = create_frame(
    		make_condition_reader(this,
    			fnc_ext::bind(
    				fnc_ext::compose1(
    					fnc_ext::compose2(std::logical_or<bool>(),
    									  std::bind2nd(std::equal_to<byte>(), PC5000FlashFeatures::MARKER_SYMBOL),
    									  std::bind2nd(std::equal_to<byte>(), PC5000FlashFeatures::SPACE_SYMBOL)),
    					fnc_ext::mem_fun<const ByteBuffer, const byte&>(&ByteBuffer::back) ),
    				&_receivedBuffer),
    			fnc_ext::bind(
    				fnc_ext::compose2(std::logical_or<bool>(),
    								  fnc_ext::compose1(std::bind2nd(std::greater<WORD>(),
    																 PC5000FlashFeatures::LENGTH_HEADER +
    																 _maxCommandFieldLength +
    																 PC5000FlashFeatures::LENGTH_MARKER +
    																 PC5000FlashFeatures::LENGTH_OF_LENGTH),
    													fnc_ext::mem_fun(&ByteBuffer::length)),
    								  fnc_ext::compose1(fnc_ext::compose2(std::logical_and<bool>(),
    																	  std::not1(std::ptr_fun<const char, bool>((SymbolCheckFunc)isDigit)),
    																	  std::not1(std::ptr_fun<const char, bool>((SymbolCheckFunc)isEnglishLetter))),
    													fnc_ext::mem_fun<const abstractBuffer<unsigned char>, const byte&>(&ByteBuffer::back)) ),
    				&_receivedBuffer) ),
    		fnc_ext::bind(std::mem_fun(&ThisClass::setDataLength), this),
    		"Data Length");

    Композиции, частичные применения, функторы? Больше тотальной функциональщины! Вложенность продолжает расти с развитием проекта.

    laMer007, 17 Сентября 2013

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

    +11

    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
    for(int i = posX-width, numBlock = 0; i < posX+width; i++)
        {
            for(int j = posY-height; j < posY+height; j++)
            {
            if(worldInfo[i][j] != air){
                switch(worldInfo[i][j])
                {
                case grass:
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[0][i];
                break;
                case dirt:
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[1][i];
                break;
                case rock:
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[2][i];
                break;
                case water:
                    if(j != 35)
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[3][i];
                    else
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[4][i];
                break;
                case sand:
                    for(i = 0; i < 8; i++) tempCoord[numBlock*8+i] = texCoordList[5][i];
                break;
                }
                numBlock++;
                }
            }
        }

    Мое. Долго искал причину краша. Нашел. Если в кратце, тот тут идет присваивание текстурных коррдинат. Я оставлю это здесь, приятного аппетита!

    pelmenka, 24 Августа 2013

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