- // delete/resurect character
- bool CCharServer::pakDeleteChar( CCharClient* thisclient, CPacket* P )
- {
- if(!thisclient->isLoggedIn) return false;
- char* name = (char*)&P->Buffer[2];
- if(!CheckEscapeMySQL(name,-1,true))
- {
- Log(MSG_WARNING,"A name (delete / resurrect) contains incorrect caracter (see warnings above)");
- return false;
- }
- MYSQL_RES *result;
- MYSQL_ROW row;
- result = DB->QStore("SELECT account_name FROM characters WHERE char_name='%s' LIMIT 1", name);
- if(result==NULL) return false;
- row = mysql_fetch_row(result);
- //LMA: no case.
- //if (strcmp(row[0], thisclient->username)!=0)
- if (stricmp(row[0], thisclient->username)!=0)
- {
- Log(MSG_HACK, "User %s tried deleting another users (%s) character.", thisclient->username, name);
- DB->QFree( );
- return false;
- }
- DB->QFree( );
- short int action = GETBYTE((*P), 1 );
- unsigned long int DeleteTime = 0;
- switch(action)
- {
- case 0x00://Resurrect
- {
- DeleteTime = 0;
- //if(!DB->QExecute(" UPDATE characters SET deletetime=0 WHERE char_name='%s'",(char*)&P->Buffer[2] ))
- if(!DB->QExecute(" UPDATE characters SET deletetime=0 WHERE char_name='%s'",name))
- {
- return false;
- }
- }
- break;
- case 0x01://Delete
- {
- DeleteTime = GetServerTime( ) + Config.DeleteTime;
- //if(!DB->QExecute(" UPDATE characters SET deletetime=%i WHERE char_name='%s'",DeleteTime, (char*)&P->Buffer[2] ))
- if(!DB->QExecute(" UPDATE characters SET deletetime=%i WHERE char_name='%s'",DeleteTime,name))
- {
- return false;
- }
- }
- break;
- }
- BEGINPACKET( pak, 0x714 );
- if(DeleteTime > 0 )
- {
- ADDDWORD ( pak, Config.DeleteTime );
- }
- else
- {
- ADDDWORD ( pak, 0x00000000 );
- }
- ADDSTRING ( pak, (char*)&P->Buffer[2] );
- ADDBYTE ( pak, 0x00 );
- thisclient->SendPacket( &pak );
- return true;
- }
The testers have been reporting bugs when logging in- All of them deleted a character and created a new one.
I have tested them myself and have concluded that the CharServer doesn't delete the entries/records in the items.sql corresponding to that character to be deleted in characters.sql. And because of that problem, the CharServer hangs for a duplicate entry when the new char logs in. And then something worst happens.
To detail it, the problem is triggered when someone creates a new character - and that NEW character TOOK the ID that was once used. But the problem doesn't end with the CharServer crashing, since items.sql is not cleared from the previous delete, the new character then gets ALL previous items from that ID. Sad.
Anyway! I'am looking forward to fixing this with your help.
I reviewed CharServer(main) and have found this:
Correct me if I'm wrong, should we add a command somewhere below line 45 something like:
- DELETE FROM list_item WHERE owner=%s
(Laughing so hard why I came up with that.. I don't know how to do this I'm really sorry. Just giving an idea, I don't really know how to begin it anyway.)
OR IS THIS A PACKET ISSUE?