Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-03-2007, 01:26 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Protected variables

Similar to access specifiers in C++, it would be cool if we can create private or read-only variables so remote objects can't view and/or edit them.

I bring this up when as I realized that anyone could access the strings in my StaffRights dbnpc and read/change them. Thus I'd like an option to be able to protect objects and their associated variables. Only really needed serverside.

I have no idea how hard this would be to implement but cool if we could make variables read only or private/hidden.

Also, I'd also think it'd be great if we have an option to compile a weapon/class/npc 's coding with encryption. This could either be done by
  • Finalising and encrypting a NPCs code so it can never be accessed/changed again - only deleted
  • Encrypting a NPC with a password
  • Giving anyone with rights to the weapon the ability to encrypt / decrypt the NPC.

With the recent use of weapon scripts that can steal servers, this may be a useful addition as well. These may have been requested before. If this is a stupid idea, at least say why .
Reply With Quote
  #2  
Old 01-07-2007, 07:48 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by wiki.graal.net
const intVar = 3;
intVar = 4; // will not work
player.chat = intVar; // displays 3
That exists already.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 01-07-2007, 07:55 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by xXziroXx View Post
That exists already.
The key point was modifiable within the local object whilst locked to others. Like private and protected access specifiers for C++
Reply With Quote
  #4  
Old 01-07-2007, 10:22 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by Twinny
  • Finalising and encrypting a NPCs code so it can never be accessed/changed again - only deleted
An artist knows he has achieved perfection, not when theres nothing left to add, but when there is nothing left to take away.
__________________
Deep into the Darkness peering...
Reply With Quote
  #5  
Old 01-08-2007, 12:25 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Quote:
Originally Posted by Twinny View Post
With the recent use of weapon scripts that can steal servers, this may be a useful addition as well. These may have been requested before.
Ah, innovation. If there was a Legal way to back up and transfer servers (GPAK), there wouldn't be such a propensity to steal servers...scriptkiddies always take the path of least resistance, if they coulda talked the serveradmin into lending them the scripts they woulda...
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #6  
Old 01-08-2007, 06:04 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Well with the addition of NPC server rights, stealing servers is a bit harder. But i still want private and protected variables
Reply With Quote
  #7  
Old 01-08-2007, 11:45 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Eventually we could add some kind of "this.protected.var" or similar, or "thisr."
Reply With Quote
  #8  
Old 01-09-2007, 05:09 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Great!
Reply With Quote
  #9  
Old 01-13-2007, 08:49 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
I prefer "thisr.", "this.protected.var" makes me cringe.
__________________
Reply With Quote
  #10  
Old 01-13-2007, 08:58 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Agreed
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #11  
Old 01-13-2007, 09:11 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Problem with thisr. is ... then we also need thisor., gets complex
Reply With Quote
  #12  
Old 01-13-2007, 10:28 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Stefan View Post
Problem with thisr. is ... then we also need thisor., gets complex
You have a point

How about something in the TGraalVar that when true makes an object only editable by its 'parent' object? I assume that variables are subobjects of the script?

object.protected(true/false);
object.final(true/false);

Opinions?
__________________
Reply With Quote
  #13  
Old 01-14-2007, 07:39 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
this.test = new TProtectedString();

or something similar to that could work .

Last edited by Twinny; 01-14-2007 at 01:58 PM..
Reply With Quote
  #14  
Old 01-14-2007, 01:57 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
this.protected.var seems reasonable enough if it clears the thisor. problem.
Reply With Quote
  #15  
Old 01-15-2007, 02:56 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Twinny View Post
this.test = new TProtectedString();

or something similar to that could work .
Why have to do that when you could simply make 'protected' an attribute of all Objects?
Object.protected = true/false;
__________________
Reply With Quote
  #16  
Old 01-15-2007, 05:57 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Because it'd be one more bit applied to every variable ever...?
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #17  
Old 04-02-2007, 06:43 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Hate to revive this but I love the idea of password protected NPCs and encrypted ones as well.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #18  
Old 04-02-2007, 02:03 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Heh..i'd much prefer my original idea of protected vars. this.protected.var would be awesome but this.var.protected = true; could also be cool .

But soon!
Reply With Quote
  #19  
Old 04-02-2007, 08:31 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Maybe if we just had more control over public and private variables...I don't know if I like the idea of classes being downloaded onto the client so they can see "Huh, whatever variable z01 is, that's the password...so I'll just say that, and it'll match it up...oh, I see, they have it scripted so I have to say the password backwards...well, I say that then."
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #20  
Old 04-03-2007, 12:01 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Tyhm View Post
Maybe if we just had more control over public and private variables...I don't know if I like the idea of classes being downloaded onto the client so they can see "Huh, whatever variable z01 is, that's the password...so I'll just say that, and it'll match it up...oh, I see, they have it scripted so I have to say the password backwards...well, I say that then."
Ahh.... where did classes come from? Or clientside for that matter? . A protected var could be like a var within a DBNPC serverside. Client has the same access it has had as always: none while serverside scripts would also be unable to access it. There's no loss of security with protected vars
Reply With Quote
  #21  
Old 04-03-2007, 12:49 PM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Piffle, I could care about internal security (the relative risk of people who already have access to RC), but I shan't. It's not the sort of thing that seems to merit having its own script to repair.
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #22  
Old 04-03-2007, 01:48 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Tyhm View Post
Piffle, I could care about internal security (the relative risk of people who already have access to RC), but I shan't. It's not the sort of thing that seems to merit having its own script to repair.
Then what are you caring about?

I requested protected variables. Kinda like making bank flags protected variables so staff members with any kind of script access (eg. level, weapon etc.) couldn't access the flags and change them from another object. Could also be like making a mud library into a DB with protected vars so weapons / items can't be changed without using the actual DB itself - thus logged. I don't see why we can't have it?

Quote:
Originally Posted by Tyhm View Post
Maybe if we just had more control over public and private variables...
We currently have no control of such things - they don't exist for developers.

Quote:
Originally Posted by Tyhm View Post
I don't know if I like the idea of classes being downloaded onto the client so they can see "Huh, whatever variable z01 is, that's the password...so I'll just say that, and it'll match it up...oh, I see, they have it scripted so I have to say the password backwards...well, I say that then."
No idea where that thought came from. In anycase, protected vars would be wasted clientside anyways. All important information should be held serverside.
Reply With Quote
  #23  
Old 06-25-2007, 12:14 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I've recently given this a bit more thought and I think this could work

Private Variables: Set by default, only the current object and all child objects can access variables.

Trust Variables: An extension of private. All variables will become private but you can add what objects are trusted. For example, a DBNPC called System may have trust with a DBNPC called Accounts. This one is not as important but it would be cool

Public Variables: When created, the player will have to set the variable as public. Public variables will have two settings: read and read/write. This could be done like
PHP Code:
obj.public=0// Variable is private
obj.public=1//Object is public read-only
obj.public=2//Object is public read/write 
Although the two levels of public variables aren't vital as such, they would definitely be handy. These settings should also use inheritance although a child can change it's variable settings if desired.

Doable?
Reply With Quote
  #24  
Old 06-25-2007, 11:25 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Can't make private variables by default as it would mess a lot of servers up. Maybe like a server option: privatevariablebydefault=true or something
I also posted this in another thread:

Quote:
Originally Posted by zokemon View Post
Yeah I was thinking about that...
You could just do like:

NPC1:
NPC Code:
function onCreated() {
public this.myvar = "Hello!";
NPC2.getMyVar();
private this.myvar;
NPC2.getMyVar();
}



NPC2:
NPC Code:
function getMyVar() {
echo("Test Results: " @ NPC1.myvar);
}



Echoed text:
NPC Code:
Test Results: Hello!
Test Results:



Color coded to show you the format of the code too ;P
(You would use public and private much like you use new, if, else, while, do, etc.)
__________________
Do it with a DON!
Reply With Quote
  #25  
Old 06-26-2007, 02:21 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
I think I would prefer private/public status to be set using a function on the object, that way you could make a function to set the status of many variables at once.
__________________
Reply With Quote
  #26  
Old 01-22-2008, 01:40 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I still desire these updates! Callstack access does rock but with protected vars: ultimate security! I will love you long time and bake many pizzas should you add this
Reply With Quote
  #27  
Old 01-23-2008, 04:21 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Hmmm In some languages there is a way to "freeze" an object. The variables of the frozen object cannot be edited anymore. That could eventually be added to Graal to make stuff like the DB-npcs not-modifiable. Eventually we could also make it so that you can "freeze" the object but still allow modifications from within the object itself.

A major problem for private variables is more the speed though, because it will need to check for each operation if the operation is allowed from the current object. Languages like C++ and Java only do private/protected stuff by the compiler, it's still possible to access those variables from outside with some tricks at runtime. So the scripting engine would need to remember the access rights for each object and check for access rights when the variable is read or modified.

A "freezing" mechanism could make that faster because it would only set the access flag for all sub-variables at the time you freeze the object, and later just check for the access flag. It could also automatically block all attempts of calling join which could be used to extend the script of an object and then send a trigger to it to modify its own variables.
Reply With Quote
  #28  
Old 01-23-2008, 04:29 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
One way you could do staff rights systems for now would be to use a system like this:

Have a folder that only the owner/manager and only essential staff have access to. In there, keep a file of flags (XML, saveVars, however you prefer to do it), and then each time you want to access something, reload it. Only save it when the function is called, etc. It's not that complicated, but could be difficult to implement. I find it nice to have a folder that only essential staff have access to anyway. Of course, hypothetically, you could just make a new folder, but many UC servers give every single staff rw */*, etc and then if they don't have that, everyone has change folder rights.

Just an idea.
__________________
Reply With Quote
  #29  
Old 01-23-2008, 04:43 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by cbkbud View Post
One way you could do staff rights systems for now would be to use a system like this:

Have a folder that only the owner/manager and only essential staff have access to. In there, keep a file of flags (XML, saveVars, however you prefer to do it), and then each time you want to access something, reload it. Only save it when the function is called, etc. It's not that complicated, but could be difficult to implement. I find it nice to have a folder that only essential staff have access to anyway. Of course, hypothetically, you could just make a new folder, but many UC servers give every single staff rw */*, etc and then if they don't have that, everyone has change folder rights.

Just an idea.
Anyone with script rights could savevars/savelines over said text file though.
__________________
Do it with a DON!
Reply With Quote
  #30  
Old 01-23-2008, 05:05 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by zokemon View Post
Anyone with script rights could savevars/savelines over said text file though.
True.

New solution: script the whole damn server yourself. Noone else deserves rights! It is YOUR server, after all!


I suppose, if all else fails, you could even manually edit the file, or, easier, just make a folder in your private folder where you have files such as rights_cbk1994.txt, and in it just a list such as
PHP Code:
summon
boots
totalabuse 
where it is read. Trickier to do, but probably more secure. Then you could simply give the (npcserver) read rights to it.
__________________
Reply With Quote
  #31  
Old 01-23-2008, 05:21 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Stefan View Post
Hmmm In some languages there is a way to "freeze" an object. The variables of the frozen object cannot be edited anymore. That could eventually be added to Graal to make stuff like the DB-npcs not-modifiable. Eventually we could also make it so that you can "freeze" the object but still allow modifications from within the object itself.

A major problem for private variables is more the speed though, because it will need to check for each operation if the operation is allowed from the current object. Languages like C++ and Java only do private/protected stuff by the compiler, it's still possible to access those variables from outside with some tricks at runtime. So the scripting engine would need to remember the access rights for each object and check for access rights when the variable is read or modified.

A "freezing" mechanism could make that faster because it would only set the access flag for all sub-variables at the time you freeze the object, and later just check for the access flag. It could also automatically block all attempts of calling join which could be used to extend the script of an object and then send a trigger to it to modify its own variables.
Whatever works best so long as objects can't read/write to frozen variables

Would this be a next Gserver update?

Last edited by Twinny; 01-24-2008 at 01:32 AM..
Reply With Quote
  #32  
Old 01-23-2008, 04:15 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by zokemon View Post
Anyone with script rights could savevars/savelines over said text file though.
Remove NPC-Server access to the folder and manually add/remove rights.
Reply With Quote
  #33  
Old 01-24-2008, 02:40 AM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
With the new callstack function, we could easily do some sort of protection.

Stefan could add some sort of onStrChanged(str, str, obj, str)
params[0] could be the string being modified
params[1] could be the new string value
params[2] could be the object that is changing it
params[3] could be the old string value

Then add a check like if onStrChanged() is in the object's functions (the one with the string being modified - to relieve any possible confusion) then run through the function, otherwise, just modify the string without any nonsense.
__________________
Trying to be nice now...
Reply With Quote
  #34  
Old 01-24-2008, 03:07 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Crow View Post
Remove NPC-Server access to the folder and manually add/remove rights.
Yah, basically what I said in my correction post
Quote:
Originally Posted by bscharff View Post
With the new callstack function, we could easily do some sort of protection.

Stefan could add some sort of onStrChanged(str, str, obj, str)
params[0] could be the string being modified
params[1] could be the new string value
params[2] could be the object that is changing it
params[3] could be the old string value

Then add a check like if onStrChanged() is in the object's functions (the one with the string being modified - to relieve any possible confusion) then run through the function, otherwise, just modify the string without any nonsense.
Except you'd get that called many, many times a second. Think. Every single variable.
__________________
Reply With Quote
  #35  
Old 01-24-2008, 03:37 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by bscharff View Post
With the new callstack function, we could easily do some sort of protection.

Stefan could add some sort of onStrChanged(str, str, obj, str)
params[0] could be the string being modified
params[1] could be the new string value
params[2] could be the object that is changing it
params[3] could be the old string value

Then add a check like if onStrChanged() is in the object's functions (the one with the string being modified - to relieve any possible confusion) then run through the function, otherwise, just modify the string without any nonsense.

onStrChanged()...... some of you people really don't seem to be getting this....when i say protected/private variables, only the local object can even see them let alone write to them! Other objects can't even read their contents or know if they exist!
Reply With Quote
  #36  
Old 01-24-2008, 03:38 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Well I suggested onVarChanged() along time ago myself.

By the way, you should call them variables instead of strings.

Also, I had thought it might be a better idea to be able to define a read and write function for a variable, easily making variables read only or private or be able to notify the object of changes.

Something like this:
PHP Code:
function onCreated() {
  
this.join("util_callstack");
  
this.strvar 0// initialize it (insurance)
  
this.strvar.setreadfunction(this.read_strvar);
  
this.strvar.setwritefunction(this.write_strvar);
}
// The actual value would be stored invisibly by GScript and only provided as a parameter when the read or write is called.
// This is example of private variable using this method.
function read_strvar(value) {
  if (
getcallingobject() == this) {
    return 
value;
  }
  else {
    return 
null;
  }
}
// the new value of the 'variable' would be returned and GScript would catch the return value and assign it to the variable internally.
// indexes parameter would be an array of indexes used with the variable.
// ex: this.var1[3][5] = 4; would call: write_var1(<currentvalue>, 0, 4, {3, 5});
function write_strvar(valueoperationnewvalueindexes) {
  
// getcallingobject() is class function of util_callstack
  
if (getcallingobject() == this) {
    switch (
operation) {
      case 
0// =
        
value[indexes[0], indexes[1]] = newvalue;
        return 
value// Gscript catches the return and sets that return to the variable's value.
      
case 1// +=
        
value[indexes[0], indexes[1]] @= newvalue// string append instead of addition.
        
return value;
      default:
        return 
value// no other operations allowed for the variable.
    
}
  }
  else {
    return 
value// value is not modified, it is a private variable
  
}

Ideally if something like this were implemented it would only produce a slowdown with variables that are specifying a read and write function, or just one of the two.

And a more secure method would probably be a new type of script function definition:
PHP Code:
function onCreated() {
  
this.join("util_callstack");
  
this.strvar "3"// is using the special defined functions.
}
varread strvar(value) {
  return 
value;
}
varwrite strvar(valueoperationnewvalueindexes) {
  
// do stuff

Its a stretch but its something I think might be interesting if used properly.
__________________
Reply With Quote
  #37  
Old 01-24-2008, 12:26 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Well we could eventually start with adding some flag to complete block access to variables from outside, and then you write functions for retrieving data.

The syntax for getters/setters would look more like "function set varname(value)" and "function get varname()" to be compatible with ECMA/JavaScript.
Reply With Quote
  #38  
Old 01-25-2008, 12:12 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Stefan View Post
Well we could eventually start with adding some flag to complete block access to variables from outside, and then you write functions for retrieving data.

The syntax for getters/setters would look more like "function set varname(value)" and "function get varname()" to be compatible with ECMA/JavaScript.
That or perhaps add a new section for variables like this.private.vars . That way the engine knows straight off that it can't touch other objects vars contained within obj.private

But whatever works
Reply With Quote
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 +2. The time now is 01:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.