ALTER PROCEDURE [dbo].[spInsertChar]
@nAID INT,
@nCharIndex INT,
@szName nvarchar(32),
@nSex INT,
@nHair INT,
@nFace INT,
@nCostume INT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @cnt INT
<--- cause of "New Character Missing"
SELECT @cnt=COUNT(*)
(e.g First Character has CharNum of 0, 2nd character is 1 and so on.
FROM Character
When you delete for example you 1st character this code counts you characters again
WHERE AID = @nAID
but now you have 2 characters aleady so @cnt=COUNT(*) will be equal to 2 so
"New Character Missing" occurs here for there is already a character assigned to CharNum=1,thus this duplicate CharNum=1 and you cant see the new character
DECLARE @cid INT
<--- cause of "Item Sharing"
SELECT @cid=COUNT(*)
same problem as above (NOTE: @cid=COUNT(*) counts all characters,
FROM Character
lets assume there are 30 characters so the last character has A CID of 29.)
But this time when you delete a character, for example a character that has a CID of 10, @cid=COUNT(*) counts all character in the database and there are 29 characters so @cid=COUNT(*) will be equal to 29 now and "CID duplication" occurs which leads to "Item Sharing" for the same CID is use.
INSERT INTO Character
VALUES(@nAID,@szName,@cnt,1,@nSex,@nCostume,@nFace,@nHair,NULL,0,'1,000',0,0,0,0,0,0,0,0,0,0,0,0,@cnt,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL,getdate(),getdate(),0)