DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • November 24, 2017, 05:51:31 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: 1 [2] 3   Go Down
  Print  
Author Topic: LoGD v1.1.2 Core Code - BUGS FIXED  (Read 15116 times)
0 Members and 1 Guest are viewing this topic.
Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5477



View Profile WWW
« Reply #15 on: March 28, 2014, 05:58:07 PM »

No link?
Not required to provide one.

That's because Stephen thinks he's so clever and cryptic by hiding what others may need to know, he doesn't care about others.

As I said. Grin Don't mention it in the first place if you're not going to explain. However, since you have stated elsewhere that you've fixed it in your own version of the code, as per the license, I would like a copy of the fixed code. Cheesy
No can do. Lost it Tongue

Now that is hardly the spirit of this site, or it's purpose.

This isn't the place to be an ass about something like this.  If you know of something that should be fixed share it.  Otherwise go troll somewhere else because it isn't welcome here.
Logged

Play the latest beta version here on DragonPrime
Aeolus
Mod God
*****
Offline Offline

Posts: 1793


You're welcome.


View Profile WWW
« Reply #16 on: March 29, 2014, 09:28:35 AM »

Quote
"DragonPrime nerd: Compare the *_getmoduleinfo() of modules to the module_userprefs when a pref is removed."

So I'm assuming that when a pref is removed, it's not removed from the module_userprefs table... Not much of a bug, but something to look into.
Logged

Stephen.Kise
Codemeister
****
Offline Offline

Posts: 377


So meme'd up.


View Profile
« Reply #17 on: March 29, 2014, 10:01:32 AM »

Quote
"DragonPrime nerd: Compare the *_getmoduleinfo() of modules to the module_userprefs when a pref is removed."

So I'm assuming that when a pref is removed, it's not removed from the module_userprefs table... Not much of a bug, but something to look into.

"Not much of a bug" when there are 400-500 players that have a couple of prefs set which are non-existent as a module is updated. Those couple of prefs turn into 1,000-2,000 entries in what should be the second biggest table for your core.
Logged

Slowly progressing fork with PHP 7 support: https://github.com/stephenKise/Legend-of-the-Green-Dragon
Cheap VPS Hosting (10$ credit!): https://m.do.co/c/acde75b086c5
Aeolus
Mod God
*****
Offline Offline

Posts: 1793


You're welcome.


View Profile WWW
« Reply #18 on: March 29, 2014, 12:52:10 PM »

"Not much of a bug" when there are 400-500 players that have a couple of prefs set which are non-existent as a module is updated. Those couple of prefs turn into 1,000-2,000 entries in what should be the second biggest table for your core.

Perhaps you should be testing your modules on a dev server first, before moving it to your live server where you'll be removing the pref. Wink

Code:
<?php
function module_delete_oldvalues($table,$key) {
    require_once 
'lib/gamelog.php';
    
$total 0;
    
$res db_query("SELECT modulename FROM ".db_prefix('modules')." WHERE infokeys LIKE '%|$key|%'");
    while (
$row db_fetch_assoc($res)) {
        
$mod $row['modulename'];
        require_once 
"modules/{$mod}.php";
        
$func $mod."_getmoduleinfo";
        
$info $func();
        
$keys array_filter(array_keys($info[$key]), "module_pref_filter");
$keys array_map("addslashes"$keys);
        
$keys implode("','"$keys);
        if (
$keysdb_query("DELETE FROM ".db_prefix($table)." WHERE modulename='$mod' AND setting NOT IN ('$keys')");
        
$total += db_affected_rows();
    }
    
gamelog("Cleaned up $total old values in $table that don't exist anymore"'maintenance');
}

function 
module_pref_filter($a){ 
    return !
is_numeric($a);
}
?>

Code:
<?php
$tables 
= array('module_userprefs'=>'prefs','module_settings'=>'settings');
foreach (
$tables as $table=>$keymodule_delete_oldvalues($table,$key);
?>

Then toss the second block of code into newday_runonce.php (or somewhere similar).

Edit: This would also apply to the module_settings and module_objprefs tables, modified the code. (Not sure how to apply it to module_objprefs, but if anyone works it out, let me know.)
« Last Edit: January 07, 2015, 08:49:37 PM by The Doctor » Logged

Rohen
Codemeister
****
Offline Offline

Posts: 264


View Profile WWW
« Reply #19 on: April 16, 2014, 03:13:33 AM »

first of all thanks to TheDoctor for sharing this 1.1.2 Version.

following the licence i publish all stable changes of core files with the mentioned changes as you can see on this list.
The file can be found on http://www.lotgd.de/downloads/upgrade%201.1.2.7z.

Changes in the lotgd.de files

As nightborn stated and when testing on our server loops with foreach are faster than while (list).
This may depent on the server self and the installed php version.

changes:
armor.php             - allow % to be a color tag
bank.php              - shorten the transfer-option if the user entered the correct target name
bio.php               - foreach change and superusers with edit_user flag gets no checkday (if you're only viewing a user you shouldn't get one)
create.php            - minlength of a name is a gamesetting, not fixed to a value of 3
creatures.php         - AI Script Entry only available for users with SQL rights (important for bigger admin teams) + foreach changes + bugs mentioned here http://dragonprime.net/index.php?topic=10381.0
dragon.php            - Changes from http://dragonprime.net/index.php?topic=12574.0 and foreach
healer.php            - Removed duplicated output row
lodge.php            - Entry allowed even if you've 0 dp's. Some lodge modules offers changes for free and cannot be accessed
logdnet.php            - foreach + added 1.2.0 Alpha as a valid version, since it's the last official version from dragonprime
mail.php            - width changes
motd.php            - Comments only available for loggedin users
payment.php            - Corrects the 1.1 header for paypal queries
prefs.php            - Replace split by explode, since 5.3 DEPRECATED
rawsql.php            - Changed the hook to allow altering the sql statement. This was done to prevent younger team members with sql rights to use delete or drop statements.
                  - Changes from http://dragonprime.net/index.php?topic=12510.0 to catch sql errors
stables.php            - Extent the $shemas-array like the $basetext array
lib\battle-buffs.php   - support for additional bufffields compatkmod, comdmgkmod,...
lib\charcleanup.php      - module changed to abort delete procedure
lib\creatures.php      - Support for level > 18
lib\events.php         - using explode instead of split (DEPRECATED since 5.3.0)
lib\expire_chars.php   - Userdelete ist limited to max. 250, hook for validating the user-delete is added
lib\forest.php         - Modified like a city to allow modules to change to texts. Needed for defining deserts and co.
lib\motd.php         - foreach and the feature edits by The Doctor http://dragonprime.net/index.php?topic=12289.0
lib\output.php         - added 2 functions to place a nav AFTER another
lib\pvplist.php         - clanrank-array replaced by function
lib\pvpsupport.php      - max. values for looseexp filtered
lib\systemmail.php      - added hook to handle systemmails within modules
lib\clan\clan_motd.php   - motd ability for all above clan_officer (nessessary for additional ranks by modules)
lib\clan\detail.php      - added rank "founder"
lib\clan\func.php      - Clanrank-color as function, not a fixed array
lib\graveyard\case_question.php - Show the inactive resurrection
lib\mail\case_default.php User can select the sorting of mails in old style or per sender
lib\mail\case_read.php   - Translate subject
lib\mail\case_write.php   - Added a Linkfield above the Textarea so users can add colors by click

modules\sethsong.php   - Color corrections in output text
modules\drinks\dohook.php-added a httpget option named 'caller' to support multiple drinks like season-depending ale/xmas-ale and so on
modules\drinks\run.php   - Caller-Changes like the line above.
modules\clannews.php   - Fixed args bug http://dragonprime.net/index.php?topic=12303.0


foreach instead of while list:
badnav.php
badword.php
companions.php
configuration.php
modules.php
mounts.php
newday.php
news.php
train.php
viewpetition.php
modules\dag\dohook.php
modules\drinks\install.php
lib\battle-skills.php
lib\bell_rand.php
lib\buffs.php
lib\censor.php
lib\dump_item.php
lib\errorhandler.php
lib\errorhandling.php
lib\experience.php
lib\http.php
lib\output_array.php
lib\php_generic_environment.php
lib\register_global.php
lib\saveuser.php
lib\show_backtrace.php
lib\showform.php
lib\spell.php
lib\stripslashes_deep.php
lib\tabledescriptor.php
lib\template.php
lib\tempstat.php
lib\user\user_edit.php
lib\user\user_save.php

modules with new functions:
modules\outhouse.php   - Extented to allow people write poems to the door. Texts partly in german
modules\raceelf.php      - Text changes on tradein - option. Source unknown
lib\case_haunt2.php      - Additional hook insered to prevent player a from haunting player b by changing the victimlist
Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1793


You're welcome.


View Profile WWW
« Reply #20 on: April 16, 2014, 04:53:01 AM »

foreach instead of while list:
badnav.php
badword.php
companions.php
configuration.php
modules.php
mounts.php
newday.php
news.php
train.php
viewpetition.php
modules\dag\dohook.php
modules\drinks\install.php
lib\battle-skills.php
lib\bell_rand.php
lib\buffs.php
lib\censor.php
lib\dump_item.php
lib\errorhandler.php
lib\errorhandling.php
lib\experience.php
lib\http.php
lib\output_array.php
lib\php_generic_environment.php
lib\register_global.php
lib\saveuser.php
lib\show_backtrace.php
lib\showform.php
lib\spell.php
lib\stripslashes_deep.php
lib\tabledescriptor.php
lib\template.php
lib\tempstat.php
lib\user\user_edit.php
lib\user\user_save.php   - Additional hook insered to prevent player a from haunting player b by changing the victimlist

I would have sworn we PM'ed about a month ago, and I showed you how while list is actually faster than foreach.

Here's the test, in case you forgot. (Be sure to read the Total times foreach() is faster than while(list()) out of 10,000 times was: x note at the bottom - I've never seen it go above 10.)
Logged

Rohen
Codemeister
****
Offline Offline

Posts: 264


View Profile WWW
« Reply #21 on: April 16, 2014, 04:56:34 AM »

You're right and i've done the test twice on other systems.
For that the warning, that this may depent on the server / software.
All i can see is that the game is running some times faster with foreach.
Nobody is forced to use the files i provide.

Edit:
it depends on the testcondition.

while(list($key,$val) = each($array)) ... is faster than foreach if you do a write operation on the array / values.
Otherwise foreach is significant faster if you only reads the data. Thats the most used on lotgd.
« Last Edit: April 16, 2014, 05:03:13 AM by Rohen » Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1793


You're welcome.


View Profile WWW
« Reply #22 on: April 16, 2014, 05:03:12 AM »

while(list($key,$val) = each($array)) ... is faster than foreach if you do a write operation on the array / values.
Otherwise foreach is significant faster if you only reads the data. Thats the most used on lotgd.

Not necessarily. The test I used simply sums the values of an array with values from 1 to 1,000 to an external variable, no writing to the array or values, just reading each value. And strange. x10Hosting and WAMP both give the same results as HostGator (my own site's host).

You've done well, that's quite a few fixes. I'm confused about this, though:

rawsql.php            - Changed the hook to allow altering the sql statement. This was done to prevent younger team members with sql rights to use delete or drop statements.

Why would younger team members even have RawSQL if they don't know what they're doing? o.o If the owner gave such a flag to them without them having considerable knowledge, then I'm not sure that they should even be running a site. (Since you can do a lot of damage even without delete or drop statements.)
« Last Edit: April 16, 2014, 05:12:09 AM by The Doctor » Logged

Rohen
Codemeister
****
Offline Offline

Posts: 264


View Profile WWW
« Reply #23 on: April 16, 2014, 05:06:33 AM »

*points to the post above about the loop*

at rawsql:
the hook was already there and the people who have the flag knows what to do, but every one can make a mistake and killing the live-db makes only a lot of work...
So they asked for a posibility to prevent these type of error and i saw no performance issues on extending this.
Logged

Aeolus
Mod God
*****
Offline Offline

Posts: 1793


You're welcome.


View Profile WWW
« Reply #24 on: April 16, 2014, 05:09:54 AM »

*points to the post above about the loop*

at rawsql:
the hook was already there and the people who have the flag knows what to do, but every one can make a mistake and killing the live-db makes only a lot of work...
So they asked for a posibility to prevent these type of error and i saw no performance issues on extending this.

*points to his post above that he edited about the loop*

Fair enough. xD I'm still confused about how someone can mistakenly type out "delete from modules" or "drop accounts", but we all have our bad days, I guess. Grin
Logged

Nightborn
Captain of the Guard
***
Offline Offline

Posts: 191


View Profile WWW
« Reply #25 on: April 17, 2014, 10:46:53 AM »

My benchmarks worked like that:

foreach($stack as $value) <-- best if you *only* need the $value, not $key - which is true in 95% of all lotgd while loops.

while is ok, but I would prefer foreach still.

Logged
Rockie
Militia
**
Offline Offline

Posts: 33

I'm Twisted


View Profile
« Reply #26 on: May 13, 2014, 10:31:41 AM »

Too bad I did not find this sooner, it would have saved a lot of headaches!  I do believe I will save a copy somewhere just in case. As always, great work Doc.
Logged
Aeolus
Mod God
*****
Offline Offline

Posts: 1793


You're welcome.


View Profile WWW
« Reply #27 on: May 13, 2014, 06:47:12 PM »

Too bad I did not find this sooner, it would have saved a lot of headaches!  I do believe I will save a copy somewhere just in case. As always, great work Doc.

Glad to help. Grin Maybe it'll get an upload to the main download area in time, so it's easier to find.
Logged

Hannah
Militia
**
Offline Offline

Posts: 50


View Profile
« Reply #28 on: May 20, 2014, 11:21:36 AM »

Doctor,
Did you remove some of the files when you edited the bugs. One of the ones that didn't make it over was multiple cities. I don't know if it was something you did OR an error between the chair in the keyboard. I managed to get it plugged in and all is great. I totally wish I would have found these edits before playing the with original one I downloaded. Thanks again to all of you who have worked to improve the core and general game-play.
Logged
Aeolus
Mod God
*****
Offline Offline

Posts: 1793


You're welcome.


View Profile WWW
« Reply #29 on: May 20, 2014, 04:12:16 PM »

Doctor,
Did you remove some of the files when you edited the bugs. One of the ones that didn't make it over was multiple cities. I don't know if it was something you did OR an error between the chair in the keyboard. I managed to get it plugged in and all is great. I totally wish I would have found these edits before playing the with original one I downloaded. Thanks again to all of you who have worked to improve the core and general game-play.

No, I didn't. The cities module isn't in the core download - it's found in the recommended modules, meaning I can't delete something that wasn't there.
Logged

Pages: 1 [2] 3   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
24 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search