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

    +50.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    ...
    double total, free;
    GetCensoredServer()->GetCensoredMemory(total, free);
    if (free<0.) // <-- чудесная проверка
    {
    	MessageBox(AfxGetMainWnd()->m_hWnd, censored("Please check censored for enough memory!")), _T(""), MB_OK|MB_ICONWARNING);
    	return false;
    }
    ...

    Найдено в рабочем коде. Некоторые идентификаторы изменены.

    Xentrax, 01 Сентября 2009

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

    +47

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #if defined(_WIN32_WCE_PSPC)
    	if(SHSipInfo(SPI_GETSIPINFO, 0, &si, 0))
      #else if (_WIN32_WCE >= 400) // <-- "хитрое" место
    	if(SipGetInfo(&si))
      #endif
    	{
    		// bla bla

    Найдено в рабочем коде.
    Удивительно, но это работает, как задумывалось.

    Xentrax, 01 Сентября 2009

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

    +56.6

    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
    class         inTm: public ioTm
            {           public: inTm(){ startInTm(); buffer=temp; };
                           int  readTm (tmData&);
                  virtual void  message(const structMessage&){};
                          void  inputArray (int);
                          void  setNonBlock(int);
                          void  startInTm();
                          long  readTmPos(tmData&);
                     protected:
                unsigned  char  temp[lengthBuffer];
              virtual unsigned  char* readBuffer(int&)=0;
                           int  inputBuffer();
                          void  convertTm(unsigned char*, tmData&);
                  virtual long  getPos(){ return current-count-countTemp; };
                       private:
                          void  cnvTmPC  (unsigned char*, tmData&);
                          void  cnvTmNet (unsigned char*, tmData&);
                        friend  inTmBl;
                        friend  finTm;
                           int  count;
                           int  lengthIn;
                unsigned  char* tempBuf;
                           int  countTemp;
            };

    Программист Мудрецов (фамилия у человека такая) был большим затейником. Например, код на С++ в хидерах он формативровал по центру - как стихи.
    P. S. Надеюсь, на сайте форматирование сохранится.

    Dimarius, 01 Сентября 2009

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

    +58.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
    switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 53)
        {
          Level_BeginThread(0, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 54)
        {
          Level_BeginThread(1, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 57)
        {
          Level_BeginThread(2, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 58)
        {
          Level_BeginThread(3, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 58)
        {
          Level_BeginThread(3, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 59)
        {
          Level_BeginThread(4, 500);
        }
        break;
      }

    Кусочек скрипта уровня одной игрушки. Вот что значит, если дизайнер не знает языка... Копипаст форева!!!АдинАдинАдин

    JohnnyIpcom, 28 Августа 2009

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

    +51.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    CSocket*   CServer::GetSocket  (const int& fd) { // Find socket by FD
      if (m_mapSocket[fd]) return m_mapSocket[fd];
      else return NULL;
    }
    // another one piece of crap...
    void CServer::CloseSocket(const int& fd) { // Close Socket.
      delete m_mapSocket[fd];
      if (m_mapSocket[fd]) m_mapSocket.erase(fd);
    
      FD_CLR(fd,&FFd_set);
      if (fd == FMax_fd) FMax_fd--;
    }

    zaufi, 28 Августа 2009

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

    +49.2

    1. 1
    2. 2
    3. 3
    4. 4
    if (strlen(tmpStr) > 250) 
        strncpy(fields[i].info.fieldName, tmpStr, 250);
    else 
        strcpy(fields[i].info.fieldName, tmpStr);

    А пох - все равно скопируем. =)

    rockerzz, 27 Августа 2009

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

    +48

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    while( !InputFileStream.atEnd() )
    {
    	QString Qstrtmp;
    	InputFileStream >> Qstrtmp;
    	ReadButton.bTag =  QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
    	InputFileStream >> Qstrtmp;
    	ReadButton.iTag =  QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
    	InputFileStream >> Qstrtmp;
    	ReadButton.Popup =  QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
    	ReadButton.PartitionId = *iVar;
    	this->Buttons.push_back( ReadButton );
    }

    Код взят из совместного проекта 5-ти студентов.
    Это был начальный период нашего изучения Qt.

    k06a, 26 Августа 2009

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

    +50

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    int i, j;
    for (i = j = 0; i < 4; i++)
    	if (frame & (0x8 >> i))
    	{
    		if (i < 2 && p.value < double(frames1[j]) && !(i && j) ||
    			i > 1 && p.value > double(frames1[j]))
    			p.value.attr = 1 + i;
    		j++;
    	}

    Как вам цикл до 4 с тремя проверками на значение счётчика? :)

    Dimarius, 25 Августа 2009

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

    +47.9

    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
    IsSimpleAssign = ( !isIfWhileForReturn&&
                        ( _currString->ecoString )->IsAtOncePresent( equalsSign )&&
                        ( _currString->ecoString )->IsAtOncePresent( star ) &&
                        ( _currString->ecoString )->IsAtOncePresent( amper ) &&
    
                        ( ( ( _currString->ecoString )->GetCharPos( amper ) <
                        ( _currString->ecoString )->GetCharPos( star ) ) ||
                        ( ( _currString->ecoString )->GetCharPos( amper ) >
                        ( _currString->ecoString )->GetCharPos( star ) ) ) &&
    
                        ( ( ( _currString->ecoString )->GetCharPos( equalsSign ) <
                        ( _currString->ecoString )->GetCharPos( star ) ) &&
                        ( ( _currString->ecoString )->GetCharPos( amper ) <
                        ( _currString->ecoString )->GetCharPos( equalsSign ) )
    
                        ||
                        ( ( _currString->ecoString )->GetCharPos( equalsSign ) >
                        ( _currString->ecoString )->GetCharPos( star ) ) &&
                        ( ( _currString->ecoString )->GetCharPos( amper ) >
                        ( _currString->ecoString )->GetCharPos( equalsSign ) ) )
    
                        );

    где-то в недрах рукописного парсера

    gilya, 25 Августа 2009

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

    +32.9

    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
    #include <stdlib.h>
    
    ...
    
    class CAbstractControl
    {
    	...
    };
    
    class CWindow
    {
    	...	
    };
    
    class CButton: public CAbstractControl
    {
    	...
    };
    
    class CLabel: public CAbstractControl
    {
    	...
    };
    
    ...
    
    bool operator+(CWindow& win, CAbstractControl& Control)
    {
    	return win.AddControl(Control);
    };
    
    ...
    
    void main()
    {
    	CWindow& w=new CWindow(10,10,300,300,"Mail Messanger v11.0");
    	CAbstractControl& b1=new CButton(270,280,300,300,"OK");
    	...
    	CAbstractControl& l1=new CLabel(10,10,"Mail:");
    	...
    	if(!(w+b1))abort();
    	if(!(w+b2))abort();
    	...
    };

    Программа делает аборт();
    :D

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

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