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

List of useful macros for SourcePawn 1.7+


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nergal
Veteran Member
Join Date: Apr 2012
Old 10-05-2015 , 01:04   List of useful macros for SourcePawn 1.7+
Reply With Quote #1

this is a list of useful I made because I was bored.

Happy coding.

Here's a list of 'em

PHP Code:
//Python + C-style operators
#define and                &&
#define and_eq                &=
#define bitand                &
#define bitor                |
#define compl                ~
#define not                !
#define not_eq                !=
#define or                ||
#define or_eq                |=
#define xor                ^
#define xor_eq                ^=
#define bitl                <<
#define bitr                >>
#define eq                ==
#define equals                ==

//functional-style typecasting
#define int(%1)                view_as<int>(%1)
#define Handle(%1)            view_as<Handle>(%1)

//misc.
#define nullfunc            INVALID_FUNCTION
#define nullvec                NULL_VECTOR
#define nullstr                NULL_STRING
#define toggle(%1)            %1 = not %1

#define min(%1,%2)            (((%1) < (%2)) ? (%1) : (%2))
#define max(%1,%2)            (((%1) > (%2)) ? (%1) : (%2))
#define mclamp(%1,%2,%3)        min(max(%1,%2),%3)

#define _buffer(%1)            %1, sizeof(%1)
#define _strbuffer(%1)            %1, sizeof(%1)
#define PLYR                MAXPLAYERS+1
#define PATH                64
#define FULLPATH            PLATFORM_MAX_PATH

#define vec3(%1)            float %1[3] 
Attached Files
File Type: inc macros.inc (908 Bytes, 250 views)
__________________

Last edited by nergal; 07-25-2016 at 12:39. Reason: updating
nergal is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 10-05-2015 , 09:48   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #2

lol pretty nice
__________________
Starbish is offline
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 10-05-2015 , 09:54   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #3

Have fun maintaining/debugging it. Things start to get really intresting when more than 1 developer is involved and he asks himself what the fuck is happening because he doesn't know what strbuffer is defined to.

Last edited by donrevan; 10-05-2015 at 10:10.
donrevan is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-05-2015 , 11:35   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #4

view_as isn't a cast, and most of these just seem like confusing, unhelpful idiosyncrasies
Miu is offline
BAILOPAN
Join Date: Jan 2004
Old 10-05-2015 , 12:11   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #5

This is a good way to ensure incomprehensibility and potential future keyword collision.
__________________
egg
BAILOPAN is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 10-05-2015 , 14:30   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #6

Quote:
Originally Posted by BAILOPAN View Post
This is a good way to ensure incomprehensibility and potential future keyword collision.
in the case of incomprehensibility: I highly disagree because every source compiled with this will need the .inc but I'm pretty sure you're saying this for another reason.

in the case of potential keyword collision: I kinda agree but, for now, there's no keyword collision and it'll likely be some time before such collision occurs.
__________________
nergal is offline
BAILOPAN
Join Date: Jan 2004
Old 10-05-2015 , 16:23   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #7

Even if you really dislike SourcePawn I would not recommend trying to transform it into your own language using macros (and macro features which are deprecated). Bonus points for incorrect max/min, subtly changing the semantics of float(), which already exists, and a broken bool(). It's all just dangerous and non-portable.

I'm not sure if the ideas from this came from http://oldhome.schmorp.de/marc/bournegol.html or what.
__________________
egg

Last edited by BAILOPAN; 10-05-2015 at 16:38.
BAILOPAN is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 10-07-2015 , 15:14   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #8

http://www.ioccc.org/2004/vik2.hint
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Farbror Godis
AlliedModders Donor
Join Date: Feb 2016
Old 03-30-2016 , 15:25   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #9

PHP Code:
#define true (GetRandomInt(0, 10) ? !false : false) 
Farbror Godis is offline
sdz
Senior Member
Join Date: Feb 2012
Old 05-27-2016 , 06:50   Re: List of useful macros for SourcePawn 1.7+
Reply With Quote #10

Quote:
Originally Posted by BAILOPAN View Post
This is a good way to ensure incomprehensibility and potential future keyword collision.
lol'd irl..


@OP I mean I like the idea but um

Last edited by sdz; 05-27-2016 at 06:51.
sdz is offline
Reply


Thread Tools
Display Modes

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 17:17.


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