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

    Всего: 246

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

    +131

    1. 1
    2. 2
    // bg_pmove.c -- both games player movement code
    // takes a playerstate and a usercmd as input and returns a modifed playerstate

    Дальше идут 11 тысяч строк нечитаемого говна. Это вообще нормально?!

    gost, 03 Декабря 2014

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

    +136

    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
    int Sys_FunctionCmp(void *f1, void *f2) {
    
    	int i, j, l;
    	byte func_end[32] = {0xC3, 0x90, 0x90, 0x00};
    	byte *ptr, *ptr2;
    	byte *f1_ptr, *f2_ptr;
    
    	ptr = (byte *) f1;
    	if (*(byte *)ptr == 0xE9) {
    		//Com_Printf("f1 %p1 jmp %d\n", (int *) f1, *(int*)(ptr+1));
    		f1_ptr = (byte*)(((byte*)f1) + (*(int *)(ptr+1)) + 5);
    	}
    	else {
    		f1_ptr = ptr;
    	}
    	//Com_Printf("f1 ptr %p\n", f1_ptr);
    
    	ptr = (byte *) f2;
    	if (*(byte *)ptr == 0xE9) {
    		//Com_Printf("f2 %p jmp %d\n", (int *) f2, *(int*)(ptr+1));
    		f2_ptr = (byte*)(((byte*)f2) + (*(int *)(ptr+1)) + 5);
    	}
    	else {
    		f2_ptr = ptr;
    	}
    	//Com_Printf("f2 ptr %p\n", f2_ptr);
    
    #ifdef _DEBUG
    	sprintf((char *)func_end, "%c%c%c%c%c%c%c", 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC3);
    #endif
    	for (i = 0; i < 1024; i++) {
    		for (j = 0; func_end[j]; j++) {
    			if (f1_ptr[i+j] != func_end[j])
    				break;
    		}
    		if (!func_end[j]) {
    			break;
    		}
    	}
    #ifdef _DEBUG
    	l = i + 7;
    #else
    	l = i + 2;
    #endif
    	//Com_Printf("function length = %d\n", l);
    
    	for (i = 0; i < l; i++) {
    		// check for a potential function call
    		if (*((byte *) &f1_ptr[i]) == 0xE8) {
    			// get the function pointers in case this really is a function call
    			ptr = (byte *) (((byte *) &f1_ptr[i]) + (*(int *) &f1_ptr[i+1])) + 5;
    			ptr2 = (byte *) (((byte *) &f2_ptr[i]) + (*(int *) &f2_ptr[i+1])) + 5;
    			// if it was a function call and both f1 and f2 call the same function
    			if (ptr == ptr2) {
    				i += 4;
    				continue;
    			}
    		}
    		if (f1_ptr[i] != f2_ptr[i])
    			return qfalse;
    	}
    	return qtrue;
    }

    Хмм...

    gost, 03 Декабря 2014

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

    +132

    1. 1
    2. 2
    3. 3
    #ifndef M_PI
    #define M_PI		3.14159265358979323846f	// matches value in gcc v2 math.h
    #endif

    Сишкопроблемы.

    gost, 03 Декабря 2014

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

    +50

    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
    switch (player->collision(pos, getRadius()))
    		{
    		case SIDE_UP:
    			ySpeed = -player->baseSpeed.y + player->currentSpeed.y;
    			xSpeed = xSpeed - player->currentSpeed.x;
    			if (abs(xSpeed) > maxXSpeed)
    				xSpeed = maxXSpeed * (xSpeed < 0 ? -1 : 1);
    			break;
    		case SIDE_DOWN:
    			setPosition(getPosition().x, getPosition().y - getRadius() * 2 - 20);
    			ySpeed = -player->baseCornerSpeed.y - player->currentSpeed.y;
    			xSpeed = xSpeed - player->currentSpeed.x; 
    			if (abs(xSpeed) > maxXSpeed)
    				xSpeed = maxXSpeed * (xSpeed < 0 ? -1 : 1);
    			break;
    		case SIDE_RIGHT:
    		case SIDE_LEFT:
    			xSpeed = -xSpeed + player->currentSpeed.x;
    			break;
    		case CORNER_LEFT_UP:
    			ySpeed = -player->baseCornerSpeed.y;
    			xSpeed = -player->baseCornerSpeed.x;
    			break;
    		case CORNER_RIGHT_UP:
    			ySpeed = -player->baseCornerSpeed.y;
    			xSpeed = player->baseCornerSpeed.x;
    			break;
    		case CORNER_RIGHT_DOWN:
    			ySpeed = player->baseCornerSpeed.y;
    			xSpeed = player->baseCornerSpeed.x;
    			break;
    		case CORNER_LEFT_DOWN:
    			ySpeed = player->baseCornerSpeed.y;
    			xSpeed = -player->baseCornerSpeed.x;
    			break;
    		}

    Только велосипедный Collision detection, только хардкор!

    gost, 27 Ноября 2014

    Комментарии (0)
  6. Си / Говнокод #17179

    +133

    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
    if (*wpPat == L'\\')
        {
          wpCharStart=wpPat;
          if (++wpPat >= wpMaxPat) goto Error;
    
          if (*wpPat == L'x')
          {
            if (++wpPat >= wpMaxPat) goto Error;
    
            if (*wpPat == L'{')
            {
              wpStrTmp=++wpPat;
              for (;;)
              {
                if (wpPat >= wpMaxPat) goto Error;
                if (*wpPat++ == L'}') break;
              }
              if (lpREGroupItem->nGroupLen != -1 && !bClassOpen)
              {
                nPatChar=(int)hex2decW(wpStrTmp, (wpPat - 1) - wpStrTmp);
                if (nPatChar == -1)
                {
                  wpPat=wpStrTmp;
                  goto Error;
                }
                if (nPatChar <= MAXWORD)
                  lpREGroupItem->nGroupLen+=1;
                else
                  lpREGroupItem->nGroupLen+=2;
              }
            }
            else
            {
              if (wpPat + 2 > wpMaxPat)
                goto Error;
              wpPat+=2;
              if (lpREGroupItem->nGroupLen != -1 && !bClassOpen)
                ++lpREGroupItem->nGroupLen;
            }
          }
          else if (*wpPat == L'u')
          {
            if (wpPat + 5 > wpMaxPat)
              goto Error;
            wpPat+=5;
            if (lpREGroupItem->nGroupLen != -1 && !bClassOpen)
              ++lpREGroupItem->nGroupLen;
          }

    Регулярные велосипеды.
    Akelpad.

    gost, 25 Ноября 2014

    Комментарии (1)
  7. Си / Говнокод #17178

    +133

    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
    if (wParam == MI_CMDLINEBEGIN)
              return xstrcpyW((void *)lParam, wpCmdLineBegin);
            if (wParam == MI_CMDLINEEND)
              return xstrcpyW((void *)lParam, wpCmdLineEnd);
            if (wParam == MI_SHOWMODIFY)
              return moCur.dwShowModify;
            if (wParam == MI_STATUSPOSTYPE)
              return moCur.dwStatusPosType;
            if (wParam == MI_STATUSUSERFORMAT)
              return xstrcpynW((void *)lParam, moCur.wszStatusUserFormat, MAX_PATH);
            if (wParam == MI_WORDBREAKCUSTOM)
              return moCur.dwWordBreakCustom;
            if (wParam == MI_PAINTOPTIONS)
              return moCur.dwPaintOptions;
            if (wParam == MI_EDITSTYLE)
              return moCur.dwEditStyle;
            if (wParam == MI_RICHEDITCLASS)
              return moCur.bRichEditClass;
            if (wParam == MI_AKELADMINRESIDENT)
              return moCur.bAkelAdminResident;
            if (wParam == MI_DATELOGFORMAT)
              return xstrcpynW((void *)lParam, moCur.wszDateLogFormat, 128);
            if (wParam == MI_DATEINSERTFORMAT)
              return xstrcpynW((void *)lParam, moCur.wszDateInsertFormat, 128);
            if (wParam == MI_AKELUPDATEROPTIONS)
              return xstrcpynW((void *)lParam, moCur.wszAkelUpdaterOptions, MAX_PATH);
            if (wParam == MI_URLCOMMAND)
              return xstrcpynW((void *)lParam, moCur.wszUrlCommand, MAX_PATH);
            if (wParam == MI_TABNAMEFIND)
              return xstrcpynW((void *)lParam, moCur.wszTabNameFind, MAX_PATH);
            if (wParam == MI_TABNAMEREP)
              return xstrcpynW((void *)lParam, moCur.wszTabNameRep, MAX_PATH);
            if (wParam == MI_ONTOP)
              return moCur.bOnTop;
            if (wParam == MI_STATUSBAR)
              return moCur.bStatusBar;
            if (wParam == MI_KEEPSPACE)
              return moCur.bKeepSpace;
            if (wParam == MI_WATCHFILE)
              return moCur.bWatchFile;
            if (wParam == MI_SAVETIME)
              return moCur.bSaveTime;
            if (wParam == MI_SINGLEOPENFILE)
              return moCur.bSingleOpenFile;
            if (wParam == MI_SINGLEOPENPROGRAM)
              return moCur.dwSingleOpenProgram;
            if (wParam == MI_TABOPTIONSMDI)
              return moCur.dwTabOptionsMDI;
            if (wParam == MI_EXECUTECOMMAND)

    И такого больше сотни строк.
    Akelpad.

    gost, 25 Ноября 2014

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

    +132

    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
    LRESULT CALLBACK MainProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
      if (uMsg == WM_CREATE)
      {
        int *lpSBParts;
        int iBorders[3];
        CLIENTCREATESTRUCT ccs;
        DWORD dwClassStyle;
        RECT rcRect;
        HMENU hMenu;
    
        hMainWnd=hWnd;
        hPopupEdit=GetSubMenu(hPopupMenu, MENU_POPUP_EDIT);
        hPopupView=GetSubMenu(hPopupMenu, MENU_POPUP_VIEW);
        hPopupCodepage=GetSubMenu(hPopupMenu, MENU_POPUP_CODEPAGE);
        hPopupOpenCodepage=GetSubMenu(hPopupCodepage, MENU_POPUP_CODEPAGE_OPEN);
        hPopupSaveCodepage=GetSubMenu(hPopupCodepage, MENU_POPUP_CODEPAGE_SAVE);
        hPopupHeadline=GetSubMenu(hPopupMenu, MENU_POPUP_HEADLINE);
    
        hMenu=GetSubMenu(hMainMenu, MENU_FILE_POSITION);
        hMenuRecentFiles=GetSubMenu(hMenu, MENU_FILE_RECENTFILES_4X);
        hMenu=GetSubMenu(hMainMenu, MENU_VIEW_POSITION);
        hMenuLanguage=GetSubMenu(hMenu, MENU_VIEW_LANGUAGE_4X);

    Плотная простынка, спать можно.
    Akelpad.

    gost, 25 Ноября 2014

    Комментарии (0)
  9. Си / Говнокод #17172

    +134

    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
    //// AEM_* AkelEdit control messages
    
      if (uMsg >= WM_USER)
      {
        if (uMsg >= AEM_CANUNDO)
          goto CanUndo;
    
        //Text retrieval and modification
        if (uMsg == AEM_EXSETTEXTA)
        {
          AESETTEXTA *at=(AESETTEXTA *)lParam;
    
          return AE_SetTextAnsi(ae, at->nCodePage, at->pText, at->dwTextLen, at->nNewLine);
        }
        if (uMsg == AEM_EXSETTEXTW)
        {
          AESETTEXTW *at=(AESETTEXTW *)lParam;
    
          return AE_SetText(ae, at->pText, at->dwTextLen, at->nNewLine, FALSE);
        }
        if (uMsg == AEM_SETTEXTA)
        {
          return AE_SetTextAnsi(ae, CP_ACP, (char *)lParam, wParam, AELB_ASINPUT);
        }
        if (uMsg == AEM_SETTEXTW)
        {
          return AE_SetText(ae, (wchar_t *)lParam, wParam, AELB_ASINPUT, FALSE);
        }
        if (uMsg == AEM_APPENDTEXTA)
        {
          AEAPPENDTEXTA *at=(AEAPPENDTEXTA *)lParam;
    
          AE_AppendTextAnsi(ae, at->nCodePage, at->pText, at->dwTextLen, at->nNewLine);
          return 0;
        }
        if (uMsg == AEM_APPENDTEXTW)
        {
          AEAPPENDTEXTW *at=(AEAPPENDTEXTW *)lParam;
    
          AE_AppendText(ae, at->pText, at->dwTextLen, at->nNewLine);
          return 0;
        }
        if (uMsg == AEM_REPLACESELA)
        {
          AEREPLACESELA *rs=(AEREPLACESELA *)lParam;
    
          AE_ReplaceSelAnsi(ae, rs->nCodePage, rs->pText, rs->dwTextLen, rs->nNewLine, rs->dwFlags, rs->ciInsertStart, rs->ciInsertEnd);
          return 0;
        }
        if (uMsg == AEM_REPLACESELW)
        {
          AEREPLACESELW *rs=(AEREPLACESELW *)lParam;
    
          AE_ReplaceSel(ae, rs->pText, rs->dwTextLen, rs->nNewLine, rs->dwFlags, rs->ciInsertStart, rs->ciInsertEnd);
          return 0;
        }
        if (uMsg == AEM_GETTEXTRANGEA)
        {
          AETEXTRANGEA *tr=(AETEXTRANGEA *)lParam;
    
          return AE_GetTextRangeAnsi(ae, tr->nCodePage, tr->lpDefaultChar, tr->lpUsedDefChar, &tr->cr.ciMin, &tr->cr.ciMax, tr->pBuffer, tr->dwBufferMax, tr->nNewLine, tr->bColumnSel, tr->bFillSpaces);
        }

    И далее около сотни if'ов в таком духе.
    AkelPad

    gost, 25 Ноября 2014

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

    +156

    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
    var old = 47;
    
            function getRate() {
                $.ajax({
                      url: "http://query.yahooapis.com/v1/public/yql?q=select%20%2a%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22USDRUB%22%29&env=store://datatables.org/alltableswithkeys",
                      dataType: "text"
                }).done(function(msg) {
                    var value = /<Rate>(.+)<\/Rate>/.exec(msg)[1];
                    //$("#p-rate").html(/<Rate>(.+)<\/Rate>/.exec(msg)[1]);
                    $("#p-rate").html(value);
                    if(value > old) $("#p-message").html("МНЕ ОТ ЭТОГО ТОЛЬКО ЛУЧШЕ! ТОЛЬКО НА ПОЛЬЗУ!");
                    else if(value < old) $("#p-message").html("СКАЛЕН! СКАЛЕН!");
                    else $("#p-message").html("МНОГОХОДОВОЧКА!");
                    old = value;
                });
            }
    
            setInterval(getRate,1500);

    gost, 24 Ноября 2014

    Комментарии (128)
  11. PHP / Говнокод #17125

    +155

    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
    <?php
     
    // Default: http://<host>/<dir>/<filename>.php?iter1=64&width=600&height=400&coef=32
     
    function BN($n, $l, $r) {return $n>$l && $n<=$r;}
    function SQR($a) {return $a*$a;}
     
    define("COEF",	$_GET["coef"]);
    $iter1	=	$_GET["iter1"];
    $width	=	$_GET["width"];
    $height	=	$_GET["height"];
     
    header("Content-type: image/png");
     
    $img	=	imagecreatetruecolor($width, $height);
    $iter2	=	0.01/($width/300);
    $yy	=	-1;
     
    for ($y = -1; $y < 1; $y = $y + $iter2) {
    	$yy++; $xx=-1;
    	for($x = -2; $x < 1; $x = $x + $iter2) {
    		$xx++;
    		$Cx	=	$x;
    		$Cy	=	$y;
    		$X	=	$x;
    		$Y	=	$y;
    		$ix	=	0;
    		$iy	=	0;
    		$n	=	0;
    		while ((SQR($ix) + SQR($iy) < 4) and ($n < $iter1)) {
    			$ix 	=	SQR($X) - SQR($Y) + $Cx;
    			$iy 	=	2*$X*$Y + $Cy;
    			$X	=	$ix;
    			$Y	=	$iy;
    			$n++;
    		}
    		if(BN($n,0,7)) $col = imagecolorallocate($img,COEF*$n,0,0);
    		elseif(BN($n,7,14)) $col = imagecolorallocate($img,COEF*$n,COEF*$n,0);
    		elseif(BN($n,14,21))$col = imagecolorallocate($img,COEF*$n,0,COEF*$n);
    		elseif(BN($n,21,28))$col = imagecolorallocate($img,0,COEF*$n,0);
    		elseif(BN($n,28,35))$col = imagecolorallocate($img,COEF*$n,COEF*$n,0);
    		elseif(BN($n,35,42))$col = imagecolorallocate($img,0,COEF*$n,COEF*$n);
    		elseif(BN($n,42,49))$col = imagecolorallocate($img,0,0,COEF*$n);
    		elseif(BN($n,49,56))$col = imagecolorallocate($img,COEF*$n,0,COEF*$n);
    		elseif(BN($n,56,64))$col = imagecolorallocate($img,0,COEF*$n,COEF*$n);
    		imagesetpixel($img, $xx, $yy, $col);
    	}
    }
    imagepng($img);
    imagedestroy($img);
    ?>

    https://ru.wikipedia.org/wiki/%D0%9C%D0%BD%D0%BE%D0%B6%D0%B5%D1%81%D1% 82%D0%B2%D0%BE_%D0%9C%D0%B0%D0%BD%D0%B4% D0%B5%D0%BB%D1%8C%D0%B1%D1%80%D0%BE%D1%8 2%D0%B0

    gost, 17 Ноября 2014

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