Welcome to the Browser-Base Game Zone forums!
In one of our game we store the formulas in the database and eval() them during the "combat". Since it is only during the combat sequences the whole argument of non tolkenized code hasn't made a bit of difference in server performance. I know it's slower and I'm not arguing that point but the slower execution isn't hurting the speed of the server. The biggest advantage I've found with going this route is *I* don't have to be the one writing the forumlas. The formulas can be easily updated / created via the admin panel by our staff based on game feedback.
It's nonsense, there's always coding - storing in DB would only mean MORE copy&paste, not less ...As far as I know eval prevents any caching & optimizationsAlso your way prevents calling other formula... unless you perform some formula analysis and fetch more formulas from DBI see no benefit of this approach, only downsides
I've already put most of the things in the database like the items are in there and thusly only their smallest values that are possible are stored and i cannot imagine storing that information in some file rather than a database.
Just a little something you want to be sure you deal with on what Chris is talking about with self-rewriting PHP files....Do not do the actual file replace until the entire file has been written. Unless you have the ini setup to avoid this, your php code stops running if a user browses away before they receive the result. Don't forget it's also possible for power outages to suddenly happen in the middle of script execution.Here's the 3 essential operations for this:1) Open file for writing2) Add code3) Close fileBut what happens if lightning strikes a transformer and your server suddenly loses power in the middle of writing the new code? This probably depends on your underlying OS and filesystem. However, it's entirely possible to end up with a corrupted file which could cause a hard failure or, even worse, can silently work but do so in a corrupted manner because the full logic you were expecting isn't applied.However, you can define a process that doesn't care about the underlying system components quite easily:1) Create a temporary copy of file.2) Perform code alterations.3) Save the temporary file.4) Rename the original file (to avoid naming conflict).5) Rename the temporary file to the original file name.6) Clean up the original file (archive, delete, whatever you normally do).Using these steps, you've guaranteed that a failure at any point is a quick and easy fix.