Raised This Month: $32 Target: $400
 8% 

Solved [SM BUG] Enum struct bugged method that returns bool


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grzyboo
Junior Member
Join Date: Apr 2011
Old 07-28-2019 , 11:16   [SM BUG] Enum struct bugged method that returns bool
Reply With Quote #1

Game: CS:GO
SM version: 1.10.0.6392
MM version: 1.11.0-dev+1127

So, basically after spending a significant amount of time on finding the bug in code I've realized that a method for enum struct that returns boolean value doesn't return proper value. Both returnTrue() and returnFalse() methods return false in this case. Returning of int values works fine.


Example code:

Code:
enum struct Example {
	
	int x; // useless, added here just to compile it. enum struct requires at least 1 field.
	
	bool returnTrue() {
		return true;
	}
	
	bool returnFalse() {
		return false;
	}
	
	int return0() {
		return 0;
	}
	
	int return1() {
		return 1;
	}
	
	int return12345() {
		return 12345;
	}
	
}

void printBool(bool value) {
	PrintToChatAll("bool value: %s", value ? "true" : "false");
}

void test() {
	Example example;	
	printBool(example.returnTrue());
	printBool(example.returnFalse());
	PrintToChatAll("0 = %i", example.return0());
	PrintToChatAll("1 = %i", example.return1());
	PrintToChatAll("12345 = %i", example.return12345());
}

Expected output:
Code:
bool value: true
bool value: false
0 = 0
1 = 1
12345 = 12345
In-game output:
Code:
bool value: false          <----------------- ???
bool value: false
0 = 0
1 = 1
12345 = 12345
A method returns false no matter what you really pass in the return statement.
In the original code, where I found the bug, a method always returned true, so something is really wrong here.

Last edited by Grzyboo; 07-28-2019 at 15:11.
Grzyboo is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-28-2019 , 11:32   Re: [SM BUG] Enum struct bugged method that returns bool
Reply With Quote #2

This was fixed a couple of months ago, please test with the compiler from the latest SourceMod 1.10 build.
__________________
asherkin is offline
Grzyboo
Junior Member
Join Date: Apr 2011
Old 07-28-2019 , 12:44   Re: [SM BUG] Enum struct bugged method that returns bool
Reply With Quote #3

Must've had an old compiler version. Using newer compiler fixed the bug.
Thanks.

Last edited by Grzyboo; 07-28-2019 at 12:45.
Grzyboo is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode