CREATE PROCEDURE [dbo].[NERO_LOGIN]
@AccountID varchar(21),
@Password varchar(32),
@nRet smallint OUTPUT
AS
/*
Written by Nero.
*/
-- Check Account
Select @nRet = Count(strAccountID) From TB_USER Where strAccountID = @AccountID
IF @nRet = 0
BEGIN
INSERT INTO TB_USER (strAccountID, strPasswd, strSocNo, iDays, strWarehouseNo) VALUES (@AccountID, @Password, 1, '6', 000000)
END
DECLARE @pwd varchar(32), @count int, @Nation int, @CharNum int
BEGIN
-- Retrieve account data
SELECT @pwd = strPasswd FROM TB_USER WHERE strAccountID = @AccountID
-- Account does not exits
IF @@ROWCOUNT = 0
BEGIN
SET @nRet = 2
RETURN
END
-- Empty password
ELSE IF @pwd IS NULL
BEGIN
SET @nRet = 0
RETURN
END
-- Invalid password
ELSE IF @pwd <> @Password
BEGIN
SET @nRet = 3
RETURN
END
-- 3 Day's Premium
DECLARE @Premium varchar(21)
SELECT @Premium = count(straccountid) FROM PREMIUM_SERVICE WHERE strAccountID = @AccountID
IF @Premium = 0
BEGIN
INSERT INTO PREMIUM_SERVICE (strAccountID, strType, nDays) VALUES (@AccountID, 1, 3)
END
-- Nation check
SELECT @Nation = bNation, @CharNum = bCharNum FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
IF @@ROWCOUNT = 0
BEGIN
SET @nRet = 1
RETURN
END
IF @CharNum = 0
BEGIN
SET @nRet = 1
RETURN
END
ELSE
BEGIN
SET @nRet = @Nation+1
--SET @nRet = 1
RETURN
END
END
GO