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

    +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
    14. 14
    #include <iostream>
    using namespace std;
    void main()
    {
        char U='#';
    int K;
        _asm
        {
            mov eax, 0
            mov al, U
            mov K,eax
        }
        cout<<K<<endl;
    }

    "Получение десятичного представления числа". C wasm.ru

    rat4, 18 Марта 2011

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

    +167

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    PopupWindow* GameLocations::getCurrentPopup()
    {
    	if(m_curPopup != nullptr && m_curPopup->needsClose())
    	{
    		m_curPopup->onClose();
    		m_curPopup = nullptr;
    		m_walker->BeginWalk(m_graph->getClosestNode(m_currentLocationId));
    	}
    	return m_curPopup;
    }

    Kirinyale, 18 Марта 2011

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    __int64 timestamp;
    
    	// Get nanoseconds since 1601
    	timestamp = rand() + (((__int64)rand()) << 32);
    	timestamp /= 100;

    очень вольная работа со временем...

    kubrinsky, 16 Марта 2011

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

    +160

    1. 1
    2. 2
    float alpha = float(m_startAlpha) + 255.0f * (getElapsed() / (m_duration * (1.0f - float(m_startAlpha) / 255.0f)));
    m_target->setAlpha(static_cast<uint8_t>(alpha));

    Выдержка из обновления объекта-действия, производящего линейный фейд-аут объекта...

    Общение с чужим говнокодом не проходит бесследно... что же я курил, перед тем как ЭТО соорудить?

    Kirinyale, 14 Марта 2011

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

    +167

    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
    float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating)
    {
        // returns the chance to win against a team with the given rating, used in the rating adjustment calculation
        // ELO system
       // return 1.0f/(1.0f+exp(log(10.0f)*(float)((float)enemy_rating - (float)own_rating)/400.0f));
    	float a,b;
    
    	a = own_rating;
    	b = enemy_rating;
    
    		 if(a<1800 && b<1800) return 16;
    		 if(a>=1800 && a<2000 && b<2000 || b>=1800 && b<2000 && a<2000) return 15;
    		 if(a>=2200 && b>=2200) return 15;
    	if(a>b){
    		 if(a>=2000 && a<2100 && b>=2100 && b<2200) return 17;
    		 if(a>=2000 && a<=2100 && b>=2200) return 18;
    		 if(b>=2000 && b<2100 && a>=2200) return 9;
    		 if(a>=2000 && a<2100 && b>=2000 && b<2100) return 15;
    		 if(a>=2100 && a<2200 && b>=2100 && b<2200) return 15;
    		 if(a>=2100 && a<2200 && b>=2200) return 16;
    		 if(b>=2100 && b<2200 && a>=2200) return 11;
    		 if (a>=2000 && a<2100 && b >=1850) return 10;
    		 if (a>=2000 && a<2100 && b <=1850) return 5;
    		 if (a>=2100 && a<=2200 && b >=1950 && b <2000) return 9;
    		 if (a>=2100 && a<=2200 && b >=1900 && b <2000) return 7;
    		 if (a>=2100 && a<=2200 && b >=2000 && b <2100) return 11;
    		 if (a>=2100 && a<2200 && b <=1900 && b >=1750) return 4;
    		 if (a>=2100 && a<2200 && b <1750) return 3;
    		 if (a>=2200 && b >=1950 && b <=2000) return 4;
             if (a>=2200 && b <=1950 && b>=1800) return 2;
    		 if (a>=2200 && b <=1850) return 1;
    		 if(a>=1500 && a<1600 && b >=2200) return 31;
    		 if(a>=1500 && a<1600 && b>=2000 && b <2100) return 28;
    		 if(a>=1500 && a<1600 && b>=2100 && b<2200) return 29;
    		 if(a>=1500 && a<1600 && b>=2100 && b>2200) return 31;
    		 if (a>=1900 && a<2000 && b>=2000 && b<= 2075) return 18;
    		 if (a>=1900 && a<2000 && b>=2075 && b<= 2150) return 24;
    		 if (a>=1900 && a<2000 && b>=2150 && b<= 2200) return 25;
    		 if (a>=1900 && a<2000 && b>=2150 && b> 2200) return 27;
    		 if (a>=1800 && a<1900 && b>=2000 && b<= 2075) return 22;
    		 if (a>=1800 && a<1900 && b>=2075 && b<= 2150) return 27;
    		 if (a>=1800 && a<1900 && b>=2150 && b<= 2200) return 29;
    		 if (a>=1800 && a<1900 && b>=2150 && b> 2200) return 30;
    		 if (a>=1600 && a<1800 && b>=2000 && b<= 2075) return 22;
    		 if (a>=1600 && a<1800 && b>=2075 && b<= 2150) return 28;
    		 if (a>=1600 && a<1800 && b>=2150 && b<= 2200) return 29;
    		 if (a>=1600 && a<1800 && b>=2150 && b> 2200) return 30;
    		 if(a<1500 & b>=2000) return 31;
    	}else{
                     // same just b instead of a and a instead of b
    	}
        
    }

    New developer for wow server ;) Best part is the cast to floats at start imo

    kerhong, 14 Марта 2011

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

    +169

    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
    #include <iostream>
    #include <cstdlib>
    #include "filesdescrtable.h"
    
    int ___cntr = 0;
    #define _(X) if((X) == EXIT_SUCCESS) {___cntr++;} else {std::cerr << "error on operator: " << ___cntr << std::endl; return (EXIT_FAILURE);}
    
    int main (int argc, char *argv[]) {
    	FilesDescrTable a;
    
    	int d1,d2,d3;
    
    	_(a.setAutoReport(true));
    	_(a.openFile(argv[1], O_RDWR | O_CREAT, 0600, d1));
    	_(a.openFile(argv[2], O_RDWR | O_CREAT, 0600, d2));
    	_(a.openFile(argv[3], O_RDWR | O_CREAT, 0600, d3));
    	_(a.clearFile(argv[3]));
    	_(a.cpy(d3,d2));
    	_(a.closeFile(d1));
    	_(a.closeFile(d2));
    	_(a.closeFile(d3));
    
    	return(EXIT_SUCCESS);
    }

    хитрый макрос для отлова ошибок. такой хитрый

    cahekm, 13 Марта 2011

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

    +175

    1. 1
    2. 2
    3. 3
    // "Dedicated to the near-memory of Nev. Let's start remembering people while they're still alive."
        // Nev's great contribution to dc++
        while(1) break;

    Вот такое можно увидеть в исходниках ядра DC++
    https://github.com/negativ/eiskaltdcpp/blob/master/dcpp/DCPlusPlus.cpp#L60

    gelraen, 11 Марта 2011

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    if (request->status().is_success() &&
          (request->GetResponseCode() / 100) == 2) {
          /* блаблабла */
      }

    Было случайно откопано в исходниках хромиума (http://src.chromium.org/svn/trunk/src/webkit/appcache/appcache_update_job.cc). И первый вопрос который возникает это "Ну вот нахера???".

    POPSuL, 11 Марта 2011

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

    +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
    16. 16
    17. 17
    18. 18
    19. 19
    void Exf2dMW::closeEvent(QCloseEvent* event)
    {
      int win_num = _winManager->numberOfModellingWindows();
      // if more than one modelling windows, just destroy current one:
      if (win_num > 1) {
        event->accept();
        delete this;
      }
      // if only one window and handle closing model properly, then destroy it:
      else {
        if( handleCloseModel() ) {
          event->accept();
          delete this;
          delete _winManager;
        }
        else
          event->ignore();
      }
    }

    Еще кусочек говнокода коллеги, я не думал что так можно писать..

    kitaec, 08 Марта 2011

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

    +158

    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
    #include <iostream.h>
    #include <stdlib.h>
    #define make(a,b) new a[b];
    #define init(a,b) for(int i=0; i<b; i++) a[i]=random(10);
    #define MyType int
    template<class type>
    void sort(type *m,int  n)
     {
     type *m1 = m;
       for(int i=0; i<n-1; i++)
      		{
            for(int j=0; j<n-i-1; j++)
               {
               if (*m1>*(m1+1))
            	    {
                                              MyType temp;
       		      temp=*m1;
      	    	       *m1=*(m1+1);
    		       *(m1+1)=temp;
             	  }
               m1++;
               }
           m1=m;
          }
     }
    
     template<class type>
     void input(type *m,int num)
     {
     type *m1=m;
     for(int i=0;i<num; i++)
      		{
             cin>>*m1;
              m1++;
          }
      m1=m;
      cout << endl;
     }
    
     template<class type>
     void output(type  *m, int n)
     {
     for(int i=0;i<n; i++)
      		{
             cout << *(m+i)<<" ";
          }
     }
    
     main()
     {
     int len;
      cout << "Vvedite razmer massiva" << endl;
      cin >> len;
    
      MyType *mas1 = make(MyType,len);
      input(mas1,len);
      //init(mas1,len);
      output<MyType>(mas1,len);
      sort<MyType>(mas1,len);
      cout<<endl;
      output<MyType>(mas1,len);
      cout<<endl;
      system("pause");;
     }

    Делалось на Borland C++ 5.02 , что прикольно без макроса make , если память выделяется просто в теле, то ревет, что память ниразу не выделена . Делали ее часика в 4 утра к зачету, препод конечно прибалдел от таких раскладов, но покопавшись ничего сам сделать не смог, плюнул на это дело и зачет поставил.

    USERNAME, 08 Марта 2011

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