1. Список говнокодов пользователя mittorn

    Всего: 37

  2. Си / Говнокод #19873

    −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
    typedef float		vec_t;
    ...
    typedef vec_t		matrix3x4[3][4];
    ...
    void Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matrix3x4 in2 );
    ...
    static matrix3x4		g_bonestransform[MAXSTUDIOBONES];
    static matrix3x4		g_rotationmatrix;
    ...
        matrix3x4		bonematrix;
    ...
        Matrix3x4_ConcatTransforms( g_bonestransform[i], g_rotationmatrix, bonematrix );

    Поясните, что не так?

    Ругань gcc такова:
    client/gl_studio.c:1076:5: warning: passing argument 2 of ‘Matrix3x4_ConcatTransforms’ from incompatible pointer type [enabled by default]
    common/mathlib.h:144:6: note: expected ‘const vec_t (*)[4]’ but argument is of type ‘vec_t (*)[4]’
    client/gl_studio.c:1076:5: warning: passing argument 3 of ‘Matrix3x4_ConcatTransforms’ from incompatible pointer type [enabled by default]
    common/mathlib.h:144:6: note: expected ‘const vec_t (*)[4]’ but argument is of type ‘vec_t (*)[4]’

    Ведь в функцию, принимающую const char* можно передавать char*? Что же тогда с матрицами то не так?

    mittorn, 24 Апреля 2016

    Комментарии (65)
  3. Си / Говнокод #19835

    −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
    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 <gtk/gtk.h>
    
    int main(int argc, char *argv[], GtkWidget* vbox) {
    
    	GtkWidget *window;
    
    	gtk_init(&argc, &argv);
    
    	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    	gtk_window_set_default_size(GTK_WINDOW(window), 450, 700);
    	gtk_window_set_title(GTK_WINDOW(window), "Model Viewer (Version 36)");
    
    	//test();
    
    	menubar(window);
    	opengl(window);
    
    	gtk_widget_show_all(window);
    
    	gtk_main();
    
    	return 0;
    }

    https://www.linux.org.ru/forum/development/12523254

    mittorn, 17 Апреля 2016

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

    +4

    1. 1
    2. 2
    3. 3
    typedef class foo_c{
    ...
    } foo_t;

    Почему мне хочется использовать такой синтаксис?

    mittorn, 04 Апреля 2016

    Комментарии (22)
  5. bash / Говнокод #19745

    −51

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    f="effects.h *.cpp"
    for m in SetThink SetTouch SetUse SetBlocked SetMoveDone; do
    m2=`echo $m|sed -e s/Set/Reset/`
    sed -e s/$m[[:space:]]\*\([[:space:]]\*/$m\(/g -e s/$m\([[:space:]]\*\\\&/$m\(/g -e s/$m\([[:space:]]\*NULL[[:space:]]\)/$m2\(\)/g -e s/$m\([[:space:]]*/$m\(\ \\\&/g -e s/$m2\(\)/$m\(\ NULL\ \)/g -i $f
    done

    Добиваемся сборки http://govnokod.ru/18975 в gcc, не ломая совместимости с уже исправленным кодом

    mittorn, 02 Апреля 2016

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

    +3

    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
    FOREACHINLIST(CBrushMip, bm_lnInBrush, penbr->GetBrush()->br_lhBrushMips, itbm)
      {
        CBrushMip &brmip=*itbm;
        FOREACHINDYNAMICARRAY(itbm->bm_abscSectors, CBrushSector, itbsc)
        {
          CBrushSector &bsc=*itbsc;
          FOREACHINSTATICARRAY(itbsc->bsc_abpoPolygons, CBrushPolygon, itbpo)
          {
            CBrushPolygon &bpo=*itbpo;
            CheckOnePolygon(bsc, bpo);
          }
        }
      }

    И такое используется во всём SeriousEngine

    mittorn, 13 Марта 2016

    Комментарии (11)
  7. JavaScript / Говнокод #19507

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    #pragma strict 
     
    function Start () { 
    function OnMouseDown (); { 
     if(name=="new") { Application.LoadLevel("procedural"); } 
     if(name=="set") { } 
     if(name=="exit") { Application.Quit(); } 
     
    } 
     
    }

    mittorn, 21 Февраля 2016

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

    0

    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
    function Calc() {
    
    var af = parseInt(document.getElementsByName("a"));
    var ad=af.value;
    
    var bf = parseInt(document.getElementsByName("b"));
    var bd=bf.value;
    
    var a = parseInt(ad)
    
    var b = parseInt(bd)
    
    alert("Результат: " + (a+b))
    }
    
    function CalcMi() {
    
    var af = parseInt(document.getElementsByName("a"));
    var ad=af.value;
    
    var bf = parseInt(document.getElementsByName("b"));
    var bd=bf.value;
    
    var a = parseInt(ad)
    
    var b = parseInt(bd)
    
    alert("Результат: " + (a-b))
    }
    
    function CalcX() {
    
    var af = parseInt(document.getElementsByName("a"));
    var ad=af.value;
    
    var bf = parseInt(document.getElementsByName("b"));
    var bd=bf.value;
    
    var a = parseInt(ad)
    
    var b = parseInt(bd)
    
    alert("Результат: " + a*b)
    }
    
    function CalcDX() {
    
    var af = parseInt(document.getElementsByName("a"));
    var ad=af.value;
    
    var bf = parseInt(document.getElementsByName("b"));
    var bd=bf.value;
    
    var a = parseInt(ad)
    
    var b = parseInt(bd)
    
    alert("Результат: " + a/b)
    }

    от школьника

    mittorn, 19 Февраля 2016

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

    −21

    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
    import re
    lines = open('gldef.in','r')
    for line in lines:
        print line.replace("BEGIN ","").replace("END","").replace("PREFIX","exp").replace("SECOND","STDCALL") + " {"
        #print "{"
        args = ""
        first = True
        for arg in line[line.index("(")+1:line.index(")")].split(", "):
            if(arg != "void"):
                argsplit = re.split(' |\*', arg)
                #print argsplit[-1]
                if(not(first)):
                    args = args + ", "
                first = False
                args = args + argsplit[-1]
        returnstr = "" if (line.split(' ')[1] == "void") else "return "
        print " "*4+returnstr+line[line.index("PREFIX")+6:line.index("(")+1] + args + ");"
        print "}"
        print ""

    киддискриптинг
    Ни питона ни regexp не знаем, а в сишке текст сложнее обрабатывать.

    mittorn, 17 Августа 2015

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

    −22

    1. 1
    2. 2
    3. 3
    4. 4
    while(!*data!=0xdeadbeef)
    {
        sched_yield();
    }

    Печку заказывали?

    mittorn, 01 Августа 2015

    Комментарии (22)
  11. Си / Говнокод #18157

    +141

    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
    const char *pS;
    		char *pD;
    
    		// clear out new string
    		szNew[0] = '\0';
    
    		pS = pszValue;
    		pD = szNew;
    
    		// step through the string, only copying back in characters that are printable
    		while( *pS )
    		{
    			if( ((byte)*pS) < 32 || ((byte)*pS) > 255 )
    			{
    				pS++;
    				continue;
    			}
    			*pD++ = *pS++;
    		}
    
    		// terminate the new string
    		*pD = '\0';

    Мало того, char в проекте подразумевается signed

    mittorn, 12 Мая 2015

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