Page MenuHomeFeedback Tracker

Adding extra saved variables to playerbase breaks
Closed, ResolvedPublic

Description

So I have some facepaint added to as an integer to playerbase but for some reason extra integers are read when OnStoreLoad triggers, even if my mod is last. To fix this I added a string as follows:

	override void OnStoreSave( ParamsWriteContext ctx )
	{
        super.OnStoreSave( ctx );
        // store facepaint
        if ( GetDayZGame().IsServer() && GetDayZGame().IsMultiplayer() )
		{
            ctx.Write( "DUG" ); // bullshit but it works, what a fucking HACK
            ctx.Write( m_DUGFacePaint );
        }
    }

	override bool OnStoreLoad( ParamsReadContext ctx, int version )
	{
        if (!super.OnStoreLoad( ctx, version))
            return false;
        
        if ( GetDayZGame().IsServer() && GetDayZGame().IsMultiplayer() )
		{
            // read facepaint
            int facepaint = 0;
            string dugfp = "";
            if (!ctx.Read(dugfp))
            {
                return false;
            }
            if(!ctx.Read(facepaint)) {
                return false;
            }
            m_DUGFacePaint = facepaint;
        }
        return true;
    }

If I do not read a string I get a random integer, mostly 3 for female characters back? Adding the string DUG fixes the issue with existing characters before that facepaint integer was added. Something in the engine I guess stores an extra integer after everything else? usually 3. Sometimes it something else breaking whatever my integer was supposed to be and crashing people.

Details

Severity
Minor
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
General
Steps To Reproduce

Add extra int to OnStoreSave, check on load, value changes to 3 on female characters.

Additional Information

If you need more info please contact me, I worked around it with the code above.

Event Timeline

Geez changed the task status from New to Assigned.May 21 2020, 1:18 PM
nigel added a subscriber: nigel.May 28 2020, 3:57 PM
Geez changed the task status from Assigned to Need More Info.Jan 8 2021, 12:14 PM
Geez added a subscriber: Geez.

Hello wouter.commandeur.
Is there still an issue with this? Do you experience the crashing on new characters as well? Or only on characters from older version?
Regards,
Geez

I will check this weekend.

I suggest you check what is returned when you want to read the string. I would imagine that that will be also damaged.

string dugfp = "";
if (!ctx.Read(dugfp))
{
    return false;
}
Print(dugfp);

Are you running any other mods? Because they can, depending on the load order and if they call super, destroy the data stream

It's been a while but I tested with a fresh wiped server with only my mod I believe.

This comment was removed by Geez.

@Geez You can close this issue, I just tried with a fresh player db and can nolonger reproduce the problem.

Geez closed this task as Resolved.Jan 13 2021, 11:52 AM
Geez claimed this task.