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

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

    −117

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function loadFromDecString(colorData:String, splitter:String = " "):void
    {
    	var colorArray:Array = colorData.split(splitter);
    	if(colorArray.length != 3)
    		return;
    	mRed = colorArray[0] * 0x1;
    	mGreen = colorArray[1] * 0x1;
    	mBlue = colorArray[2] * 0x1;
    }

    Чудеса в решете

    Werdn, 30 Августа 2011

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #include "alloca.h"
    //...
    template<class o>
    o*MakeOAtStack(){
    return (o*)alloca(sizeof(o));};//;;;Оптимизировоной operator new nothrow

    Говногость, 28 Августа 2011

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

    +147

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    void  Character::getWalkScreenDirection(SPVector& dst) {
    	float stick_y = 0.0f, stick_x = 0.0f;
    	/*if(isPadMove())*/	{
    		stick_y = getOffsetLY();
    		stick_x = getOffsetLX();
    	}/*else*/{
    		//stick_y =  angleAC_DIRECTION[animator.animation.getDirection()][0];
    		//stick_x =  angleAC_DIRECTION[animator.animation.getDirection()][1];
    		/*
    		if(stick_y == 0 && stick_x == 0){
    			animator.animation.set(AC_DIRECTION_NONE);   // stop walking
    			animator.animation.set(AC_MOVEMENT_IDLE);
    			animator.animation.update();
    		}*/	}
      dst.asg(0,0,0);
      /* if(animator.animation.getDirection() == AC_DIRECTION_NONE){  
        //CameraCore* camera = game.get_camera();
        camera = game.get_camera();
        cam_up = camera->up();
        SPVector up_tmp = camera->up();
        SPVector look = camera->look();
        SPVector look_tmp = camera->look();
        cam_right = up_tmp.cross(look_tmp);    
        return;
      } */
      SPPosition current; 
      model.getRootPose(current);
      bool isRun = this->isRun();
      if(animator.getTarget()){
        if(animator.getTarget()->get_run(current, isRun)){ // run stance can overwrite depend from target
        state(CharacterFlags_MODE_SWAPRUN, true);
        state(CharacterFlags_MODE_RUN,isRun);
        }
      }  
      CameraCore* camera_compare = game.get_camera(); 
      SPVector cam_compare_pos = camera_compare->pos();
      if(cam_compare_pos != cam_pos) {
        if(first_time) {
          cam_time = game.time.system.current_value(1); 
          cam_time /= 1000;
          first_time = false;      
          first_stick_x = stick_x;  //premiere fois : on rйcup la position du stick en x et y
          first_stick_y = stick_y;
        }
        double move_time = game.time.system.current_value(1);
        move_time /= 1000;
        if(move_time - cam_time < delta_time) {
          //stick_y = first_stick_y; 
          //stick_x = first_stick_x;  
          /*if(dst.len() != 0)
          {
          //animator.animation.set(AC_DIRECTION_FORWARD);  // for the animation
          animator.animation.enable(true);
          animator.animation.set(isRun?AC_MOVEMENT_RUN:AC_MOVEMENT_WALK);
          dst.norm();
          model.setDirection(dst);                     // facing the direction
          }  
          return;*/
        }
      }
      if(stick_y==0 && stick_x==0) initializeCameraAxis();
      SPVector new_direction;
      new_direction.asg(stick_x, 0, stick_y);
      if(new_direction.len() != 0)  new_direction.norm();
      if(direction_reference.len() != 0)  direction_reference.norm();
      float scalar_product = new_direction.dot(direction_reference);
      if(fabs(scalar_product) <= delta) {
        direction_reference.asg(new_direction);
        initializeCameraAxis();
      }  
      if(cam_compare_pos == cam_pos || (cam_compare_pos != cam_pos && fabs(scalar_product) <= delta)) {
        first_time = true;
        SPVector up = cam_up;
        SPVector right = cam_right;
        up.y = 0;
        right.y = 0;    
    //     CameraCore* camera_2 = game.get_camera();    //rйtablissement d'une camйra inversйe
    //     SPPosition pos_test = camera_2->sview();
    //     SPVector vec_test = pos_test.c;    
        SPVector vec_test = cam_pos;
        SPVector vec_stock;
        vec_stock.asg(69.8761444,2.45131993,117.599548);
        if(vec_test.equal(vec_stock,0.0000001f)) {
          up.x = - up.x;
          up.z = - up.z;
        }
        ////////////////
        if(up.len() != 0)  up.norm();
        if(right.len() != 0) right.norm();
        up *= stick_y;
        right *= stick_x;
        dst = up;                                              // update destination vector
        dst += right;  // i.e. dst = up + right 
       if(dst.len() != 0)  {
         //animator.animation.set(AC_DIRECTION_FORWARD);  // for the animation
         animator.animation.enable(true);
         animator.animation.set(isRun?AC_MOVEMENT_RUN:AC_MOVEMENT_WALK);
         dst.norm();
         model.setDirection(dst);                     // facing the direction
       }

    Такой код в нашем движке.
    ЗЫ. Код немного ужат, так как не помещался в 100 строк.

    MAGnit, 26 Августа 2011

    Комментарии (8)
  5. Java / Говнокод #7650

    +64

    1. 1
    2. 2
    3. 3
    4. 4
    boolean i = true;
      while (i){
       out.println("\n");
      }

    Нашлось в недрах работающей программы

    red_octopus, 25 Августа 2011

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

    +147

    1. 1
    var that = this;

    просто и со вкусом

    rk4n, 25 Августа 2011

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

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    if (ID_Pers == (decimal)r["Код_ФизЛица"])
        query = new SqlCommand("UPDATE СписокФизическихЛиц SET ДатаРождения=CONVERT(DateTime,'" + Date + "',104) where  ID='" + r["Код_ФизЛица"].ToString() + "'", conn);
    else
        query = new SqlCommand("UPDATE СписокФизическихЛиц SET ДатаРождения=CONVERT(DateTime,'" + Date + "',104) where  ID='" + ID_Pers.ToString() + "'", conn);

    Классический говнокод.

    exile, 23 Августа 2011

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

    +178

    1. 1
    #define float double

    Так в последнем, полученном мною, для поддержки проекте произвели увеличение точности расчётов.

    Говногость, 20 Августа 2011

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

    −88

    1. 1
    2. 2
    exec "a" * 300000000 + " = 'FUCKING_LONG_VARIABLE'" # Создание переменной с длиннннным именем
    exec "print " + ("a" * 300000000) # Выведет 'FUCKING_LONG_VARIABLE'

    Это был эксперимент (не повторять дома!). Хотелось узнать количество значащих символов в имени переменной, оказалось что все:).
    Первая строка кода ужирает около 270 МБ памяти.

    Niceblack, 17 Августа 2011

    Комментарии (8)
  10. Си / Говнокод #7546

    +139

    1. 1
    2. 2
    3. 3
    4. 4
    char *reg = data;
    char *temp = "blahblah is ";
    
    strcat(temp,(const char*)"reg[4]");

    Как оказывается на Си можно конкатенировать строки

    Kortez, 15 Августа 2011

    Комментарии (8)
  11. SQL / Говнокод #7489

    −854

    1. 1
    2. 2
    3. 3
    4. 4
    if rtrim(@parent_ID) = null
        select '' as Parent_ID, '' as Parent_Name where 1 = 2
      else
        select isnull(@parent_ID, '') as Parent_ID, isnull(@parent_name, '') as Parent_Name

    dosGovno, 08 Августа 2011

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