Eclipse-Phase-Unofficial / ep-character-creator

A web-based character creator application for the Eclipse Phase role-playing game.
Other
27 stars 18 forks source link

JSON Save/Load issue #71

Open mace666 opened 8 years ago

mace666 commented 8 years ago

Every time I load a saved character from .json file and and save it again the content of the "groupsArray" in the skills section (EPSkill.php) gets duplicated. This continues until JSON string gets to long to be loaded. I tried to fix the issue but right now I do not fully understand the usage of the "groupsArray" and how it should be filled correctly.

I testet with the actual version of master branch (2 Feb 2016) and in the virtual environment you provided. The browser used was Firefox 44.0

mace666 commented 8 years ago

A fix might be (EPSkill.php): function loadSavePack($savePack,$cc = null){ parent::loadSavePack($savePack);

$this->skillType = $savePack['skillType'];
 $this->prefix = $savePack['prefix'];  
 $this->baseValue = $savePack['baseValue'];
 $this->morphMod = $savePack['morphMod'];
 $this->traitMod = $savePack['traitMod'];
 $this->backgroundMod = $savePack['backgroundMod'];
 $this->factionMod = $savePack['factionMod'];
 $this->softgearMod = $savePack['softgearMod'];
 $this->psyMod = $savePack['psyMod'];
 $this->defaultable = $savePack['defaultable'];
 $this->tempSkill = $savePack['tempSkill']; 
 $this->specialization = $savePack['specialization'];
 $this->isNativeTongue = $savePack['isNativeTongue'];
 $this->nativeTongueBonus = $savePack['nativeTongueBonus'];  

 # this is the new code:   
    if(isset($savePack['groupsArray'])){
    $this->groups = $savePack['groupsArray'];
     }
 # it replaces this part:
 #        if(isset($savePack['groupsArray'])){ 
 #                foreach($savePack['groupsArray'] as $m){
 #                    array_push($this->groups, $m);
 #                } 
 #            } 
        $this->maxValue = $savePack['maxValue'];  
        $this->maxValueMorphMod = $savePack['maxValueMorphMod'];
        $this->maxValueTraitMod = $savePack['maxValueTraitMod'];
        $this->maxValueFactionMod = $savePack['maxValueFactionMod'];
        $this->maxValueBackgroundMod = $savePack['maxValueBackgroundMod'];
        $this->maxValuePsyMod = $savePack['maxValuePsyMod'];
        $this->maxValueSoftgearMod = $savePack['maxValueSoftgearMod'];   
mace666 commented 8 years ago

The effect described in this issue ( #65 ) may beconnected with the problem described above. If there is a problem with the json string, loading seems to last forever.

mace666 commented 8 years ago

The duplication of the Groups array leads to awfully long JSON strings. And I think at some time the JSON parser reaches a maximum number of chars and fails.

mace666 commented 7 years ago

I just noticed my code post above was not displayed correctly. I changed that. Now you can see what I modified.