p_characterDelete Function not working!

General discussion about Life is Feudal MMO and Life is Feudal: Your Own, The main section and backbone of the forums.
User avatar
XopVoluspa
True Believer
 
Posts: 2
Joined: 15 Jun 2015, 22:39

p_characterDelete Function not working!

Post by XopVoluspa » 29 Nov 2015, 20:30

Hello! I am having an issue with some of my players being able to delete a character manually. I think it has to do with the fact that we implemented a script to limit each account to 1 character (unless they're a GM). But we did have some players help us out before server launch, which means they had that one character before our limit was implemented. But maybe there is something wrong with the function? Here is the error I'm getting:

https://i.imgur.com/7Guwxz6.png

Any help would be super appreciated! We have a workaround, but it would be a useful tool to have available.


Alakar
Beta Tester
 
Posts: 202
Joined: 23 Jan 2015, 07:39

Re: p_characterDelete Function not working!

Post by Alakar » 30 Nov 2015, 05:59

Change the procedure to look more like this
Code: Select all
BEGIN
   declare eqContID, invContID, delCharacterID int unsigned default null;
   declare isCharFound tinyint unsigned default 0; -- not found by default

   declare exit handler for sqlexception
   begin
      rollback;
      resignal;
   end;

  select EquipmentContainerID, RootContainerID from `character` where id = inCharID and AccountID = inAccID
      into eqContID, invContID;

   if(eqContID is not null and invContID is not null) then
      set isCharFound = 1; -- found

     START TRANSACTION;

      DELETE FROM skills WHERE CharacterID = inCharID;
      DELETE FROM equipment_slots WHERE CharacterID = inCharID;
      DELETE FROM character_wounds WHERE CharacterID = inCharID;
      DELETE FROM character_titles WHERE CharacterID = inCharID;
      -- DELETE FROM guest_links WHERE characterId = inCharID;

      -- personal_lands -> claims -> (claim_rules, unmovable_objects_claims)
      DELETE FROM claim_rules              WHERE ClaimID IN (SELECT ID FROM claims WHERE PersonalLandID IN (SELECT ID FROM personal_lands WHERE CharID = inCharID));
      DELETE FROM unmovable_objects_claims WHERE ClaimID IN (SELECT ID FROM claims WHERE PersonalLandID IN (SELECT ID FROM personal_lands WHERE CharID = inCharID));
      DELETE FROM claims WHERE PersonalLandID IN (SELECT ID FROM personal_lands WHERE CharID = inCharID);
      DELETE FROM personal_lands WHERE CharID = inCharID;

      -- claim_subjects -> (claim_rules, claim_rules_unmovable)
      DELETE FROM claim_rules           WHERE ClaimSubjectID IN (SELECT ID FROM claim_subjects WHERE CharID = inCharID);
      DELETE FROM claim_rules_unmovable WHERE ClaimSubjectID IN (SELECT ID FROM claim_subjects WHERE CharID = inCharID);
      DELETE FROM claim_subjects WHERE CharID = inCharID;

      -- DELETE FROM minigame_results WHERE characterID = inCharID;
      DELETE FROM food_eaten WHERE CharID = inCharID;
      -- DELETE FROM guild_actions WHERE CharID = inCharID;
      -- DELETE FROM guild_actions WHERE ProducerCharID = inCharID;
      DELETE FROM chars_deathlog WHERE CharID = inCharID;
      DELETE FROM chars_deathlog WHERE KillerID = inCharID;
      DELETE FROM skill_raise_logs WHERE PlayerID = inCharID;

      UPDATE movable_objects SET CarrierCharacterID = NULL WHERE CarrierCharacterID = inCharID;
      UPDATE movable_objects SET OwnerID = NULL, DroppedTime = 0 WHERE OwnerID = inCharID;
      UPDATE unmovable_objects SET OwnerID = NULL, DroppedTime = 0 WHERE OwnerID = inCharID;
      -- _cm_old_cmLocks
      -- UPDATE geo_data SET PrivatePropertyPlayerID=0 WHERE PrivatePropertyPlayerID = inCharID;
      -- /_cm_old_cmLocks

      -- clear guild_actions_queue data
      insert into deleted_character_info
         (ExCharID, CharName, CharLastName)
         select ID, Name, LastName from `character` WHERE ID = inCharID;
      set delCharacterID = LAST_INSERT_ID();

      DELETE FROM guild_actions_queue where ProducerCharID = inCharID or CharID = inCharID;
      UPDATE guild_actions_processed set ProducerCharDeletedID = delCharacterID, ProducerCharID = NULL where ProducerCharID = inCharID;
      UPDATE guild_actions_processed set CharDeletedID = delCharacterID, CharID = NULL where CharID = inCharID;

      -- Deletion Fix - Alakar 11/19/15
      DELETE FROM character_effects WHERE CharacterID = inCharID;
      -- End of Deletion Fix      

      DELETE FROM `character` WHERE ID = inCharID;

      CALL f_deleteContainer(eqContID);
      CALL f_deleteContainer(invContID);

      COMMIT;
   end if;

   select isCharFound as `found`;

END

Return to General Discussion