Raised This Month: $51 Target: $400
 12% 

enum & float double array - tag mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 11-25-2009 , 09:00   Re: float double array - tag mismatch
Reply With Quote #21

Quote:
Originally Posted by Arkshine View Post
Not sure to understand well "your solution". Please apply your solution to his code and post it.
Obviously this solution isn't good if it's supposed to work like we found it does, but for a bug fix simply:
PHP Code:
#define array1[%1] ( tag1: array1[ %1 ] )
new tag1array133 ];
enum 
{
     
enum1
}
new 
tag1var1 array1enum1 ]; 
I get your logic how it basically could have been designed to act like this even it sounds dumb. In my opinion you should still forward this to compuphase, so they can clear how this actually should work and whether there's a bug or not. I can though do that as well.

Last edited by SnoW; 11-25-2009 at 09:02.
SnoW is offline
Send a message via MSN to SnoW
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-25-2009 , 09:22   Re: float double array - tag mismatch
Reply With Quote #22

I don't see bug and your solution is the same that putting the tag after the operator ( which is idiot because I can be applied to all the situations ). I don't understand where is the problem and why you are trying to find weird way to do the trick. It's well written in the Pawn Guide that "Pawn supports enumeration constants with extension that allows to mimic some functionality that others languages implement with "structures" or "records"". Whatever a tagged enum or not, there is no bugs. No need to untag or what you have said.
__________________

Last edited by Arkshine; 11-25-2009 at 09:45.
Arkshine is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 11-25-2009 , 09:44   Re: float double array - tag mismatch
Reply With Quote #23

Quote:
Originally Posted by Arkshine View Post
I don't see bug and your solution is the same that putting the tag after the operator ( which is idiot because I can be applied to all the situations ). I don't understand where is the problem and why you are trying to find weird way to do the trick.
It's not a weird way, but it has the idea define has, short the source. Obviously it's the same, but when I originally posted it, I were in the thought that there's a bug which will be fixed and you can remove the define to update the code.
Quote:
Originally Posted by Arkshine View Post
It's well written in the Pawn Guide that "Pawn supports enumeration constants with extension that allows to mimic some functionality that others languages implement with "structures" or "records"". Whatever a tagged enum or not, there is no bugs.
I don't really understand how that phrase has anything to do with this situation? Maybe you should specify it more to me. Maybe there isn't a bug, but my opinion is still that the logic of the enumeration in this situation is strangely limited.
SnoW is offline
Send a message via MSN to SnoW
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 11-25-2009 , 10:16   Re: float double array - tag mismatch
Reply With Quote #24

Code:
#include <amxmodx> const MAX_CLIENTS  = 32; enum UserData {     bool:IsAlive,     Float:TotalTime,     Name[ 32 ],     Health, }; new UserData:PData2[ MAX_CLIENTS + 1 ][ UserData ]; new PData[ MAX_CLIENTS + 1 ][ UserData ]; new UserData:PData2[ MAX_CLIENTS + 1 ][ UserData ]; public MyFucntion ( Player ) {     new PlayerName[ 32 ];     get_user_name( Player, PlayerName, 31 );         PData[ Player ][ IsAlive ] = true;     PData[ Player ][ TotalTime ] = _:100.5;     PData[ Player ][ Health ] = 50;     copy( PData[ Player ][ Name ], 31, PlayerName );     PData2[ Player ][ IsAlive ] = UserData:true;     PData2[ Player ][ TotalTime ] = UserData:100.5;     PData2[ Player ][ Health ] = UserData:50; }

Arkshine, this code works great, I wanna use the structure property of the enum in my plugin but I'm not sure on the "_:" thingy, like when should I use it & exactly what does it do.
What happens:
Code:
enum _:UserData //here { ... }; PData[ Player ][ TotalTime ] = _:100.5; //here new UserData:PData2[ MAX_CLIENTS + 1 ][ UserData ]; //here with "UserData:" PData2[ Player ][ TotalTime ] = UserData:100.5; //or here with "UserData:"
Are there any other cases?
__________________

Last edited by ehha; 11-25-2009 at 11:17.
ehha is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-25-2009 , 10:45   Re: float double array - tag mismatch
Reply With Quote #25

Quote:
but my opinion is still that the logic of the enumeration in this situation is strangely limited.
Quote:
to mimic some functionality

Anyway, the logic is simple ; if you use the enum as a structure you have to follow the usage of a structure. There is no bug, it's the way of the Pawn.


Simple tagged enum :
Code:
enum Weather {     SNOW,     RAIN, }; new Weather:CurrentWeather = SNOW;

Simple no tagged enum ( same as defines )
Code:
enum {     SNOW,     RAIN, }; new CurrentWeather = SNOW;

Simple tagged structure
Code:
enum Rectangle {     Left,     Top,     Right,     Bottom }; new MyRec[ Rectangle ]; new Value = MyRec[ Left ] = 10; new Rectangle:Side = Bottom;
Code:
enum Coordinate {     Float:X, Float:Y, Float:Z } new Float:coordinates[ Coordinate ]; new Float:value = coordinates[X] = 1.0; new Coordinate:Value2 = Z;

Simple no tagged structure ( bad idea )
Code:
enum {     Left,     Top,     Right,     Bottom }; new MyRec[ 4 ]; new Value = MyRec[ Left ] = 10; new Side = Bottom;
Code:
enum {     Float:X, Float:Y, Float:Z } new Float:coordinates[ 3 ]; new Float:value = coordinates[X] = 1.0; new Value2 = Z;

Complex tagged structures ( without tag, no change. )
Code:
enum Color {     Red,     Green,     Blue } enum Mood {     HAPPY,     ANNOYED, } enum PlayerData {     Float:RunTime,     bool:IsConnected,     KillCount,     GlowColor[ Color ],     Mood:CurrentMood,     PlayerName[ 32 ], } new Data[ PlayerData ]; new Float:Value1 = Data[ RunTime ] = _:150.854; new bool:Value2 = Data[ IsConnected ] = true; new Value3 = Data[ KillCount ] = 666; new Value4 = Data[ GlowColor ][ Red ] = 255; new Mood:Value5 = Data[ CurrentMood ] = _:ANNOYED; copy( Data[ PlayerName ], 31, "Arkshine" );

Even me I understand and I don't see bug, nor difficulty. Such "incredible hacked enum" ( (c) BAILOPAN ) works fine as it is.


Quote:
Arkshine, this code works graet, I wanna use the structure property of the enum in my plugin but I'm not sure on the "_:" thingy, like when should I use it & exactly what does it do.
_: means you set a "no tag" ; basically you untag the variable.
If you have a structure which have strong tags ( A strong tag starts with an uppercase letter ) and you need to set a value in such constants, you would need to untag them before. A weak tag is dropped automatically in such case, that's why like bool you don't need to untag before.

See my example above : new Mood:Value5 = Data[ CurrentMood ] = _:ANNOYED; If I was written "mood" instead of "Mood", it would be a weak tag and I would write : new mood:Value5 = Data[ CurrentMood ] = ANNOYED;

You understand ?
__________________

Last edited by Arkshine; 11-25-2009 at 11:15.
Arkshine is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 11-25-2009 , 11:29   Re: float double array - tag mismatch
Reply With Quote #26

Quote:
Originally Posted by SnoW View Post
Including this there's only another one with Ark I won and then the debate with Hawk. You can't really say who won the main debate( It doesn't get hard to admit it was me ), but I can do say that in the very same thread I won an argument v you and Hawk, so basically your phrase fails with an unbelieveable way.

Even if I had loosed all my debates It'd be just great. If you're always right you never learn anything. If I for example never replied to this thread, I'd have never learned that there exists that kind of bug.

You though never seem to reply to these deep threads until they're basically over and it's easy to blame the looser and say hail to the winner. Before you say "I didn't see it until now", I could claim that you're most online of a lot of users here.
Yeah right. At the end, you were asking me questions about my opinion, which pretty much means you gave up and wanted to know more about my reasoning.

For reference, here's one of your last posts in that thread:

Quote:
Originally Posted by SnoW View Post
I can always stand back easily when the conversation goes more deep, because my English is so bad. Not, but really I need a better dictionary to understand your points.
No we can't make a perfect comparison between them. I'd call it my logic, even it doesn't represent my opinion about the issue. I believe you actually forgot to mention that typing " = 0" isn't four times slower at all than typing ";".

So you are saying that using initilization is horrible, when on your first post you said it's completely fine and maybe even good practice? I've to get the answer before I admit that you changed my opinion about semicolons a bit.
... and here's the whole thread:
http://forums.alliedmods.net/showthread.php?t=106358

How you could possibly believe that you won that is beyond me. I'm 100% with Exolent on this.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 11-25-2009 , 11:34   Re: enum & float double array - tag mismatch
Reply With Quote #27

Thanks again It's clear now, but there's one more case:
Quote:
Originally Posted by ConnorMcLeod View Post
Try :
PHP Code:
new Float:stats[33][list_stats];
enum _:list_stats

No tag for what? What would this be used for?
__________________
ehha is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-25-2009 , 12:33   Re: enum & float double array - tag mismatch
Reply With Quote #28

There are specifics case which is more convenient to untag the enum.

For example see the Coordinate enum ; new Float:Origin[ Coordinate ]; ; if you use Origin in a native it won't work because the header of the native don't use a tag but something like Float:vector[3]. So to keep the tag to declare vars and to avoid tag mismatch, you untag the enum. Though it's possible to not use a tag for the enum and using a #define Coordinate 3 to declare the vars.
__________________
Arkshine is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 11-25-2009 , 12:35   Re: float double array - tag mismatch
Reply With Quote #29

Quote:
Originally Posted by Hawk552 View Post
Yeah right. At the end, you were asking me questions about my opinion, which pretty much means you gave up and wanted to know more about my reasoning.
That's true. I just failed expressing myself. I meant that it doesn't get hard to admit it was me who loosed. Following phrase combination failed:
Quote:
Originally Posted by SnoW View Post
You can't really say who won the main debate( It doesn't get hard to admit it was me )
What I counted as my victory was another debate in the same thread to which both you and Exo just somehow stopped posting completely.
Quote:
Originally Posted by SnoW View Post
but I can do say that in the very same thread I won an argument v you and Hawk, so basically your phrase fails with an unbelieveable way.
http://forums.alliedmods.net/showpos...6&postcount=47
SnoW is offline
Send a message via MSN to SnoW
kim_perm
Member
Join Date: Sep 2007
Location: Perm, Russia
Old 07-10-2010 , 07:54   Re: enum & float double array - tag mismatch
Reply With Quote #30

Hello, not the same problem, but...

Can somehow use double array in enum?
like this:

enum e_test {
arr[10][10]
}

new test[e_test];

test[arr][0][0] = 1;
kim_perm 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 07:27.


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