capadocius

Initiate
So here the deal: I must add a new stat (experience points) to the playerMobile. So i got an Experience class that look like this for now:

public class Experience
{
public int pointXP { get; set; }

public Experience()
{
pointXP = 0;
}
}

so a get; set; and something to initialize when it's called. after that i placed it in playerMobile like this

public PlayerMobile(){
blablabla;
blablabla;
blabalala;

Experience m_exp=New Experience(); //around line 3950 of playerMobile

after i call the serialize/deserialize

public override void Deserialize(GenericReader reader)
{

blablablabala;
blablalbablal;

case 1:
{
m_LongTermElapse = reader.ReadTimeSpan();
m_ShortTermElapse = reader.ReadTimeSpan();
m_GameTime = reader.ReadTimeSpan();
m_exp.pointXP = reader.ReadInt(); //supose to read the IO stream for m_exp.PointXP
goto case 0;
}
}

public override void Serialize(GenericWriter writer)
{
blablabla;
blablabla;
blabla;

writer.Write(m_LongTermElapse);
writer.Write(m_ShortTermElapse);
writer.Write(GameTime);
writer.Write(m_exp.pointXP);

}

So here the problem, there must be something wrong in the way I use the writer and the reader because when i shut down the server i have to erase created PlayerMobile because it Say it can't read the IOstream to the end. Ideas on what I did wrong?
 
Adding a new property in Deserialize to an existing switch case will cause any existing playermobiles to be deleted.

you have to create a new switch for the new property
 
ok so it would have to look like this then?:

public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();

switch (version)
{
case 36:
m_exp = new Experience(reader);
...

public override void Serialize(GenericWriter writer)
{
//cleanup our anti-macro table
...
}

CheckKillDecay();
HumilityHunt = false;
CheckAtrophies(this);

base.Serialize(writer);

writer.Write(36); // version

m_exp.Serialize(writer);

because i still have saving problems
 

Active Shards

  • Unchained
    Custom (Classic)
    • Players
    • 138 Online
    • 273 Peak
  • UO Eventine
    Custom (Classic)
    • Players
    • 90 Online
    • 137 Peak
  • The Crossroads
    Mondain's Legacy
    • Players
    • 87 Online
    • 190 Peak
  • Insane UO
    Endless Journey
    • Players
    • 83 Online
    • 105 Peak
  • UO: New Renaissance
    Custom (Classic)
    • Players
    • 33 Online
    • 85 Peak
  • CALYPSO
    Custom (Modern)
    • Players
    • 28 Online
    • 30 Peak
  • Arth
    Custom (Modern)
    • Players
    • 22 Online
    • 34 Peak
  • Heritage
    New Legacy
    • Players
    • 20 Online
    • 41 Peak
  • UO Phoenix
    Custom (Classic)
    • Players
    • 19 Online
    • 48 Peak
  • UO Enigma
    Custom (Modern)
    • Players
    • 19 Online
    • 172 Peak

Donations

Total amount
$0.00
Goal
$500.00
Back