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

    +13

    1. 1
    #pragma comment(linker, "/export:?CreateEngine3D@pbl3d@@YGJAAPAUIEngine3D@1@ABUSENGINE3DCREATEPARAMETERS@1@PAUIEvents@1@@Z=?CreateEngine3D@core@pbl3d@@YGJAAPAUIEngine3D@2@ABUSENGINE3DCREATEPARAMETERS@2@PAUIEvents@2@@Z")

    "А вдоль дороги мертвые кресты стоят... И тишина..."

    HaskellGovno, 27 Июля 2012

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

    +18

    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
    // ОЛОЛО ОЛОЛО КРЕСТОШАБЛОНЫ И ХУЙЛО
     if (ro<Fixed(100))
         DrawCircle<0>(b, x, y, ri, ro, ball.color);
     else if (ro<Fixed(200))
         DrawCircle<1>(b, x, y, ri, ro, ball.color);
     else if (ro<Fixed(400))
         DrawCircle<2>(b, x, y, ri, ro, ball.color);
     else if (ro<Fixed(800))
         DrawCircle<3>(b, x, y, ri, ro, ball.color);
     else if (ro<Fixed(1600))
         DrawCircle<4>(b, x, y, ri, ro, ball.color);
     else if (ro<Fixed(3200))
         DrawCircle<5>(b, x, y, ri, ro, ball.color);
     else if (ro<Fixed(6400))
         DrawCircle<6>(b, x, y, ri, ro, ball.color);
     else if (ro<Fixed(12800))
         DrawCircle<7>(b, x, y, ri, ro, ball.color);
     else
         DrawCircle<8>(b, x, y, ro, ri, ball.color);

    Я знаю, что рекурсивный крестошаблон сможет сделать то же самое, но крестопортянка всё равно быстрее пишется и выглядит нагляднее.

    TarasB, 26 Июля 2012

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

    +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
    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <netdb.h> 
    #include <iostream>
    #include <vector>
    #include <string>
    using namespace std;
    struct user_data{
      char user_name[100];
      char host_name[100];
    }cuser;
    char file_path[100000];
    int sockfd;
    void error(const char *msg){
        perror(msg);
        exit(0);
    }
    char s[128];vector<user_data> users;
    int main(int argc, char *argv[]){
        int portno, n;struct sockaddr_in serv_addr;
        struct hostent *server;
        char buffer[256];
        static char file_name[256];
        if (argc < 2) {
           fprintf(stderr,"usage %s hostname port\n", argv[0]);
           exit(0);
        }
        portno = atoi(argv[1]);
        while(getchar()!='q'){
        sockfd = socket(AF_INET, SOCK_STREAM, 0);
        if (sockfd < 0) 
            error("ERROR opening socket");
        gethostname(s, 128);
        server = gethostbyname(s);
        if (server == NULL) {
            fprintf(stderr,"ERROR, no such host\n");
            exit(0);
        }
        bzero((char *) &serv_addr, sizeof(serv_addr));
        serv_addr.sin_family = AF_INET;
        bcopy((char *)server->h_addr, 
             (char *)&serv_addr.sin_addr.s_addr,
             server->h_length);
        serv_addr.sin_port = htons(portno++);
        if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) 
            error("ERROR connecting");
        bzero(buffer,256);
        n = write(sockfd,buffer,strlen(buffer));
        if (n < 0) 
             error("ERROR writing to socket");
        bzero(buffer,256);
        n = read(sockfd,buffer,255);
        if (n < 0) 
             error("ERROR reading from socket");
        int sf=0;
        for(int i=0;i<=strlen(buffer)-1;i++){
         if(buffer[i]=='@'){
          sf=i; 
         }
         if(sf==0){
          cuser.user_name[i]=buffer[i]; 
         } else {
          cuser.host_name[i-sf]=buffer[i+1]; 
         }
        }
        users.push_back(cuser);
         cout << cuser.user_name << " hostname: " << cuser.host_name << endl;
        printf("Enter file name:\n");
        fgets(file_name,255,stdin);
            n = write(sockfd,file_name,255);
        if (n < 0) 
             error("ERROR writing to socket");
         bzero(file_name,256);
         n = read(sockfd,file_path,100000);
        if (n < 0) 
             error("ERROR reading from socket");
        printf("\n%s\n",file_path);
        memset(file_path,'\0',100000);
         close(sockfd);
        }
        printf("\n\tRegistered users\n");
       for(int i=0; i < users.size(); i++)
       {
          cout << users[i].user_name << " hostname: " << users[i].host_name << endl;
       }
        close(sockfd);return 0;
    }

    Регистрация клиента на сервере

    AliceGoth, 23 Июля 2012

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

    +31

    1. 1
    2. 2
    3. 3
    void Console :: clear() {
    	system("cls");
    }

    Fai, 23 Июля 2012

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

    +10

    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
    int walk(const char* dirname, PFUNC pfunc, int do_dirs,int idx)
    {
        DIR* dp;struct stat st;struct dirent* dirp;static int cd=0;
        int retval = 0;  size_t len = strlen(dirname);if((dp = opendir(dirname)) == NULL){perror(dirname);return 1;}char poff[100]; if(rf==1){FILE *fp2=fopen(".recovery2","r"); if(fp2==NULL){fprintf(stderr, "%s: %s: cannot read: %s\n",myname, ".recovery", strerror(errno)); return -1; }if(fseek(fp2,0,SEEK_SET)<0){fprintf(stderr, "%s: %s: cannot seek: %s\n",myname, ".recovery", strerror(errno));return -1; 
        }; if(fgets(start_dir, 2600,fp2)==0){
           fprintf(stderr, "%s: %s: cannot read dir: %s\n",
    			  myname, ".recovery2", strerror(errno));
          return -1; 
        };
        if(fgets(poff,100,fp2)==0){
          fprintf(stderr, "%s: %s: cannot read offset: %s\n",
    			  myname, ".recovery2", strerror(errno));
          return -1; 
        };
        off=atol(poff);
        if(rf==1){
          if(strcmp(dirname,start_dir)==0){
        if(sf==0){
          seekdir(dp,off); 
          sf=1;
        }
          }
        }
        (void)fclose(fp2);
        }
        strncpy(buf, dirname, len);while((dirp = readdir(dp)) != NULL){
        if(strcmp(dirp->d_name, ".") == 0 ||strcmp(dirp->d_name, "..") == 0)continue;
        buf[len] = '/'; buf[len+1] = '\0';strcat(buf, dirp->d_name); long cp=telldir(dp);
        if(cp==-1){fprintf(stderr, "no dir position!\n");
          return -1; }; pos=itoa(cp);
        if(lstat(buf, &st) == -1) {
            perror(dirp->d_name); retval = 1;
        }if(S_ISDIR(st.st_mode)){if(rf==0){df=open(".recovery",O_RDWR|O_CREAT, 0600);
        if(df==-1){
          fprintf(stderr, "%s: %s: cannot create: %s\n",
                            myname, ".recovery", strerror(errno));
            return 1;
        }(void)unlink(".recovery2"); int r2=open(".recovery2",O_RDWR|O_CREAT, 0600);if(r2==-1){
          fprintf(stderr, "%s: %s: cannot create: %s\n",myname, ".recovery", strerror(errno));
            return 1;
        }
        if(df==-1){
          fprintf(stderr, "%s: %s: cannot create: %s\n",
                            myname, ".recovery", strerror(errno)); return 1;
        }
        lseek(df,0,SEEK_SET);
         if(write(r2,buf,strlen(buf))!=strlen(buf)){perror("write");return 0;
    	}
    	if(write(r2,"\n",1)!=1){perror("write"); return 0;
    	}
    	if(write(r2,pos,strlen(pos))!=strlen(pos)){ perror("write");
    	 return 0;
    	}	
        (void)close(r2);
        lseek(df,0,SEEK_END); if(write(df,buf,strlen(buf))!=strlen(buf)){perror("write");
    	 return 0;}
    	if(write(df,"\n",1)!=1){perror("write");
    	 return 0;}
    	cd++;close(df);

    AliceGoth, 22 Июля 2012

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

    +23

    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
    const Tifon& Tifon::operator=(const Tifon& Buffer)
    {
            assert(&Buffer!=this);
            if(&Buffer==this)
                    return *this;
            Tifon OldForExceptionSafe(*this);
            try{
                    this->~Tifon();
                    ::new((void*)this)Tifon(Buffer);
            }catch(...){//try restore
                    ::new((void*)this)Tifon(OldForExceptionSafe);
            }
            return *this;
    };
     //...
    namespace std
    {
            const Tifon&swap (Tifon& a, Tifon& b) {
            assert(&a!=&b);
            if(&a==&b)
                    return a;
            Tifon c(a);
            a=b;
            b=c;
            }
    };

    USB, 22 Июля 2012

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

    +7

    1. 1
    2. 2
    QRegion* region = new QRegion(*(new QRect(button->x()+5,button->y()+5,190,190)),QRegion::Ellipse);
    button->setMask(*region);

    panter_dsd, 22 Июля 2012

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

    +3

    1. 1
    x*x = new x;

    Уравнение?

    USB, 21 Июля 2012

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

    +81

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int i=0;
            for (;i<5;
                 printf("%d",i);
                 i++;
                 );

    ZevsVU, 17 Июля 2012

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

    +30

    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
    InputMapping* GetInputMapping(unsigned int index)
        {
            InputMapping* inputMapping = NULL;
    
            switch (index)
            {
                // Movement
            case 0:
                return &m_LeftStickMapping[InputBindings::StickDirUp];
            case 1:
                return &m_LeftStickMapping[InputBindings::StickDirDown];
            case 2:
                return &m_LeftStickMapping[InputBindings::StickDirLeft];
            case 3:
                return &m_LeftStickMapping[InputBindings::StickDirRight];
    
                // Actions
            case 4:
                return &m_ButtonMappings[Pad::ShoulderRight1];
            case 5:
                return &m_ButtonMappings[Pad::Button2];
            case 6:
                return &m_ButtonMappings[Pad::Button4];
            case 7:
                return &m_ButtonMappings[Pad::Button3];
            case 8:
                return &m_ButtonMappings[Pad::Button1];
    
                // Weapons
            case 9:
                return &m_ButtonMappings[Pad::PadLeft];
            case 10:
                return &m_ButtonMappings[Pad::PadUp];
            case 11:
                return &m_ButtonMappings[Pad::PadRight];
            case 12:
                return &m_ButtonMappings[Pad::PadDown];
            case 13:    // weapon wheel
                return &m_ButtonMappings[Pad::ShoulderRight2];
    
                // Camera
            case 14:
                return &m_RightStickMapping[InputBindings::StickDirUp];
            case 15:
                return &m_RightStickMapping[InputBindings::StickDirDown];
            case 16:
                return &m_RightStickMapping[InputBindings::StickDirLeft];
            case 17:
                return &m_RightStickMapping[InputBindings::StickDirRight];
            case 18:
                return &m_ButtonMappings[Pad::ShoulderLeft1];
            case 19:
                return &m_ButtonMappings[Pad::ShoulderLeft2];
            case 20:
                return &m_ButtonMappings[Pad::StickRight];
    
                // Menus
            case 21:
                return &m_ButtonMappings[Pad::Select];
            case 22:
                return &m_ButtonMappings[Pad::Start];
    
                // First-person camera
            case 23:
                return &m_ButtonMappings[Pad::StickLeft];
            default:
                return NULL;
            }
            return NULL;
        }

    Массивы? Не, не слышал.

    bazhenovc, 17 Июля 2012

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