RMMZ The root of all eval()

Lihinel

Veteran
Veteran
Joined
Nov 9, 2013
Messages
256
Reaction score
310
First Language
German
Primarily Uses
I am in the middle of reimplementing a battle system for the 4th time and I am thinking about using some eval() magic.
I know this is a big no-no when it comes to developing for the web, but since the rpgmaker itselft uses tons of eval in the objects js (and the plugins aren't encrypted anyway so anyone could just put in any malicious code anyway), it doesn't seem to be a problem.

So... any objections?

Background:
Many of the skills use have multiple conditions and side effects. I could use a lot of if/else/submethods/recursion and other ways to implement it, but it seems to be easier to use eval for some of the conditions, damage, status effect duration, and other computations. (I'd read the strings in from a json and use them in a method/scope that has variables for str, def etc. to manipulate)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,229
Reaction score
7,614
First Language
German
Primarily Uses
RMMV
The problem is not eval itself, the problem is the source of the string that is eval'ed.

If you develop inside the web, there is a really high chance that someone else can send a string to be eval'ed, and construct that string in a way that it breaks your websites security structure.

However, the RM is a closed system where you are the only one entering strings to be eval'ed. So unless you're using a plugin that let's the player choose their damage formula or anything similiarly insane, there is no way that someone else can enter malcode by eval into your game.
 

Lihinel

Veteran
Veteran
Joined
Nov 9, 2013
Messages
256
Reaction score
310
First Language
German
Primarily Uses
Thanks, thats what I wanted confirmed.

I use eval on strings from a json.
If someone wants to mess with your game they could just alter the plugins or even the engines js so there doesn't seem to be any special additional danger to using eval.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

rux
Just 80% of my motivation on game making lmao, anyone got tips on how to not be unmotivated?
I've signed up for a job training program for people with Asperger's Syndrome. I went to a "test run" today so they could see how well I did with simple jobs, and I amazed them. Most new people do it in 30+ minutes, while I finished in a mere 15 minutes. Gives me time to work on a screenplay for Studio MDHR...
People,I have seen that Someone from China/Chile and London is doing a Vaccine Against COVID-19.
Doing anything that yield good result in the long run is like sowing seeds. With proper care, they will grow and bear fruits. I'm excited for tomorrow. :D

Forum statistics

Threads
105,454
Messages
1,013,834
Members
137,104
Latest member
sasakureman
Top