Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by madpower2000. 07/22/26 14:01
ZorroGPT
by TipmyPip. 07/21/26 17:54
New Zorro version 3.11
by jcl. 07/21/26 13:42
Lapsa's very own thread
by Lapsa. 07/18/26 13:40
Purchase A8 full licence version
by ukgamer. 07/17/26 05:52
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 9,798 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Ephraim, Student_64151
19223 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
namespacing #257015
03/20/09 02:53
03/20/09 02:53
Joined: Dec 2008
Posts: 43
D
DavidM Offline OP
Newbie
DavidM  Offline OP
Newbie
D

Joined: Dec 2008
Posts: 43
I find myself sometimes inadvertently conflicting with some globals in A7 ( result, target, hit, etc ) mostly because these are common English words.

Could these be put into a static struct such as:

struct {
VECTOR hit;
VECTOR target;
VAR result;
...
} Acknex;

I understand this would break some scripts but it would make for a much cleaner API.

I am not sure if you could alias these in a compatibility header which had some declarations like:

VAR* result = &Acknex.result;
VECTOR* target = &Acknex.target;

-DavidM

Re: namespacing [Re: DavidM] #257044
03/20/09 08:00
03/20/09 08:00
Joined: Jul 2000
Posts: 28,127
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,127
Frankfurt
Those common names are replaced by the hit struct long ago, but have to be still around for compatibility. I'd be teared and feathered by the community if I would follow your advice.

Re: namespacing [Re: jcl] #257583
03/24/09 04:03
03/24/09 04:03
Joined: Dec 2008
Posts: 43
D
DavidM Offline OP
Newbie
DavidM  Offline OP
Newbie
D

Joined: Dec 2008
Posts: 43
So there is no way to redefine locally the global variables?

Its really error prone to preserve the word "result" to always point somewhere in the API.(and target, hit, etc).

I define it as a passed parameter and it just shows up zeroed out, until I realize its reserved.

Re: namespacing [Re: DavidM] #257584
03/24/09 04:13
03/24/09 04:13
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
use a type_def struct to make your variables to a certain scope and thus making sure it doesnt point to any core variables defined in the engine. e.g.

Code:
typedef struct 
{
	ENTITY* entAgent;
	int ID;
	var x;
	var result;
	var zpos;
	var timestamp;
	var exist;
	var dead;
	
} structMyVars;

structMyVars myVar;



To access use myVar.result, etc.. for all the members. I understand that this is not memory efficient if u mite need only one member sometimes. But u can do this for all ur normal variables.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: namespacing [Re: DavidM] #257704
03/25/09 01:49
03/25/09 01:49
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
i just use underscores, and self defs are _ and skill defs are __ saves me any problems


Moderated by  aztec, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1