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

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

    +2

    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
    #include <iostream>
    #include <Windows.h>
    
    #define OCT_1 0
    #define OCT_2 12
    #define OCT_3 24
    #define OCT_4 36
    #define OCT_5 48
    #define OCT_6 60
    #define OCT_7 72
    #define OCT_8 84
    #define OCT_9 96
    
    #define NOTE_C 0
    #define NOTE_Ch 1
    #define NOTE_Db 1
    #define NOTE_D 2
    #define NOTE_Dh 3
    #define NOTE_Eb 3
    #define NOTE_E 4
    #define NOTE_F 5
    #define NOTE_Fh 6
    #define NOTE_Gb 6
    #define NOTE_G 7
    #define NOTE_Gh 8
    #define NOTE_Ab 8
    #define NOTE_A 9
    #define NOTE_Ah 10
    #define NOTE_Bb 10
    #define NOTE_B 11
    
    long double notes[200];
    
    #define TEMPO 100
    #define LEN1 (120000 / TEMPO)
    #define LEN2 (LEN1 / 2)
    #define LEN4 (LEN1 / 4)
    #define LEN8 (LEN1 / 8)
    #define LEN16 (LEN1 / 16)
    
    #define melody_len 28
    struct s {
    	int key, len;
    	s(int key, int len) {
    		this->key = key;
    		this->len = len;
    	}
    } melody[melody_len] = {
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_C, LEN4),
    	
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_C, LEN4),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_E, LEN4),
    	
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_D, LEN8),
    	s(OCT_4 + NOTE_D, LEN8),
    	
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_5 + NOTE_E, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	s(OCT_4 + NOTE_B, LEN8),
    	
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_5 + NOTE_C, LEN8),
    	s(OCT_4 + NOTE_E, LEN4),
    };
    
    int main(int argc, char** argv) {
    	notes[0] = 32.7032;
    	for(int i = 1; i < 200; ++i)
    		notes[i] = notes[i - 1] * 1.05946309436;
    		
    	for(int i = 0; i < melody_len; ++i) {
    		int key = melody[i].key;
    		int len = melody[i].len;
    		
    		if(key < 0) Sleep(len);
    		else Beep(notes[key], len);
    	}
    	
    	return 0;
    }

    Дохуя мелодия... с 1 класса музыкалки...

    Losyash1337, 27 Мая 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    for(uint64_t i = 0ULL; i <= 999999999ULL; i+= 1)
    {
        long double a =  0.00005l * i; // это чтоб в плавучке не накапливались ошибки.
        somefunction(a);
        ....
    }

    j123123, 26 Мая 2017

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

    +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
    $(document).ready(function(){
    
    		$('.field').click(function(){
    			$('.selected').removeClass('selected');
    			$(this).addClass('selected');
    			$(this).click(function(){
    
    				$('#move').attr('disabled', true);
    			$('.selected, .field').removeClass('visible');
    			$('.field').text('');
    			$('.selected').html('<span id="user"><img src="user.gif"></span>');
    			$('.selected').next().addClass('visible');
    			$('.selected').next().next().next().next().next().next().addClass('visible');
    			$('.selected').next().next().next().next().next().next().next().addClass('visible');
    			$('.selected').next().next().next().next().next().next().next().next().addClass('visible');
    			//$('.selected').addClass('visible');
    			$('.selected').prev().addClass('visible');
    			$('.selected').prev().prev().prev().prev().prev().prev().addClass('visible');
    			$('.selected').prev().prev().prev().prev().prev().prev().prev().addClass('visible');
    			$('.selected').prev().prev().prev().prev().prev().prev().prev().prev().addClass('visible');
    
    			});
    
    ...

    Поле перемещения, написано около года назад :D не знал как можно по-другому

    SardykoIvan, 18 Мая 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    template<typename V>
            constexpr Vector(V&& x, V&& y, V&& z) noexcept(std::is_lvalue_reference<V>::value ?
                    std::is_nothrow_move_constructible<V>::value  :
                    std::is_nothrow_copy_constructible<V>::value) :
                data{std::forward<V>(x), std::forward<V>(y), std::forward<V>(z)} {}

    jangolare, 07 Августа 2016

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

    +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
    public CustomCollection<T> wherePropertyIs(String propertyName, Object value) {
    		CustomCollection<T> lstTemp = new CustomCollection <T>();
    		if (this.size() > 0) {
    			Field foundField = null;
    			for (Field f : this.get(0).getClass().getDeclaredFields()){
    				if (f.getName().equals(propertyName)){
    					foundField = f;
    					break;
    				}
    			}
    			if (foundField != null) {
    				foundField.setAccessible(true);
    				try {
    					for(T obj : this){
    						if (foundField.get(obj).equals(value)){
    							lstTemp.add(obj);
    						}
    					}
    				}catch (IllegalAccessException e){
    					System.out.println(e.getMessage());
    				}
    			}
    		}
    		return lstTemp; 
    	}

    братишка, я тебе Linq на джаве принёс

    bydlan228, 03 Августа 2016

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

    +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
    <?php
    /*
    * System class
    * @package: PerfCMS
    */
    
    class System extends PerfSystem
    {
    	public static function textarea($rows = 5, $cols = 25, $name = 'text', $value = '', $class = '', $id = 'area', $style = '')
    	{
    		if(parent::browserType() == 'web')
    		{
    			Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/js/bbtags.js');
    			return '
    			<div id="tagspanel" class="textarea">
    			<a href="#" title="'. Lang::get('bold_text').'" id="bold" onclick="return bbtags(\'[b]\', \'[/b]\', \'bold\', \''.$id.'\')">'.System::image('bbpanel/bold.png').'<span class="tooltip"></span></a>
    			<a href="#" title="'. Lang::get('italic_text').'" id="italic" onclick="return bbtags(\'[i]\', \'[/i]\', \'italic\', \''.$id.'\')">'.System::image('bbpanel/italic.png').'</a>
    			<a href="#" title="'. Lang::get('underline_text').'" id="underline" onclick="return bbtags(\'[u]\', \'[/u]\', \'underline\', \''.$id.'\')">'.System::image('bbpanel/underline.png').'</a>
    			<a href="#" title="'. Lang::get('strike_text').'" id="strikethrough" onclick="return bbtags(\'[s]\', \'[/s]\', \'strikethrough\', \''.$id.'\')">'.System::image('bbpanel/strikethrough.png').'</a>
    			<a href="#" title="'. Lang::get('quote_text').'" id="blockquote" onclick="return bbtags(\'[quote]\', \'[/quote]\', \'blockquote\', \''.$id.'\')">'.System::image('bbpanel/blockquote.png').'</a>
    			<a href="#" title="'. Lang::get('spoiler_text').'" id="spoiler" onclick="return bbtags(\'[spoiler]\', \'[/spoiler]\', \'spoiler\', \''.$id.'\')">'.System::image('bbpanel/spoiler.png').'</a>
    			<a href="#" title="'. Lang::get('color_text').'" id="color" onclick="return bbtags(\'[color=]\', \'[/color]\', \'color\', \''.$id.'\')">'.System::image('bbpanel/text_color.png').'</a>
    			<a href="#" title="'. Lang::get('url_text').'" id="link" onclick="return bbtags(\'[url=http://]\', \'[/url]\', \'link\', \''.$id.'\')">'.System::image('bbpanel/insert_link.png').'</a>
    			<a href="#" id="image" onclick="return bbtags(\'[img=http://]\', \'[/img]\', \'image\', \''.$id.'\')">'.System::image('bbpanel/image.png').'</a>
    			<a href="#" title="'. Lang::get('video_text').'" id="video" onclick="return bbtags(\'[video]\', \'[/video]\', \'video\', \''.$id.'\')">'.System::image('bbpanel/video.png').'</a>
    			<a href="#" title="'.Lang::get('source_text').'" id="source" onclick="return bbtags(\'[source lang=]\', \'[/source]\', \'source\', \''.$id.'\')">'.System::image('bbpanel/script_code.png').'</a>
    			</div>
    			<textarea name="'.$name.'" rows="'.$rows.'" cols="'.$cols.'"'.(!empty($class) ? ' class="'.$class.'"' : null).(!empty($style) ? ' style="'.$style.'"' : null).' id="'.$id.'">'.(!empty($value) ? $value : null).'</textarea>';
    		}
    		else
    		{
    			return '[<a href="/help/codes">'.Lang::get('bb_codes').'</a> | <a href="/help/smiles">'.Lang::get('smiles').'</a> | <a href="/help/rules">'.Lang::get('rules').'</a> | <a href="/help/">'.Lang::get('help').'</a>]<br/>
    			<textarea name="'.$name.'" rows="'.$rows.'" cols="'.$cols.'"'.(!empty($class) ? ' class="'.$class.'"' : null).(!empty($style) ? ' style="'.$style.'"' : null).' id="'.$id.'">'.(!empty($value) ? $value : null).'</textarea>';
    		}
    	}
    
    
    }

    Весь класс https://gist.github.com/eskrano/bb8fe1bc1e6b22456d68cf3e56bf752b

    eskrano, 30 Июля 2016

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

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?if( $arResult['PROPERTIES']['NOT_ALLOWED']['VALUE'] == 'да' || $arItem["PROPERTIES"]["NOT_ALLOWED"]["VALUE_XML_ID"] == "Y" ) { ?>
    				<div class="alert-empty alert--licence">
    					<?$APPLICATION->IncludeComponent(
    						"bitrix:main.include",
    						"",
    						Array(
    							"AREA_FILE_SHOW" => "file",
    							"PATH" => SITE_DIR."/inc/card_not_allowed.php",
    							"EDIT_TEMPLATE" => ""
    						)
    					);?>

    Платформа Битрикс, очередное творение Lenal в шаблоне компонента.

    Сравнение значения с КИРИЛИЦЕЙ в template.php.

    lscin, 22 Июля 2016

    Комментарии (1)
  9. PHP / Говнокод #20401

    +2

    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
    public function addBankAccount(
    						$firstName, $lastName, $companyName, $phone, $addressId, $bankName, $bankSwiftCode, $bankStreet,$bankCity, $bankCountry, $bankState, $bankPostalCode,
    						$bankAccountNumber, $currency, $bankRoutingCode, $accountType, $bankAccountType, $intermediaryName, $intermediaryStreet,
    						$intermediaryCountry, $intermediaryState, $intermediaryCity, $intermediaryPostalCode, $intermediarySwift, $intermediaryCodeBank, $intermediaryFurtherAccount, $intermediaryBank
    						)
    	{
    		$key = md5(sprintf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
    			$this->encryptedPassword, $firstName, $lastName, $companyName,
    			$phone, $addressId, $bankName, $bankSwiftCode, $bankStreet, $bankCity,
    			$bankState, $bankCountry, $bankPostalCode, $bankAccountNumber, 
    			$currency, $bankRoutingCode, $bankAccountType, $accountType, 
    			$intermediaryName, $intermediaryStreet, $intermediaryCountry, 
    			$intermediaryState, $intermediaryCity, $intermediaryPostalCode, 
    			$intermediarySwift, $intermediaryCodeBank, $intermediaryFurtherAccount, $intermediaryBank
    		));
    
    		// Prepare the request
    
    		$req  = sprintf("method=%s", urlencode("addBankAccount"));
    		$req .= sprintf("&fromEmail=%s", urlencode($this->fromEmail));
    		$req .= sprintf("&firstName=%s", urlencode($firstName));
    		$req .= sprintf("&lastName=%s", urlencode($lastName));
    		$req .= sprintf("&companyName=%s", urlencode($companyName));
    		$req .= sprintf("&phone=%s", urlencode($phone));
    		$req .= sprintf("&addressId=%s", urlencode($addressId));
    		$req .= sprintf("&bankName=%s", urlencode($bankName));
    		$req .= sprintf("&bankSwiftCode=%s", urlencode($bankSwiftCode));
    		$req .= sprintf("&bankStreet=%s", urlencode($bankStreet));
    		$req .= sprintf("&bankCity=%s", urlencode($bankCity));
    		$req .= sprintf("&bankCountry=%s", urlencode($bankCountry));
    		$req .= sprintf("&bankState=%s", urlencode($bankState));
    		$req .= sprintf("&bankPostalCode=%s", urlencode($bankPostalCode));
    		$req .= sprintf("&bankAccountNumber=%s", urlencode($bankAccountNumber));
    		$req .= sprintf("&currency=%s", urlencode($currency));
    		$req .= sprintf("&bankRoutingCode=%s", urlencode($bankRoutingCode));
    		$req .= sprintf("&accountType=%s", urlencode($accountType));
    		$req .= sprintf("&bankAccountType=%s", urlencode($bankAccountType));
    		$req .= sprintf("&intermediaryName=%s", urlencode($intermediaryName));
    		$req .= sprintf("&intermediaryStreet=%s", urlencode($intermediaryStreet));
    		$req .= sprintf("&intermediaryCountry=%s", urlencode($intermediaryCountry));
    		$req .= sprintf("&intermediaryState=%s", urlencode($intermediaryState));
    		$req .= sprintf("&intermediarySwift=%s", urlencode($intermediarySwift));
    		$req .= sprintf("&intermediaryCodeBank=%s", $intermediaryCodeBank);
    		$req .= sprintf("&intermediaryFurtherAccount=%s", urlencode($intermediaryFurtherAccount));
    		$req .= sprintf("&intermediaryBank=%s", $intermediaryBank);
    		$req .= sprintf("&key=%s", urlencode($key));
    
    		// the following two lines are for testing only (in production they should be commented out)
    		//$req .= sprintf("&sandbox=ON");
    		//$req .= sprintf("&return=%s", urlencode("51"));
    
    		$res = $this->process($req);
    
    		// TODO: Parse the response from server and return error code
    		printf("<textarea cols=\"60\" rows=\"10\" wrap=\"off\">\n%s\n</textarea>\n", $res);
    	}
    
    	protected function process($req)
    	{
    		$header  = "POST /payment/api/paymentAPI.php HTTP/1.0\r\n";
    		$header .= "Host: www.paxum.com\r\n";
    		$header .= "Accept: */*\r\n";
    		$header .= "User-Agent: php-agent/1.0\r\n";
    		$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    		$header .= "Connection: close\r\n";        
    		$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    
    		// Make the request to the server
    		// If possible, securely post using HTTPS, your PHP server will need to be SSL enabled
    		$fp = fsockopen ("ssl://www.paxum.com", 443, $errno, $errstr, 30);
    
    		if (!$fp)
    		{
    			// HTTP ERROR
    			return -1;
    		}
    		
    		//echo $req;exit;
    		
    		fputs ($fp, sprintf("%s%s", $header, $req));
    
    		// Read the server response
    
    		$res = "";
    		$headerdone = false;
    		while (!feof($fp))
    		{
    			$line = fgets ($fp, 1024);
    			if (strcmp($line, "\r\n") == 0)
    			{
    				// read the header
    				$headerdone = true;
    			}
    			else if ($headerdone)
    			{
    				// header has been read. now read the contents
    				$res .= $line;
    			}
    		}
            }

    hardcode = true;

    hack3p, 20 Июля 2016

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

    +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
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    #define CREATE_EVENT_LISTENER(_elname, arg1_type, arg1_name) \
    class _elname : public EventListener	 \
    {	 \
    private:	 \
    	class IContainer	 \
    		{	 \
    	public:	 \
    		virtual void Call(arg1_type arg1_name) = 0;	 \
    		virtual ~IContainer() {}	 \
    		};	 \
    	 \
    	class FunctionContainer : public IContainer	 \
    		{	 \
    	private:	 \
    		typedef void(*__CallbackPtr)(arg1_type);	 \
    	public:	 \
    		FunctionContainer(__CallbackPtr fn)	 \
    				{	 \
    			this->fn = fn;	 \
    				}	 \
    	 \
    		virtual void Call(arg1_type arg1_name)	 \
    				{	 \
    			fn(arg1_name);	 \
    				}	 \
    	 \
    	private:	 \
    		__CallbackPtr fn;	 \
    		};	 \
    		 \
    	template<class T, class Q>	 \
    	class MethodContainer : public IContainer	 \
    		{	 \
    	public:	 \
    		MethodContainer(T method, Q _this)	 \
    				{	 \
    			this->method = method;	 \
    			this->_this = _this;	 \
    				}	 \
    	 \
    		virtual void Call(arg1_type arg1_name )	 \
    				{	 \
    			(_this->*method)(arg1_name);	 \
    				}	 \
    	 \
    	private:	 \
    		T method;	 \
    		Q _this;	 \
    		};	 \
    public:	 \
    	typedef void(*__FN_CALLBACK)(arg1_type);	 \
    	 \
    	_elname(__FN_CALLBACK fn)	 \
    		{	 \
    		this->container = new FunctionContainer(fn);	 \
    		}	 \
    	 \
    	template <class T, class Q>	 \
    	_elname(T method, Q _this)	 \
    		{	 \
    		this->container = new MethodContainer<T, Q>(method, _this);	 \
    		}	 \
    	 \
    	void Call(arg1_type arg1_name)	 \
    		{	 \
    		container->Call(arg1_name);	 \
    		}	 \
    	 \
    	virtual ~_elname()	 \
    		{	 \
    		delete this->container;	 \
    		}	 \
    private:	 \
    	IContainer* container;	 \
    };	 \
    
    #define CREATE_EVENT(_ename, _elname, arg1_type, arg1_name) \
    class _ename : public Event	 \
    {	 \
    public:	 \
    	void AddListener(_elname* listener)	 \
    		{	 \
    		Event::AddListener(listener);	 \
    		}	 \
    	 \
    	void Handle(arg1_type arg1_name)	 \
    		{	 \
    		for (size_t i = 0; i < this->listeners.size(); i++)	 \
    												{	 \
    			((_elname*)listeners[i])->Call(arg1_name);	 \
    												}	 \
    		}	 \
    	 \
    	void RemoveListener(_elname* listener)	 \
    		{	 \
    		Event::RemoveListener(listener);	 \
    		}	 \
    	 \
    };	 \

    Я когда то это написал. Думал, это хорошая идея...
    Полный файл: https://github.com/arhyme/CPP_EVENTS/blob/master/Event.h

    Avery, 18 Июля 2016

    Комментарии (59)
  11. Куча / Говнокод #20386

    +2

    1. 1
    2. 2
    https://www.youtube.com/watch?v=Zrd7kFFCfp4
    https://www.youtube.com/watch?v=yuMlhKI-pzE

    CPU

    laMer007, 16 Июля 2016

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