PATCH - DOLCharacterBackup Erroring on Duplicate Entry

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

PATCH - DOLCharacterBackup Erroring on Duplicate Entry

Postby Kadorien » Sat Oct 16, 2010 9:49 pm

I noticed that if a character is deleted and backed-up but shares the same name as a prior backed up character the console would display an error regarding a duplicate entry. The following patch will fix this problem by checking to see if a character in the back-up exists with that characters name. If a duplicate is discovered the old back-up will be removed and the new back-up will take it's place

If it would be liked I can add in the feature so that if for instance Account A makes CharacterA and Account A deleted CharacterA and than Account B makes CharacterA and proceeds to delete him that there would be a way to name Account B's back-up CharacterA1 and require a rename on next boot.

This, I assume is how live works in a sense (when merging the clusters people with duplicate names would have that happen).

Either way, this fixes the current code in place and if people feel that the above could would be useful I can find time to crank that out as well or if a better route is needed than that can be submitted as well.

The only other suggestion I could think of is prevent Name from being a 'key' to allow duplicates of Name. I'm not sure how this would work when copied over if a character with the same name exists.

Code: Select all
13:23:17,535 - [3] - ERROR - DOL.Database.ObjectDatabase - Error while adding data object DOLCharactersBackup e11089ab-968f-44a5-bb41-63711b5214e2
MySql.Data.MySqlClient.MySqlException (0x80004005): Duplicate entry 'Kallendra' for key 'Name'
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
   at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at DOL.Database.Connection.DataConnection.ExecuteNonQuery(String sqlcommand) in Source\DOLDatabase\Connection\DataConnection.cs:line 235
   at DOL.Database.Handlers.MySQLObjectDatabase.AddObjectImpl(DataObject dataObject) Source\DOLDatabase\Handlers\MySQLObjectDatabase.cs:line 158
Attachments
deletecharacter.patch
(5.72 KiB) Downloaded 15 times
Kadorien
DOL Novice
 
Posts: 57
Joined: Wed Sep 08, 2010 1:14 am

Re: PATCH - DOLCharacterBackup Erroring on Duplicate Entry

Postby Tolakram » Sun Oct 17, 2010 12:11 am

Hi Kadorian,

your fix certainly works but I've made the following change to allow backups of the same char name:

Made name virtual and added an override in DOLCharactersBackup:

Code: Select all
            /// <summary>
            /// Name of this character - indexed but not unique for backups
            /// </summary>
            [DataElement(AllowDbNull = false, Index = true)]
            public override string Name
            {
                get
                {
                    return base.Name;
                }
                set
                {
                    Dirty = true;
                    base.Name = value;
                }
            }


This will be in SVN shortly. You can also quickly fix this by removing the unique index in your DOLCharactersBackup table and creating a non unique index on Name.

Thanks for bringing this to our attention.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: PATCH - DOLCharacterBackup Erroring on Duplicate Entry

Postby Kadorien » Sun Oct 17, 2010 12:22 am

Tolakram,

That is what I figured would end up happening but I wasn't quite sure. My only question is, I'm assuming DOLCharactersBackup is used for if someone deletes there character on accident. However, what if someone has taken that characters name already, does this just become a GM to Member conversation of "Hey, your name is taken, what new name do you want" as I assume DOLCharacters doesn't allow duplicate names or is there a measure in the code to respond if a duplicate name exists?
Kadorien
DOL Novice
 
Posts: 57
Joined: Wed Sep 08, 2010 1:14 am

Re: PATCH - DOLCharacterBackup Erroring on Duplicate Entry

Postby Tolakram » Sun Oct 17, 2010 12:36 am

Yes, I would use Heidi SQL to copy the backup row, paste the insert statement and change the name.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest