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

Bitsum question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 11-07-2020 , 03:35   Bitsum question
Reply With Quote #1

Hello,
I was wondering why compiler is throwing this errors:
PHP Code:
D:\Custom Projects\Zombie Apocalypse\scripting\Special_Project_ZA.1.0.sma(127 -- 128) : error 012invalid function callnot a valid address
D
:\Custom Projects\Zombie Apocalypse\scripting\Special_Project_ZA.1.0.sma(128) : error 001expected token";"but found ")"
D:\Custom Projects\Zombie Apocalypse\scripting\Special_Project_ZA.1.0.sma(128) : error 029invalid expressionassumed zero
D
:\Custom Projects\Zombie Apocalypse\scripting\Special_Project_ZA.1.0.sma(128) : fatal error 107too many error messages on one line 
I have defined macro like this
PHP Code:
#define SetBit(%1,%2) (%1 |= (1 << (%2 & 31))) 
Error is thrown only when the code is written like this:
PHP Code:
        g_bLastZombie true
        SetBit
(g_bitIsLastZombieiPlayer
when I change the position of the bit like this:
PHP Code:
        SetBit(g_bitIsLastZombieiPlayer)
        
g_bLastZombie true 
compiler is happy, I can't find a concrete explanation for this.

And btw, when I change the macro like this:
PHP Code:
#define SetBit(%1,%2) %1 |= (1 << (%2 & 31)) 
it's working in both ways.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 11-07-2020 at 03:36.
Shadows Adi is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 11-07-2020 , 09:43   Re: Bitsum question
Reply With Quote #2

Seems like the compiler sees the parentheses and therefor assumes the previous is a function to be called.
Exactly like this also works:
Code:
    server_print     ("");

It could be negated by removing the parentheses as you did, adding a semicolon before it or on the end of the row before or by using it after another function.

Code:
    g_bLastZombie = true;     SetBit(g_bitIsLastZombie, iPlayer)
Code:
    g_bLastZombie = true     ;SetBit(g_bitIsLastZombie, iPlayer)
Code:
    register_plugin("Test Plugin 1", "1.0", "[ --{-@ ]")     SetBit(g_bitIsLastZombie, iPlayer)

Or simply turning it into a real function, unless called every server frame it really doesn't matter.
Code:
stock SetBit(container,bit) {     container |= ( 1 << ( bit & 31 ) ); }



But being honest here, using bitsum for setting a value for a single player that is reset when not applicable anymore without adding another player is just making things complicated. Better to just do:
Code:
g_LastZombie = iPlayer.
__________________
Black Rose 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:01.


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