GunZ 2 Alpha Source Code

Page 5 of 9 FirstFirst 123456789 LastLast
Results 61 to 75 of 125
  1. #61
    igunz.net Dawson is offline
    LegendRank
    Feb 2010 Join Date
    ::1 (Canada BC)Location
    2,581Posts

    Re: GunZ 2 Alpha Source Code

    I didn't even upload the files, I'm using cell phone internet till the 1st, 'cause Shaw wanted to be a dick and decide they wanted to pull my internet because "You shouldn't even have 100 down and 25 up, that's not a residential plan" ANYWAY, because of all the drama on the 1st they're giving me 100 down and 15 up, but for 50% off for 3 months.

    CMB did the uploading.

  2. #62
    Die() Secured is offline
    MemberRank
    Sep 2011 Join Date
    /home/SDev/Location
    555Posts

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by ThePhailure772 View Post
    Oh, did not Dawson not include the database?

    Structure:
    Code:
    CREATE TABLE ChallengeQuestionRecord 
    (
    	ChallengeQuestionID		int NOT NULL
    	, CID					int NOT NULL
    	, SecondTime 			int NOT NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
              
    		  
    CREATE TABLE Character 
    (
    	CID	 			int 		NOT NULL	IDENTITY(1,1) 
    	, AID 			int 		NOT NULL
    	, DeleteFlag 	bit 		NOT NULL
    	, SlotIndex 	smallint 	NOT NULL	DEFAULT(0)
    	, CharPlayTime	int	 		NOT NULL	DEFAULT(0)
    	, Sex 			tinyint 	NOT NULL	DEFAULT(0)
    	, Class 		tinyint		NOT NULL	DEFAULT(0)
    	, AdminLevel 	tinyint		NOT NULL
    	, BP 			int 		NOT NULL
    	, Cash 			int 		NOT NULL
    	, Level 		smallint	NOT NULL	DEFAULT(1)
    	, Name 			nvarchar(20) NOT NULL	DEFAULT(N'UnKnown')
    	, LatestBattleType tinyint 	NOT NULL	DEFAULT(0)
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE CharacterLook 
    (
    	AID 			int NOT NULL
    	, CID 			int NOT NULL
    	, DeleteFlag 		bit NOT NULL	DEFAULT(0)
    	, UnderwearItemID	int NOT NULL	DEFAULT(0)
    	, UnderwearColor 	int NOT NULL	DEFAULT(0)
    	, TopItemID 		int NOT NULL	DEFAULT(0)
    	, TopColor		int NOT NULL	DEFAULT(0)
    	, PantsItemID		int NOT NULL	DEFAULT(0)
    	, PantsColor 		int NOT NULL	DEFAULT(0)
    	, HandItemID 		int NOT NULL	DEFAULT(0)	
    	, HandColor		int NOT NULL	DEFAULT(0)
    	, FootItemID		int NOT NULL	DEFAULT(0)
    	, FootColor 		int NOT NULL	DEFAULT(0)
    	, BackItemID 		int NOT NULL	DEFAULT(0)
    	, BackColor 		int NOT NULL	DEFAULT(0)
    	, HeadItemID 		int NOT NULL	DEFAULT(0)
    	, HeadColor		int NOT NULL	DEFAULT(0)
    	, FaceItemID 		int NOT NULL	DEFAULT(0)
    	, FaceColor 		int NOT NULL	DEFAULT(0)
    	, EarringItemID 	int NOT NULL	DEFAULT(0)
    	, EarringColor 		int NOT NULL	DEFAULT(0)
    	, NeckItemID 		int NOT NULL	DEFAULT(0)
    	, NeckColor	 	int NOT NULL	DEFAULT(0)
    	, FingerItemID 		int NOT NULL	DEFAULT(0)
    	, FingerColor 		int NOT NULL	DEFAULT(0)
    	, SetItemID 		int NOT NULL	DEFAULT(0)
    	, SetColor 		int NOT NULL	DEFAULT(0) 
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE CharBattleRecord 
    (
    	CID		int 		NOT NULL
    	, Type	smallint	NOT NULL
    	, Value int 		NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ChoiceProduct 
    (
    	ChoiceProdID		bigint	NOT NULL	IDENTITY(1,1)
    	, CID 				int 	NOT NULL
    	, Type 				tinyint	NOT NULL
    	, ProdSellPoliID	int		NOT NULL
    	, ProdID 			int	 	NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE Friend 
    (
    	CID			int NOT NULL
    	, FriendCID	int NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ItemInstance 
    ( 
    	IUID				bigint 		NOT NULL	IDENTITY(1,1)
    	, ItemID 			int		 	NOT NULL
    	, CID 				int	 		NOT NULL
    	, Durability		float		NOT NULL
    	, Color				int 		NOT NULL
    	, SlotType			tinyint 	NOT NULL
    	, SlotID 			smallint	NOT NULL
    	, UsagePeriod		int 		NOT NULL
    	, AddUsagePeriod	int 		NOT NULL	DEFAULT(0)
    	, ExpiDate			datetime 	NULL
    	, CharPlayTime		int 		NOT NULL
    	, UseCharPlayTime	int 		NOT NULL	DEFAULT(0)
    	, AccumuUsageTime	int 		NOT NULL	DEFAULT(0)
    	, UsageState		tinyint		NOT NULL	DEFAULT(0)
    	, ExpirationType	tinyint 	NOT NULL	DEFAULT(0)
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE Login 
    (
    	AID		int 			NOT NULL 	IDENTITY(1,1) 
    	, ID 	nvarchar(20) 	NOT NULL	DEFAULT(N'UnKnown')
    	, PWD 	nvarchar(20) 	NOT NULL	DEFAULT(N'None')
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ServerList 
    (
    	ID			int 	NOT NULL
    	, Type		tinyint NOT NULL
    	, GSID 		bigint 	NOT NULL
    	, TCPPort 	int 	NOT NULL
    	, UDPPort	int		NOT NULL
    	, Name		varchar(50) NOT NULL	DEFAULT('None')
    	, IP 		varchar(50) NOT NULL	DEFAULT('0.0.0.0')
    	, Memo		varchar(100) NOT NULL	DEFAULT('None')
    	, KeeperID	smallint NOT NULL		DEFAULT(0)
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE KeeperList 
    (
    	ID		int	 		NOT NULL
    	, IP 	varchar(24) NOT NULL
    	, Port 	int	 		NOT NULL
    	, Name 	varchar(24) NOT NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ServerOperationLog 
    (
    	OperationID		int	 	NOT NULL	IDENTITY(1,1)
    	, ProgramID 	int	 	NOT NULL
    	, SrartTime 	datetime NOT NULL
    	, EndTime	 	datetime NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ServerPatchLog 
    (
    	ProgramID 		int			NOT NULL
    	, PatchTime 	datetime	NOT NULL
    	, PatchResult 	int 		NOT NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ServerPatchSchedule 
    ( 
    	PatchID			int 		NOT NULL	IDENTITY(1,1)
    	, KeeperID	 	int 		NOT NULL
    	, ProgramID 	int 		NOT NULL
    	, PatchTime 	datetime	NOT NULL
    	, CycleMinute 	int 		NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    
    
    CREATE TABLE PlayerDataStageSetup 
    (
    	ID			int	 	NOT NULL	IDENTITY(1,1)
    	, CID 			int	 		NOT NULL 
    	, BattleType	smallint 	NOT NULL
    	, Name			nvarchar(33) NOT NULL	
    	, MapID 		smallint NOT NULL 
    	, MaxPlayer 	smallint NOT NULL 
    	, BattleRoundNum 		smallint NOT NULL 
    	, BattleTime 		smallint NOT NULL 
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    
    
    
    
    CREATE TABLE [dbo].[GameLog_BattleInfo] 
    (
    	BattleUID		bigint		NOT NULL	IDENTITY(1,1)
    	, MasterCID	 	int			NOT NULL 
    	, MasetrServerGroupNum	smallint	NOT NULL 
    	, HostCID		int 		NOT NULL
    	, HostServerGroupNum	smallint	NOT NULL
    	, MapID	 		int 		NOT NULL
    	, BattleType 	smallint	NOT NULL
    	, RoundCount	smallint	NOT NULL
    	, PlayTime		smallint 	NOT NULL
    	, StartDate		smalldatetime NOT NULL
    	, EndDate 		smalldatetime NOT NULL
    	, IsCompleted 	tinyint 	NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------         
               
    CREATE TABLE [dbo].[GameLog_KillDeath]
    (
    	BattleUID		bigint	NOT NULL,
    	RoundNumber		smallint NOT NULL, 
    	AttackerCID		int		NOT NULL,
    	VictimCID		int		NOT NULL,
    	AttackerServerGroupNum	smallint	NOT NULL,
    	VictimServerGroupNum		smallint	NOT NULL,
    	AttackerNPCID	int		NOT NULL,
    	VictimNPCID		int		NOT NULL,
    	WeaponID		int		NOT NULL,
    	REG_DATE		datetime NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------
    
    
    CREATE TABLE [dbo].[GameLog_WeaponShot]
    (
    	BattleUID	bigint		NOT NULL,
    	RoundNumber		smallint NOT NULL, 
    	CID			int			NOT NULL,
    	PlayerServerGroupNum	smallint		NOT NULL,
    	WeaponID	int			NOT NULL,
    	FireCount	int			NOT NULL,
    	HitCount	int			NOT NULL,
    	Damage		int			NOT NULL, 
    	REG_DATE	datetime	NOT NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    CREATE TABLE [dbo].[GameLog_WeaponTime]
    (
    	BattleUID	bigint	NOT NULL,
    	CID			int		NOT NULL, 
    	PlayerServerGroupNum	smallint		NOT NULL,
    	WeaponID	int		NOT NULL,
    	UseTime		int		NOT NULL, 
    	REG_DATE	datetime NOT NULL
    ) 
    GO 
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE [dbo].[GameLog_REFDATA_ITEM](
    	[ID] [int] NOT NULL,
    	[Name] [nvarchar](50) NOT NULL,
    	[Type] [int] NOT NULL,
    	[Level] [smallint] NOT NULL,
    	[Sex] [smallint] NOT NULL,
    	[CharRes] [smallint] NOT NULL,
    	[WeaponType] [smallint] NOT NULL,
    	[ItemType] [int] NOT NULL,
    	[Description] [nvarchar](150) NOT NULL,
     CONSTRAINT [PK_GameLog_REFDATA_ITEM] PRIMARY KEY CLUSTERED 
    (
    	[ID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    
    GO
    Stored procs:
    Code:
    CREATE PROCEDURE spChangeEquItemInstance
    (
    	@IUID1 bigint, @SlotID1 smallint, @UseCharPlayTime1 int, @AccumuUsageTime1 int,  
    	@IUID2 bigint, @SlotID2 smallint, @UseCharPlayTime2 int, @AccumuUsageTime2 int,  
    	@IUID3 bigint, @SlotID3 smallint, @UseCharPlayTime3 int, @AccumuUsageTime3 int 
    )
    AS	
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @RowCount	int
    	
    	BEGIN TRAN
    	
    	-- 1
    	UPDATE ItemInstance SET SlotID=@SlotID1, UseCharPlayTime=@UseCharPlayTime1, 
    				AccumuUsageTime=@AccumuUsageTime1 WHERE IUID=@IUID1;	SET @RowCount = @@ROWCOUNT	
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		GOTO ERROR_HANDLER;
    	END
    	
    	-- 2
    	IF( @IUID2 <> 0 )
    	BEGIN
    		UPDATE ItemInstance SET SlotID=@SlotID2, UseCharPlayTime=@UseCharPlayTime2, 
    				AccumuUsageTime=@AccumuUsageTime2 WHERE IUID=@IUID2;	SET @RowCount = @@ROWCOUNT	
    		
    		IF( @RowCount < 1 OR @@ERROR <> 0 )
    		BEGIN
    			GOTO ERROR_HANDLER;
    		END
    	END
    	
    	-- 3
    	IF( @IUID3 <> 0 )
    	BEGIN
    		UPDATE ItemInstance SET SlotID=@SlotID3, UseCharPlayTime=@UseCharPlayTime3, 
    				AccumuUsageTime=@AccumuUsageTime3 WHERE IUID=@IUID3;	SET @RowCount = @@ROWCOUNT	
    		
    		IF( @RowCount < 1 OR @@ERROR <> 0 )
    		BEGIN
    			GOTO ERROR_HANDLER;
    		END
    	END
    	
    	
    	COMMIT TRAN
    	return;
    	
    ERROR_HANDLER:
    	IF @@TRANCOUNT <> 0 ROLLBACK TRAN
    	
    	RAISERROR(N'Failed Update IUID1(%d), IUID2(%d), IUID3(%d).'
    		, 11
    		, 1
    		, @IUID1, @IUID2, @IUID3);
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spCharBattleRecordUpdate
    (
    	  @Update VARCHAR(2000)
    	, @Insert VARCHAR(2000)
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    
    	BEGIN TRAN;
    
    
    	UPDATE cbr
    	SET	   cbr.Value = cbr.Value + C.Value
    	FROM  (SELECT B.CID
    				, CAST(SUBSTRING(B.Val, 1, CHARINDEX('.', B.Val) - 1) AS SMALLINT) Kind	 
    				, CAST(SUBSTRING(B.Val + '.', CHARINDEX('.', B.Val) + 1, LEN(B.Val) - CHARINDEX('.', B.Val)) AS INT) Value
    		   FROM  (SELECT CAST(SUBSTRING(A.val_str, 1, CHARINDEX('.', A.val_str) - 1) AS INT) CID	 
    					   , SUBSTRING(A.val_str + '.', CHARINDEX('.', A.val_str) + 1, LEN(val_str) - CHARINDEX('.', A.val_str)) Val
    				  FROM  (SELECT LTRIM(RTRIM(SUBSTRING(@Update, c.num, CHARINDEX(',', @Update + ',', c.num) - c.num))) AS val_str
    			  			 FROM   dbo.cpt c
    						 WHERE  c.num <= LEN(@Update)
    						 AND	SUBSTRING(',' + @Update, c.num, 1) = ',') A) B) C
    		 , dbo.CharBattleRecord cbr
    	WHERE  cbr.CID = C.CID AND cbr.Type = C.Type;
    	
    	IF (0 <> @@ERROR) 
    	BEGIN
    		ROLLBACK TRAN;
    		RAISERROR(N'ERROR BATTLE UPDATE.', 11, 1);
    	END
    
    
    
    
    	INSERT INTO dbo.CharBattleRecord(CID, Type, Value)
    	SELECT B.CID
    		 , CAST(SUBSTRING(B.Val, 1, CHARINDEX('.', B.Val) - 1) AS SMALLINT) Type	 
    		 , CAST(SUBSTRING(B.Val + '.', CHARINDEX('.', B.Val) + 1, LEN(B.Val) - CHARINDEX('.', B.Val)) AS INT) Value
    	FROM  (SELECT CAST(SUBSTRING(A.val_str, 1, CHARINDEX('.', A.val_str) - 1) AS INT) CID	 
    				, SUBSTRING(A.val_str + '.', CHARINDEX('.', A.val_str) + 1, LEN(val_str) - CHARINDEX('.', A.val_str)) Val
    		   FROM  (SELECT LTRIM(RTRIM(SUBSTRING(@Insert, c.num, CHARINDEX(',', @Insert + ',', c.num) - c.num))) AS val_str
    				  FROM   dbo.cpt c
    				  WHERE  c.num <= LEN(@Insert)
    				  AND	  SUBSTRING(',' + @Insert, c.num, 1) = ',') A) B;
    				  
    	IF (0 <> @@ERROR) 
    	BEGIN
    		ROLLBACK TRAN;
    		RAISERROR(N'ERROR BATTLE INSERT.', 11, 1);
    	END
    
    
    	COMMIT TRAN;
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeleteCharacter
    (
    	@cid int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    
    	UPDATE Character SET DeleteFlag = 1 WHERE cid = @cid
    
    
    	IF (0 = @@ROWCOUNT)
    	BEGIN
    		RAISERROR(N'invalid character(CID:%d).'
    			, 11
    			, 1
    			, @CID);
    	END
    
    
    	UPDATE CharacterLook SET DeleteFlag = 1 WHERE CID = @cid
    	UPDATE ItemInstance SET UsageState = 10 WHERE CID = @cid
    	DELETE FROM Friend WHERE CID = @cid OR FriendCID = @cid
    	DELETE FROM ChoiceProduct WHERE CID = @cid
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeleteChoiceProduct
    (
    	@ChoiceProdID bigint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    
    	DELETE FROM ChoiceProduct WHERE ChoiceProdID = @ChoiceProdID
    
    
    	IF (0 = @@ROWCOUNT)
    	BEGIN
    		RAISERROR(N'invalid ChoiceProdID(ChoiceProdID:%I64d).'
    			, 11
    			, 1
    			, @ChoiceProdID);
    	END
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeleteFriend
    (
    	@CID int,
    	@FriendCID	int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DELETE FROM Friend WHERE CID = @CID AND FriendCID = @FriendCID
    
    
    	IF (0 = @@ROWCOUNT)
    	BEGIN
    		RAISERROR(N'invalid character(CID:%d), friend(CID:%d).'
    			, 11
    			, 1
    			, @CID, @FriendCID);
    	END
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeleteItemInstance
    (
    	@CID	int,
    	@IUID	bigint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	UPDATE ItemInstance SET UsageState = 10 WHERE CID = @CID AND IUID = @IUID
    END	
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeletePatchSchedule
    (
    	@PatchID int
    )
    AS
    BEGIN
    	DELETE FROM ServerPatchSchedule WHERE PatchID = @PatchID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDevAddItemInstance
    (
    	@ItemId int,
    	@CID int,
    	@Durability float,
    	@SlotType tinyint,
    	@CurTime int,
    	@ExpirationType tinyint,
    	@UsagePeriod int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @IUID bigint
    
    
    	INSERT INTO ItemInstance (ItemID, CID, Durability, Color, SlotType, 
    				SlotID, UsagePeriod, AddUsagePeriod, CharPlayTime, UseCharPlayTime, AccumuUsageTime, 
    				UsageState, ExpirationType ) VALUES 
    				(@ItemId, @CID, @Durability, 0, @SlotType, 
    				-1, @UsagePeriod, 0, @CurTime, 0, 0, 
    				0, @ExpirationType)
    
    
    	SET @IUID = SCOPE_IDENTITY()
    	SELECT @IUID AS IUID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertCharacter
    (
    	@AID int,
    	@Name nvarchar(20),
    	@SlotIndex smallint,
    	@Sex tinyint,
    	@Class tinyint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @FindCID int
    	SELECT @FindCID = CID FROM Character WHERE Name = @Name AND DeleteFlag = 0
    	IF (@FindCID is not null)
    	BEGIN
    		SELECT CID = -1
    		return
    	END
    	
    	INSERT INTO Character (AID, Name, DeleteFlag, SlotIndex, Sex, Class, Level, AdminLevel, BP, Cash) 
    	VALUES (@AID, @Name, 0, @SlotIndex, @Sex, @Class, 1, 0, 0, 0)
    	
    	SET @FindCID = SCOPE_IDENTITY()
    
    
    	INSERT INTO CharacterLook (AID, CID) VALUES (@AID, @FindCID)
    	/*
    	IF (1 = @Class)
    	BEGIN
    		-- 1 Head(4)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10179002, @FindCID, 0, 0 
    				   , 1, 17, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    		--  2 Top(1)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10129002, @FindCID, 0, 0 
    				   , 1, 12, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- 3 Pants(2)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10139002, @FindCID, 0, 0 
    				   , 1, 13, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- 4 Hand(12)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				  ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10149002, @FindCID, 0, 0 
    				   , 1, 14, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- 5 Foot(3)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10159002, @FindCID, 0, 0 
    				   , 1, 15, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    	END
    	*/		  
    	-- ¾î½Ø½Å 
    	IF (1 = @Class)
    	BEGIN		  
    		-- ¸ÞÀÎ 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10400001, @FindCID, 0, 0 
    				   , 1, 101, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 2
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10500002, @FindCID, 0, 0 
    				   , 1, 102, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¼­ºê 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10560001, @FindCID, 0, 0 
    				   , 1, 201, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 3
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10470001, @FindCID, 0, 0 
    				   , 1, 103, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 4
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10420001, @FindCID, 0, 0 
    				   , 1, 104, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 5
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10440001, @FindCID, 0, 0 
    				   , 1, 105, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    	END
    	
    	-- ÆÄÀÌÅÍ
    	IF (2 = @Class)
    	BEGIN		  
    		-- ¸ÞÀÎ 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10410001, @FindCID, 0, 0 
    				   , 1, 101, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 2
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10510001, @FindCID, 0, 0 
    				   , 1, 102, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¼­ºê 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10570001, @FindCID, 0, 0 
    				   , 1, 201, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 3
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10430001, @FindCID, 0, 0 
    				   , 1, 103, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 4
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10470001, @FindCID, 0, 0 
    				   , 1, 104, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 5
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10480001, @FindCID, 0, 0 
    				   , 1, 105, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    	END           
    	
    	-- Çìºñ
    	IF (4 = @Class)
    	BEGIN		  
    		-- ¸ÞÀÎ 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10450001, @FindCID, 0, 0 
    				   , 1, 101, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 2
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10460001, @FindCID, 0, 0 
    				   , 1, 102, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 3
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10530001, @FindCID, 0, 0 
    				   , 1, 103, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 4
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10550001, @FindCID, 0, 0 
    				   , 1, 104, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 5
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10470001, @FindCID, 0, 0 
    				   , 1, 105, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    	END
    						  
    			   
    	select @FindCID AS CID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertChoiceProduct
    (
    	@CID int,
    	@Type tinyint,
    	@ProdSellPoliID int, 
    	@ProdID int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @ChoiceProdID bigint
    
    
    	INSERT INTO ChoiceProduct (CID, Type, ProdSellPoliID, ProdID) 
    	VALUES (@CID, @Type, @ProdSellPoliID, @ProdID)
    
    
    	SET @ChoiceProdID = SCOPE_IDENTITY()
    	SELECT @ChoiceProdID AS ChoiceProdID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertFriend
    (
    	@CID int,
    	@FriendName varchar(20)
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @FindCID int
    	
    	SELECT @FindCID = CID FROM Character WHERE Name = @FriendName AND DeleteFlag = 0
    	
    	IF (@FindCID is null)
    	BEGIN
    		SELECT FriendCID = 0
    		return
    	END
    	
    	INSERT INTO Friend (CID, FriendCID) VALUES (@CID, @FindCID)
    	SELECT FriendCID = @FindCID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertKeeperInfo
    (
    	@ID int,
    	@IP varchar(24),
    	@Port int,
    	@Name varchar(24)
    )
    AS
    BEGIN
    	INSERT INTO KeeperList(ID, IP, Port, Name) VALUES (@ID, @IP, @Port, @Name)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertPatchSchedule
    (
    	@KeeperID int,
    	@ProgramID int,
    	@PatchTime datetime,
    	@CycleMinute int
    )
    AS
    BEGIN
    	IF (@CycleMinute = 0 AND datediff(minute, getdate(), @PatchTime) < 0)
    		return;
    
    
    	INSERT INTO ServerPatchSchedule(KeeperID, ProgramID, PatchTime, CycleMinute) 
    	VALUES (@KeeperID, @ProgramID, @PatchTime, @CycleMinute)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertProgramInfo
    (
    	@ProgramID int,
    	@KeeperID int,
    	@ProgramName varchar(32)
    )
    AS
    BEGIN 
    	INSERT INTO ProgramList(ProgramID, KeeperID, ProgramName) VALUES (@ProgramID, @KeeperID, @ProgramName)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertServerPatchLog
    (
    	@ProgramID int,
    	@PatchResult int
    )
    AS
    BEGIN
    	INSERT INTO ServerPatchLog(ProgramID, PatchTime, PatchResult) VALUES (@ProgramID, getdate(), @PatchResult)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertServerStartLog
    (
    	@ProgramID int
    )
    AS
    BEGIN 
    	INSERT INTO ServerOperationLog (ProgramID, SrartTime, EndTime) VALUES (@ProgramID, getdate(), null)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertServerStopLog
    (
    	@ProgramID int
    )
    AS
    BEGIN 
    	DECLARE @FindOperationID int
    	SELECT @FindOperationID = max(OperationID) FROM ServerOperationLog WHERE ProgramID = @ProgramID
    	
    	IF @FindOperationID is not null
    	BEGIN
    		UPDATE ServerOperationLog SET EndTime = getdate() WHERE OperationID = @FindOperationID
    	END
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spLogin
    (
    	@ID nvarchar(20)
    )
    AS
    BEGIN 
    	SELECT AID, PWD FROM Login WHERE id = @ID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSaveCharacterData
    (
    	@CID int, @CharPlayTime int, @BP int, @LatestBattleType tinyint, 
    	@SetItemID int, @SetColor int, @UnderwearItemID int, @UnderwearColor int, @TopItemID int, @TopColor int, 
    	@PantsItemID int, @PantsColor int, @HandItemID int, @HandColor int, @FootItemID int, @FootColor int, 
    	@BackItemID int, @BackColor int, @HeadItemID int, @HeadColor int, @FaceItemID int, @FaceColor int, 
    	@EarringItemID int, @EarringColor int, @NeckItemID int, @NeckColor int, @FingerItemID int, @FingerColor int 
    )
    AS	
    BEGIN
    	set nocount on;
    	DECLARE @RowCount	int
    	
    	BEGIN TRAN
    	
    	-- 1
    	UPDATE Character SET CharPlayTime=@CharPlayTime, BP=@BP, LatestBattleType=@LatestBattleType WHERE CID=@CID;	SET @RowCount = @@ROWCOUNT	
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		SELECT UpdateRowCount = -1;
    		GOTO ERROR_HANDLER;
    	END
    	
    	-- 2
    	UPDATE CharacterLook SET SetItemID=@SetItemID, SetColor=@SetColor, 
    							UnderwearItemID=@UnderwearItemID, UnderwearColor=@UnderwearColor, 
    							TopItemID=@TopItemID, TopColor=@TopColor, 
    							PantsItemID=@PantsItemID, PantsColor=@PantsColor, 
    							HandItemID=@HandItemID, HandColor=@HandColor, 
    							FootItemID=@FootItemID, FootColor=@FootColor, 
    							BackItemID=@BackItemID, BackColor=@BackColor, 
    							HeadItemID=@HeadItemID, HeadColor=@HeadColor, 
    							FaceItemID=@FaceItemID, FaceColor=@FaceColor, 
    							EarringItemID=@EarringItemID, EarringColor=@EarringColor, 
    							NeckItemID=@NeckItemID, NeckColor=@NeckColor, 
    							FingerItemID=@FingerItemID, FingerColor=@FingerColor 
    		WHERE CID=@CID;	SET @RowCount = @@ROWCOUNT	
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		SELECT UpdateRowCount = -2;
    		GOTO ERROR_HANDLER;
    	END
    	
    		
    	COMMIT TRAN
    	SELECT UpdateRowCount = 1
    	return;
    	
    ERROR_HANDLER:
    	IF @@TRANCOUNT <> 0 ROLLBACK TRAN
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectChallengeQuestionNumber
    (
    	@CID	int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    
    	SELECT ChallengeQuestionID FROM ChallengeQuestionRecord WITH (NOLOCK)
    	WHERE CID = @CID 
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectCharacterBattleRecord
    (
    	@CID	int
    )
    AS
    BEGIN 
    	SET NOCOUNT ON;
    
    
    	SELECT Type, Value FROM CharBattleRecord WITH (NOLOCK)
    	WHERE CID = @CID 
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectCharacterList
    (
    	@AID int
    )
    AS
    BEGIN 
    	select Charac.CID, Name, SlotIndex, Sex, Class, Charac.Level, CharPlayTime, AdminLevel, BP, Cash, LatestBattleType, 
    		SetItemID, SetColor, UnderwearItemID, UnderwearColor, TopItemID, TopColor,  
    		PantsItemID, PantsColor, HandItemID, HandColor, FootItemID, FootColor,  
    		BackItemID, BackColor, HeadItemID, HeadColor, FaceItemID, FaceColor, 
    		EarringItemID, EarringColor, NeckItemID, NeckColor, FingerItemID, FingerColor 
    	from Character as Charac, CharacterLook as Look 
    	where Charac.AID = @AID and Look.AID = @AID and Charac.CID = Look.CID and Charac.DeleteFlag = 0
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectChoiceProductList 
    (
    	@CID	int
    ) 
    AS
    BEGIN 
    	SET NOCOUNT ON;
    
    
    	SELECT ChoiceProdID, Type, ProdSellPoliID, ProdID FROM ChoiceProduct WITH (NOLOCK)
    	WHERE CID = @CID 
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectFriendList
    (
    	@CID int
    ) 
    AS
    BEGIN 
    	SELECT f.FriendCID, Name 
    	FROM (SELECT FriendCID FROM Friend WHERE CID = @CID) AS f, Character
    	WHERE CID = f.FriendCID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectItemInstanceList
    (
    	@CID	int
    ) 
    AS
    BEGIN 
    	SET NOCOUNT ON;
    
    
    	DECLARE @ExpirationTime int
       
        SELECT IUID, ItemID, Durability, Color, SlotType, SlotID
    		, UsagePeriod, AddUsagePeriod, CharPlayTime, UseCharPlayTime, AccumuUsageTime
    		, ExpirationType, DATEDIFF(mi, GETDATE(), ExpiDate) AS ExpirationTime		
    	FROM dbo.ItemInstance WITH (NOLOCK)
    	WHERE CID = @CID AND UsageState = 0 AND SlotType = 1;
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectKeeperList
    AS
    BEGIN
    	SELECT ID, IP, Port, Name FROM KeeperList
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectObserverList
    (	
    	@CID int
    ) 
    AS
    BEGIN 
    	SELECT CID FROM Friend WHERE FriendCID = @CID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectPatchSchedule
    AS
    BEGIN 
    	SELECT PatchID, KeeperID, ProgramID, PatchTime, CycleMinute
    	FROM ServerPatchSchedule
    	WHERE CycleMinute <> 0 or datediff(minute, getdate(), PatchTime) > 0
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectProgramList
    AS
    BEGIN 
    	SELECT ID, KeeperID, Name FROM ServerList
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectServerPatchSchedule
    (
    	@KeeperID int
    ) 
    AS
    BEGIN 
    	SELECT PatchID, ProgramID, PatchTime, CycleMinute
    	FROM ServerPatchSchedule
    	WHERE KeeperID = @KeeperID AND (CycleMinute <> 0 OR datediff(minute, getdate(), PatchTime) > 0)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spTempInsertLogin
    (
    	@ID nvarchar(20),
    	@PWD nvarchar(20)
    ) 
    AS
    BEGIN 
    	SET NOCOUNT ON;
    	DECLARE @FindAID int
    	
    	SELECT @FindAID = AID FROM Login WHERE ID = @ID
    	
    	IF (@FindAID is null)
    	BEGIN
    		INSERT INTO Login (ID, PWD) VALUES (@ID, @PWD)
    		SELECT aid FROM Login WHERE id = @ID
    	END
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    
    
    CREATE PROCEDURE spChangeWeaponSlot
    (
    	@SlotID1 smallint, @IUID1 bigint, @SlotID2 smallint, @IUID2 bigint  
    )
    AS	
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @RowCount	int
    	
    	BEGIN TRAN
    	
    	-- 1
    	UPDATE ItemInstance SET SlotID=@SlotID1 WHERE IUID=@IUID1;	SET @RowCount = @@ROWCOUNT	
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		GOTO ERROR_HANDLER;
    	END
    	
    	-- 2
    	IF( @IUID2 <> 0 )
    	BEGIN
    		UPDATE ItemInstance SET SlotID=@SlotID2 WHERE IUID=@IUID2;	SET @RowCount = @@ROWCOUNT	
    		
    		IF( @RowCount < 1 OR @@ERROR <> 0 )
    		BEGIN
    			GOTO ERROR_HANDLER;
    		END
    	END
    		
    	
    	COMMIT TRAN
    	return;
    	
    ERROR_HANDLER:
    	IF @@TRANCOUNT <> 0 ROLLBACK TRAN
    	
    	RAISERROR(N'Failed ChangeWeaponSlot Update IUID1(%d), IUID2(%d).'
    		, 11
    		, 1
    		, @IUID1, @IUID2);
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    
    
    CREATE PROCEDURE spSelectPlayerDataStageSetup
    (
    	@CID int
    )
    AS
    BEGIN 
    	SELECT ID, CID, BattleType, Name, MapID, MaxPlayer, BattleRoundNum, BattleTime FROM PlayerDataStageSetup where CID = @CID 
    END
    GO
    
    
    -------------------------------------------------------------------------------------------------------
    
    
    CREATE PROCEDURE spSavePlayerDataStageSetupUpdate
    (
    	@ID int,
    	@MapID smallint,
    	@Name nvarchar(33), 
    	@MaxPlayer smallint,
    	@BattleRoundNum smallint,
    	@BattleTime smallint
    )
    AS
    BEGIN
    	UPDATE PlayerDataStageSetup SET MapID = @MapID, Name = @Name, MaxPlayer = @MaxPlayer, BattleRoundNum = @BattleRoundNum, 
    							BattleTime = @BattleTime WHERE ID = @ID
    END
    
    
    CREATE PROCEDURE spSavePlayerDataStageSetupInsert
    (
    	@CID int, 
    	@BattleType tinyint, 
    	@MapID smallint,
    	@Name nvarchar(33), 
    	@MaxPlayer smallint,
    	@BattleRoundNum smallint,
    	@BattleTime smallint
    )
    AS
    BEGIN
    	INSERT INTO PlayerDataStageSetup (CID, BattleType, MapID, Name, MaxPlayer, BattleRoundNum, BattleTime) 
    			VALUES(@CID, @BattleType, @MapID, @Name, @MaxPlayer, @BattleRoundNum, @BattleTime )
    END
    -------------------------------------------------------------------------------------------------------
    
    
    CREATE PROC spGameLogInsertBattleInfo
    (
    	@MasterCID int,
    	@HostCID int,
    	@MasterServerGroupNum smallint, 
    	@HostServerGroupNum smallint, 
    	@MapID int,
    	@BattleType smallint, 
    	@RoundCount smallint, 
    	@PlayTime	smallint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @BattleUID bigint
    
    
    	INSERT INTO GameLog_BattleInfo (MasterCID, HostCID, MasterServerGroupNum, HostServerGroupNum, MapID, BattleType, RoundCount, PlayTime, StartDate, EndDate, IsCompleted) 
    	 VALUES (@MasterCID, @HostCID, @MasterServerGroupNum, @HostServerGroupNum, @MapID, @BattleType, @RoundCount, @PlayTime, getdate(), getdate(), 0)
    
    
    	SET @BattleUID = SCOPE_IDENTITY()
    	SELECT @BattleUID AS BattleUID
    END
    GO
    -----------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spGameLogUpdateEndBattle
    (
    	@BattleUID bigint,
    	@IsCompleted tinyint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @RowCount	int
    
    
    	UPDATE GameLog_BattleInfo SET IsCompleted=@IsCompleted, EndDate=GETDATE() WHERE BattleUID=@BattleUID;	
    	SET @RowCount = @@ROWCOUNT 
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		RAISERROR(N'Failed spGameLogUpdateEndBattle Update BattleUID(%d).'
    		, 11
    		, 1
    		, @BattleUID);
    	END
    END
    GO
    -----------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spGameLogInsertKillDeath
    (
        @BattleUID BIGINT, 
        @RoundNumber_1 smallint, @AttackerCID_1 int, @VictimCID_1 int, @AttackerServerGroupNum_1 smallint, @VictimServerGroupNum_1 smallint, 
        @AttackerNPCID_1 int, @VictimNPCID_1 int, @WeaponID_1 int, 
        @RoundNumber_2 smallint, @AttackerCID_2 int, @VictimCID_2 int, @AttackerServerGroupNum_2 smallint, @VictimServerGroupNum_2 smallint, 
        @AttackerNPCID_2 int, @VictimNPCID_2 int, @WeaponID_2 int, 
        @RoundNumber_3 smallint, @AttackerCID_3 int, @VictimCID_3 int, @AttackerServerGroupNum_3 smallint, @VictimServerGroupNum_3 smallint, 
        @AttackerNPCID_3 int, @VictimNPCID_3 int, @WeaponID_3 int, 
        @RoundNumber_4 smallint, @AttackerCID_4 int, @VictimCID_4 int, @AttackerServerGroupNum_4 smallint, @VictimServerGroupNum_4 smallint, 
        @AttackerNPCID_4 int, @VictimNPCID_4 int, @WeaponID_4 int, 
        @RoundNumber_5 smallint, @AttackerCID_5 int, @VictimCID_5 int, @AttackerServerGroupNum_5 smallint, @VictimServerGroupNum_5 smallint, 
        @AttackerNPCID_5 int, @VictimNPCID_5 int, @WeaponID_5 int, 
        @RoundNumber_6 smallint, @AttackerCID_6 int, @VictimCID_6 int, @AttackerServerGroupNum_6 smallint, @VictimServerGroupNum_6 smallint, 
        @AttackerNPCID_6 int, @VictimNPCID_6 int, @WeaponID_6 int, 
        @RoundNumber_7 smallint, @AttackerCID_7 int, @VictimCID_7 int, @AttackerServerGroupNum_7 smallint, @VictimServerGroupNum_7 smallint, 
        @AttackerNPCID_7 int, @VictimNPCID_7 int, @WeaponID_7 int, 
        @RoundNumber_8 smallint, @AttackerCID_8 int, @VictimCID_8 int, @AttackerServerGroupNum_8 smallint, @VictimServerGroupNum_8 smallint, 
        @AttackerNPCID_8 int, @VictimNPCID_8 int, @WeaponID_8 int
    )
    AS
        SET NOCOUNT ON;
        
        WITH KLOG (RoundNumber, AttackerCID, VictimCID, AttackerServerGroupNum, VictimServerGroupNum, AttackerNPCID, VictimNPCID, WeaponID) AS
            (
                SELECT @RoundNumber_1, @AttackerCID_1, @VictimCID_1, @AttackerServerGroupNum_1, @VictimServerGroupNum_1, @AttackerNPCID_1, @VictimNPCID_1, @WeaponID_1  
                 UNION ALL
                SELECT @RoundNumber_2, @AttackerCID_2, @VictimCID_2, @AttackerServerGroupNum_2, @VictimServerGroupNum_2, @AttackerNPCID_2, @VictimNPCID_2, @WeaponID_2 
                 UNION ALL
                SELECT @RoundNumber_3, @AttackerCID_3, @VictimCID_3, @AttackerServerGroupNum_3, @VictimServerGroupNum_3, @AttackerNPCID_3, @VictimNPCID_3, @WeaponID_3 
    			 UNION ALL	
                SELECT @RoundNumber_4, @AttackerCID_4, @VictimCID_4, @AttackerServerGroupNum_4, @VictimServerGroupNum_4, @AttackerNPCID_4, @VictimNPCID_4, @WeaponID_4 
                 UNION ALL
                SELECT @RoundNumber_5, @AttackerCID_5, @VictimCID_5, @AttackerServerGroupNum_5, @VictimServerGroupNum_5, @AttackerNPCID_5, @VictimNPCID_5, @WeaponID_5 
                 UNION ALL
                SELECT @RoundNumber_6, @AttackerCID_6, @VictimCID_6, @AttackerServerGroupNum_6, @VictimServerGroupNum_6, @AttackerNPCID_6, @VictimNPCID_6, @WeaponID_6
                  UNION ALL
                SELECT @RoundNumber_7, @AttackerCID_7, @VictimCID_7, @AttackerServerGroupNum_7, @VictimServerGroupNum_7, @AttackerNPCID_7, @VictimNPCID_7, @WeaponID_7
                 UNION ALL
                SELECT @RoundNumber_8, @AttackerCID_8, @VictimCID_8, @AttackerServerGroupNum_8, @VictimServerGroupNum_8, @AttackerNPCID_8, @VictimNPCID_8, @WeaponID_8
            )
        INSERT INTO GameLog_KillDeath (BattleUID, RoundNumber, AttackerCID, VictimCID, AttackerServerGroupNum, VictimServerGroupNum, AttackerNPCID, VictimNPCID, WeaponID, REG_DATE)    
        SELECT @BattleUID, RoundNumber, AttackerCID, VictimCID, AttackerServerGroupNum, VictimServerGroupNum, AttackerNPCID, VictimNPCID, WeaponID, GETDATE()
          FROM KLOG
         WHERE WeaponID > 0;
    GO
    -----------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spGameLogInsertWeaponShot
    (
        @BattleUID BIGINT, 
        @RoundNumber_1 smallint, @CID_1 int, @PlayerServerGroupNum_1 smallint, @WeaponID_1 int, @FireCount_1 int, @HitCount_1 int, @Damage_1 float, 
        @RoundNumber_2 smallint, @CID_2 int, @PlayerServerGroupNum_2 smallint, @WeaponID_2 int, @FireCount_2 int, @HitCount_2 int, @Damage_2 float, 
        @RoundNumber_3 smallint, @CID_3 int, @PlayerServerGroupNum_3 smallint, @WeaponID_3 int, @FireCount_3 int, @HitCount_3 int, @Damage_3 float, 
        @RoundNumber_4 smallint, @CID_4 int, @PlayerServerGroupNum_4 smallint, @WeaponID_4 int, @FireCount_4 int, @HitCount_4 int, @Damage_4 float, 
        @RoundNumber_5 smallint, @CID_5 int, @PlayerServerGroupNum_5 smallint, @WeaponID_5 int, @FireCount_5 int, @HitCount_5 int, @Damage_5 float, 
        @RoundNumber_6 smallint, @CID_6 int, @PlayerServerGroupNum_6 smallint, @WeaponID_6 int, @FireCount_6 int, @HitCount_6 int, @Damage_6 float, 
        @RoundNumber_7 smallint, @CID_7 int, @PlayerServerGroupNum_7 smallint, @WeaponID_7 int, @FireCount_7 int, @HitCount_7 int, @Damage_7 float, 
        @RoundNumber_8 smallint, @CID_8 int, @PlayerServerGroupNum_8 smallint, @WeaponID_8 int, @FireCount_8 int, @HitCount_8 int, @Damage_8 float, 
        @RoundNumber_9 smallint, @CID_9 int, @PlayerServerGroupNum_9 smallint, @WeaponID_9 int, @FireCount_9 int, @HitCount_9 int, @Damage_9 float, 
        @RoundNumber_10 smallint, @CID_10 int, @PlayerServerGroupNum_10 smallint, @WeaponID_10 int, @FireCount_10 int, @HitCount_10 int, @Damage_10 float, 
        @RoundNumber_11 smallint, @CID_11 int, @PlayerServerGroupNum_11 smallint, @WeaponID_11 int, @FireCount_11 int, @HitCount_11 int, @Damage_11 float, 
        @RoundNumber_12 smallint, @CID_12 int, @PlayerServerGroupNum_12 smallint, @WeaponID_12 int, @FireCount_12 int, @HitCount_12 int, @Damage_12 float
    )
    AS
        SET NOCOUNT ON;
        
        WITH KLOG (RoundNumber, CID, PlayerServerGroupNum, WeaponID, FireCount, HitCount, Damage) AS
            (
                SELECT @RoundNumber_1, @CID_1, @PlayerServerGroupNum_1, @WeaponID_1, @FireCount_1, @HitCount_1, @Damage_1  
                 UNION ALL
                SELECT @RoundNumber_2, @CID_2, @PlayerServerGroupNum_2, @WeaponID_2, @FireCount_2, @HitCount_2, @Damage_2 
                 UNION ALL
                SELECT @RoundNumber_3, @CID_3, @PlayerServerGroupNum_3, @WeaponID_3, @FireCount_3, @HitCount_3, @Damage_3 
    			 UNION ALL	
                SELECT @RoundNumber_4, @CID_4, @PlayerServerGroupNum_4, @WeaponID_4, @FireCount_4, @HitCount_4, @Damage_4 
                 UNION ALL
                SELECT @RoundNumber_5, @CID_5, @PlayerServerGroupNum_5, @WeaponID_5, @FireCount_5, @HitCount_5, @Damage_5 
                 UNION ALL
                SELECT @RoundNumber_6, @CID_6, @PlayerServerGroupNum_6, @WeaponID_6, @FireCount_6, @HitCount_6, @Damage_6
                  UNION ALL
                SELECT @RoundNumber_7, @CID_7, @PlayerServerGroupNum_7, @WeaponID_7, @FireCount_7, @HitCount_7, @Damage_7
                 UNION ALL
                SELECT @RoundNumber_8, @CID_8, @PlayerServerGroupNum_8, @WeaponID_8, @FireCount_8, @HitCount_8, @Damage_8
                 UNION ALL
                SELECT @RoundNumber_9, @CID_9, @PlayerServerGroupNum_9, @WeaponID_9, @FireCount_9, @HitCount_9, @Damage_9
                 UNION ALL
                SELECT @RoundNumber_10, @CID_10, @PlayerServerGroupNum_10, @WeaponID_10, @FireCount_10, @HitCount_10, @Damage_10
                 UNION ALL
                SELECT @RoundNumber_11, @CID_11, @PlayerServerGroupNum_11, @WeaponID_11, @FireCount_11, @HitCount_11, @Damage_11
                 UNION ALL
                SELECT @RoundNumber_12, @CID_12, @PlayerServerGroupNum_12, @WeaponID_12, @FireCount_12, @HitCount_12, @Damage_12
            )
        INSERT INTO GameLog_WeaponShot (BattleUID, RoundNumber, CID, PlayerServerGroupNum, WeaponID, FireCount, HitCount, Damage, REG_DATE)    
        SELECT @BattleUID, RoundNumber, CID, PlayerServerGroupNum, WeaponID, FireCount, HitCount, Damage, GETDATE()
          FROM KLOG
         WHERE CID > 0;
    GO
    -----------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spGameLogInsertWeaponTime
    (
        @BattleUID BIGINT, 
        @CID_1 int, @PlayerServerGroupNum_1 smallint, @WeaponID_1 int, @UseTime_1 int, 
        @CID_2 int, @PlayerServerGroupNum_2 smallint, @WeaponID_2 int, @UseTime_2 int, 
        @CID_3 int, @PlayerServerGroupNum_3 smallint, @WeaponID_3 int, @UseTime_3 int, 
        @CID_4 int, @PlayerServerGroupNum_4 smallint, @WeaponID_4 int, @UseTime_4 int, 
        @CID_5 int, @PlayerServerGroupNum_5 smallint, @WeaponID_5 int, @UseTime_5 int, 
        @CID_6 int, @PlayerServerGroupNum_6 smallint, @WeaponID_6 int, @UseTime_6 int, 
        @CID_7 int, @PlayerServerGroupNum_7 smallint, @WeaponID_7 int, @UseTime_7 int, 
        @CID_8 int, @PlayerServerGroupNum_8 smallint, @WeaponID_8 int, @UseTime_8 int, 
        @CID_9 int, @PlayerServerGroupNum_9 smallint, @WeaponID_9 int, @UseTime_9 int, 
        @CID_10 int, @PlayerServerGroupNum_10 smallint, @WeaponID_10 int, @UseTime_10 int, 
        @CID_11 int, @PlayerServerGroupNum_11 smallint, @WeaponID_11 int, @UseTime_11 int, 
        @CID_12 int, @PlayerServerGroupNum_12 smallint, @WeaponID_12 int, @UseTime_12 int 
    )
    AS
        SET NOCOUNT ON;
        
        WITH KLOG (CID, PlayerServerGroupNum, WeaponID, UseTime) AS
            (
                SELECT @CID_1, @PlayerServerGroupNum_1, @WeaponID_1, @UseTime_1  
                 UNION ALL
                SELECT @CID_2, @PlayerServerGroupNum_2, @WeaponID_2, @UseTime_2 
                 UNION ALL
                SELECT @CID_3, @PlayerServerGroupNum_3, @WeaponID_3, @UseTime_3 
    			 UNION ALL	
                SELECT @CID_4, @PlayerServerGroupNum_4, @WeaponID_4, @UseTime_4 
                 UNION ALL
                SELECT @CID_5, @PlayerServerGroupNum_5, @WeaponID_5, @UseTime_5 
                 UNION ALL
                SELECT @CID_6, @PlayerServerGroupNum_6, @WeaponID_6, @UseTime_6 
                  UNION ALL
                SELECT @CID_7, @PlayerServerGroupNum_7, @WeaponID_7, @UseTime_7 
                 UNION ALL
                SELECT @CID_8, @PlayerServerGroupNum_8, @WeaponID_8, @UseTime_8 
                 UNION ALL
                SELECT @CID_9, @PlayerServerGroupNum_9, @WeaponID_9, @UseTime_9 
                 UNION ALL
                SELECT @CID_10, @PlayerServerGroupNum_10, @WeaponID_10, @UseTime_10 
                 UNION ALL
                SELECT @CID_11, @PlayerServerGroupNum_11, @WeaponID_11, @UseTime_11 
                 UNION ALL
                SELECT @CID_12, @PlayerServerGroupNum_12, @WeaponID_12, @UseTime_12 
            )
        INSERT INTO GameLog_WeaponTime (BattleUID, CID, PlayerServerGroupNum, WeaponID, UseTime, REG_DATE)    
        SELECT @BattleUID, CID, PlayerServerGroupNum, WeaponID, UseTime, GETDATE()
          FROM KLOG
         WHERE CID > 0;
    GO
    -----------------------------------------------------------------------------------------------------------
    You beat me to this :c

  3. #63
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by SecretsOThePast View Post
    Yeah I'll be working on this in my spare time regardless of what happens or who works on it. If anyone is interested I can set up a subversion and you can watch my progress. I'll give read access to the public and write access to whomever.

    At the end of the day though I think we should work on this in the public eye.
    No closed source shit, no hoarding code until it's relatively developed to the point where we can customize a server.
    No withholding exploits, I don't want people crashing each other's work.
    And lastly, no infighting amongst developers. We have a common goal now, let's not fuck this one up.
    I don't mind checking in here and there, but I'll be busy with uni for at least 6 more months, having little to no time to spend on this.

  4. #64

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by ThePhailure772 View Post
    Oh, did not Dawson not include the database?

    Structure:
    Code:
    CREATE TABLE ChallengeQuestionRecord 
    (
    	ChallengeQuestionID		int NOT NULL
    	, CID					int NOT NULL
    	, SecondTime 			int NOT NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
              
    		  
    CREATE TABLE Character 
    (
    	CID	 			int 		NOT NULL	IDENTITY(1,1) 
    	, AID 			int 		NOT NULL
    	, DeleteFlag 	bit 		NOT NULL
    	, SlotIndex 	smallint 	NOT NULL	DEFAULT(0)
    	, CharPlayTime	int	 		NOT NULL	DEFAULT(0)
    	, Sex 			tinyint 	NOT NULL	DEFAULT(0)
    	, Class 		tinyint		NOT NULL	DEFAULT(0)
    	, AdminLevel 	tinyint		NOT NULL
    	, BP 			int 		NOT NULL
    	, Cash 			int 		NOT NULL
    	, Level 		smallint	NOT NULL	DEFAULT(1)
    	, Name 			nvarchar(20) NOT NULL	DEFAULT(N'UnKnown')
    	, LatestBattleType tinyint 	NOT NULL	DEFAULT(0)
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE CharacterLook 
    (
    	AID 			int NOT NULL
    	, CID 			int NOT NULL
    	, DeleteFlag 		bit NOT NULL	DEFAULT(0)
    	, UnderwearItemID	int NOT NULL	DEFAULT(0)
    	, UnderwearColor 	int NOT NULL	DEFAULT(0)
    	, TopItemID 		int NOT NULL	DEFAULT(0)
    	, TopColor		int NOT NULL	DEFAULT(0)
    	, PantsItemID		int NOT NULL	DEFAULT(0)
    	, PantsColor 		int NOT NULL	DEFAULT(0)
    	, HandItemID 		int NOT NULL	DEFAULT(0)	
    	, HandColor		int NOT NULL	DEFAULT(0)
    	, FootItemID		int NOT NULL	DEFAULT(0)
    	, FootColor 		int NOT NULL	DEFAULT(0)
    	, BackItemID 		int NOT NULL	DEFAULT(0)
    	, BackColor 		int NOT NULL	DEFAULT(0)
    	, HeadItemID 		int NOT NULL	DEFAULT(0)
    	, HeadColor		int NOT NULL	DEFAULT(0)
    	, FaceItemID 		int NOT NULL	DEFAULT(0)
    	, FaceColor 		int NOT NULL	DEFAULT(0)
    	, EarringItemID 	int NOT NULL	DEFAULT(0)
    	, EarringColor 		int NOT NULL	DEFAULT(0)
    	, NeckItemID 		int NOT NULL	DEFAULT(0)
    	, NeckColor	 	int NOT NULL	DEFAULT(0)
    	, FingerItemID 		int NOT NULL	DEFAULT(0)
    	, FingerColor 		int NOT NULL	DEFAULT(0)
    	, SetItemID 		int NOT NULL	DEFAULT(0)
    	, SetColor 		int NOT NULL	DEFAULT(0) 
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE CharBattleRecord 
    (
    	CID		int 		NOT NULL
    	, Type	smallint	NOT NULL
    	, Value int 		NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ChoiceProduct 
    (
    	ChoiceProdID		bigint	NOT NULL	IDENTITY(1,1)
    	, CID 				int 	NOT NULL
    	, Type 				tinyint	NOT NULL
    	, ProdSellPoliID	int		NOT NULL
    	, ProdID 			int	 	NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE Friend 
    (
    	CID			int NOT NULL
    	, FriendCID	int NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ItemInstance 
    ( 
    	IUID				bigint 		NOT NULL	IDENTITY(1,1)
    	, ItemID 			int		 	NOT NULL
    	, CID 				int	 		NOT NULL
    	, Durability		float		NOT NULL
    	, Color				int 		NOT NULL
    	, SlotType			tinyint 	NOT NULL
    	, SlotID 			smallint	NOT NULL
    	, UsagePeriod		int 		NOT NULL
    	, AddUsagePeriod	int 		NOT NULL	DEFAULT(0)
    	, ExpiDate			datetime 	NULL
    	, CharPlayTime		int 		NOT NULL
    	, UseCharPlayTime	int 		NOT NULL	DEFAULT(0)
    	, AccumuUsageTime	int 		NOT NULL	DEFAULT(0)
    	, UsageState		tinyint		NOT NULL	DEFAULT(0)
    	, ExpirationType	tinyint 	NOT NULL	DEFAULT(0)
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE Login 
    (
    	AID		int 			NOT NULL 	IDENTITY(1,1) 
    	, ID 	nvarchar(20) 	NOT NULL	DEFAULT(N'UnKnown')
    	, PWD 	nvarchar(20) 	NOT NULL	DEFAULT(N'None')
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ServerList 
    (
    	ID			int 	NOT NULL
    	, Type		tinyint NOT NULL
    	, GSID 		bigint 	NOT NULL
    	, TCPPort 	int 	NOT NULL
    	, UDPPort	int		NOT NULL
    	, Name		varchar(50) NOT NULL	DEFAULT('None')
    	, IP 		varchar(50) NOT NULL	DEFAULT('0.0.0.0')
    	, Memo		varchar(100) NOT NULL	DEFAULT('None')
    	, KeeperID	smallint NOT NULL		DEFAULT(0)
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE KeeperList 
    (
    	ID		int	 		NOT NULL
    	, IP 	varchar(24) NOT NULL
    	, Port 	int	 		NOT NULL
    	, Name 	varchar(24) NOT NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ServerOperationLog 
    (
    	OperationID		int	 	NOT NULL	IDENTITY(1,1)
    	, ProgramID 	int	 	NOT NULL
    	, SrartTime 	datetime NOT NULL
    	, EndTime	 	datetime NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ServerPatchLog 
    (
    	ProgramID 		int			NOT NULL
    	, PatchTime 	datetime	NOT NULL
    	, PatchResult 	int 		NOT NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE ServerPatchSchedule 
    ( 
    	PatchID			int 		NOT NULL	IDENTITY(1,1)
    	, KeeperID	 	int 		NOT NULL
    	, ProgramID 	int 		NOT NULL
    	, PatchTime 	datetime	NOT NULL
    	, CycleMinute 	int 		NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    
    
    CREATE TABLE PlayerDataStageSetup 
    (
    	ID			int	 	NOT NULL	IDENTITY(1,1)
    	, CID 			int	 		NOT NULL 
    	, BattleType	smallint 	NOT NULL
    	, Name			nvarchar(33) NOT NULL	
    	, MapID 		smallint NOT NULL 
    	, MaxPlayer 	smallint NOT NULL 
    	, BattleRoundNum 		smallint NOT NULL 
    	, BattleTime 		smallint NOT NULL 
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    
    
    
    
    
    
    CREATE TABLE [dbo].[GameLog_BattleInfo] 
    (
    	BattleUID		bigint		NOT NULL	IDENTITY(1,1)
    	, MasterCID	 	int			NOT NULL 
    	, MasetrServerGroupNum	smallint	NOT NULL 
    	, HostCID		int 		NOT NULL
    	, HostServerGroupNum	smallint	NOT NULL
    	, MapID	 		int 		NOT NULL
    	, BattleType 	smallint	NOT NULL
    	, RoundCount	smallint	NOT NULL
    	, PlayTime		smallint 	NOT NULL
    	, StartDate		smalldatetime NOT NULL
    	, EndDate 		smalldatetime NOT NULL
    	, IsCompleted 	tinyint 	NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------         
               
    CREATE TABLE [dbo].[GameLog_KillDeath]
    (
    	BattleUID		bigint	NOT NULL,
    	RoundNumber		smallint NOT NULL, 
    	AttackerCID		int		NOT NULL,
    	VictimCID		int		NOT NULL,
    	AttackerServerGroupNum	smallint	NOT NULL,
    	VictimServerGroupNum		smallint	NOT NULL,
    	AttackerNPCID	int		NOT NULL,
    	VictimNPCID		int		NOT NULL,
    	WeaponID		int		NOT NULL,
    	REG_DATE		datetime NOT NULL
    )
    GO
    ----------------------------------------------------------------------------------------------
    
    
    CREATE TABLE [dbo].[GameLog_WeaponShot]
    (
    	BattleUID	bigint		NOT NULL,
    	RoundNumber		smallint NOT NULL, 
    	CID			int			NOT NULL,
    	PlayerServerGroupNum	smallint		NOT NULL,
    	WeaponID	int			NOT NULL,
    	FireCount	int			NOT NULL,
    	HitCount	int			NOT NULL,
    	Damage		int			NOT NULL, 
    	REG_DATE	datetime	NOT NULL
    ) 
    GO
    ----------------------------------------------------------------------------------------------
    
    
    CREATE TABLE [dbo].[GameLog_WeaponTime]
    (
    	BattleUID	bigint	NOT NULL,
    	CID			int		NOT NULL, 
    	PlayerServerGroupNum	smallint		NOT NULL,
    	WeaponID	int		NOT NULL,
    	UseTime		int		NOT NULL, 
    	REG_DATE	datetime NOT NULL
    ) 
    GO 
    ----------------------------------------------------------------------------------------------
    
    
    
    
    CREATE TABLE [dbo].[GameLog_REFDATA_ITEM](
    	[ID] [int] NOT NULL,
    	[Name] [nvarchar](50) NOT NULL,
    	[Type] [int] NOT NULL,
    	[Level] [smallint] NOT NULL,
    	[Sex] [smallint] NOT NULL,
    	[CharRes] [smallint] NOT NULL,
    	[WeaponType] [smallint] NOT NULL,
    	[ItemType] [int] NOT NULL,
    	[Description] [nvarchar](150) NOT NULL,
     CONSTRAINT [PK_GameLog_REFDATA_ITEM] PRIMARY KEY CLUSTERED 
    (
    	[ID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    
    GO
    Stored procs:
    Code:
    CREATE PROCEDURE spChangeEquItemInstance
    (
    	@IUID1 bigint, @SlotID1 smallint, @UseCharPlayTime1 int, @AccumuUsageTime1 int,  
    	@IUID2 bigint, @SlotID2 smallint, @UseCharPlayTime2 int, @AccumuUsageTime2 int,  
    	@IUID3 bigint, @SlotID3 smallint, @UseCharPlayTime3 int, @AccumuUsageTime3 int 
    )
    AS	
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @RowCount	int
    	
    	BEGIN TRAN
    	
    	-- 1
    	UPDATE ItemInstance SET SlotID=@SlotID1, UseCharPlayTime=@UseCharPlayTime1, 
    				AccumuUsageTime=@AccumuUsageTime1 WHERE IUID=@IUID1;	SET @RowCount = @@ROWCOUNT	
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		GOTO ERROR_HANDLER;
    	END
    	
    	-- 2
    	IF( @IUID2 <> 0 )
    	BEGIN
    		UPDATE ItemInstance SET SlotID=@SlotID2, UseCharPlayTime=@UseCharPlayTime2, 
    				AccumuUsageTime=@AccumuUsageTime2 WHERE IUID=@IUID2;	SET @RowCount = @@ROWCOUNT	
    		
    		IF( @RowCount < 1 OR @@ERROR <> 0 )
    		BEGIN
    			GOTO ERROR_HANDLER;
    		END
    	END
    	
    	-- 3
    	IF( @IUID3 <> 0 )
    	BEGIN
    		UPDATE ItemInstance SET SlotID=@SlotID3, UseCharPlayTime=@UseCharPlayTime3, 
    				AccumuUsageTime=@AccumuUsageTime3 WHERE IUID=@IUID3;	SET @RowCount = @@ROWCOUNT	
    		
    		IF( @RowCount < 1 OR @@ERROR <> 0 )
    		BEGIN
    			GOTO ERROR_HANDLER;
    		END
    	END
    	
    	
    	COMMIT TRAN
    	return;
    	
    ERROR_HANDLER:
    	IF @@TRANCOUNT <> 0 ROLLBACK TRAN
    	
    	RAISERROR(N'Failed Update IUID1(%d), IUID2(%d), IUID3(%d).'
    		, 11
    		, 1
    		, @IUID1, @IUID2, @IUID3);
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spCharBattleRecordUpdate
    (
    	  @Update VARCHAR(2000)
    	, @Insert VARCHAR(2000)
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    
    	BEGIN TRAN;
    
    
    	UPDATE cbr
    	SET	   cbr.Value = cbr.Value + C.Value
    	FROM  (SELECT B.CID
    				, CAST(SUBSTRING(B.Val, 1, CHARINDEX('.', B.Val) - 1) AS SMALLINT) Kind	 
    				, CAST(SUBSTRING(B.Val + '.', CHARINDEX('.', B.Val) + 1, LEN(B.Val) - CHARINDEX('.', B.Val)) AS INT) Value
    		   FROM  (SELECT CAST(SUBSTRING(A.val_str, 1, CHARINDEX('.', A.val_str) - 1) AS INT) CID	 
    					   , SUBSTRING(A.val_str + '.', CHARINDEX('.', A.val_str) + 1, LEN(val_str) - CHARINDEX('.', A.val_str)) Val
    				  FROM  (SELECT LTRIM(RTRIM(SUBSTRING(@Update, c.num, CHARINDEX(',', @Update + ',', c.num) - c.num))) AS val_str
    			  			 FROM   dbo.cpt c
    						 WHERE  c.num <= LEN(@Update)
    						 AND	SUBSTRING(',' + @Update, c.num, 1) = ',') A) B) C
    		 , dbo.CharBattleRecord cbr
    	WHERE  cbr.CID = C.CID AND cbr.Type = C.Type;
    	
    	IF (0 <> @@ERROR) 
    	BEGIN
    		ROLLBACK TRAN;
    		RAISERROR(N'ERROR BATTLE UPDATE.', 11, 1);
    	END
    
    
    
    
    	INSERT INTO dbo.CharBattleRecord(CID, Type, Value)
    	SELECT B.CID
    		 , CAST(SUBSTRING(B.Val, 1, CHARINDEX('.', B.Val) - 1) AS SMALLINT) Type	 
    		 , CAST(SUBSTRING(B.Val + '.', CHARINDEX('.', B.Val) + 1, LEN(B.Val) - CHARINDEX('.', B.Val)) AS INT) Value
    	FROM  (SELECT CAST(SUBSTRING(A.val_str, 1, CHARINDEX('.', A.val_str) - 1) AS INT) CID	 
    				, SUBSTRING(A.val_str + '.', CHARINDEX('.', A.val_str) + 1, LEN(val_str) - CHARINDEX('.', A.val_str)) Val
    		   FROM  (SELECT LTRIM(RTRIM(SUBSTRING(@Insert, c.num, CHARINDEX(',', @Insert + ',', c.num) - c.num))) AS val_str
    				  FROM   dbo.cpt c
    				  WHERE  c.num <= LEN(@Insert)
    				  AND	  SUBSTRING(',' + @Insert, c.num, 1) = ',') A) B;
    				  
    	IF (0 <> @@ERROR) 
    	BEGIN
    		ROLLBACK TRAN;
    		RAISERROR(N'ERROR BATTLE INSERT.', 11, 1);
    	END
    
    
    	COMMIT TRAN;
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeleteCharacter
    (
    	@cid int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    
    	UPDATE Character SET DeleteFlag = 1 WHERE cid = @cid
    
    
    	IF (0 = @@ROWCOUNT)
    	BEGIN
    		RAISERROR(N'invalid character(CID:%d).'
    			, 11
    			, 1
    			, @CID);
    	END
    
    
    	UPDATE CharacterLook SET DeleteFlag = 1 WHERE CID = @cid
    	UPDATE ItemInstance SET UsageState = 10 WHERE CID = @cid
    	DELETE FROM Friend WHERE CID = @cid OR FriendCID = @cid
    	DELETE FROM ChoiceProduct WHERE CID = @cid
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeleteChoiceProduct
    (
    	@ChoiceProdID bigint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    
    	DELETE FROM ChoiceProduct WHERE ChoiceProdID = @ChoiceProdID
    
    
    	IF (0 = @@ROWCOUNT)
    	BEGIN
    		RAISERROR(N'invalid ChoiceProdID(ChoiceProdID:%I64d).'
    			, 11
    			, 1
    			, @ChoiceProdID);
    	END
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeleteFriend
    (
    	@CID int,
    	@FriendCID	int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DELETE FROM Friend WHERE CID = @CID AND FriendCID = @FriendCID
    
    
    	IF (0 = @@ROWCOUNT)
    	BEGIN
    		RAISERROR(N'invalid character(CID:%d), friend(CID:%d).'
    			, 11
    			, 1
    			, @CID, @FriendCID);
    	END
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeleteItemInstance
    (
    	@CID	int,
    	@IUID	bigint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	UPDATE ItemInstance SET UsageState = 10 WHERE CID = @CID AND IUID = @IUID
    END	
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDeletePatchSchedule
    (
    	@PatchID int
    )
    AS
    BEGIN
    	DELETE FROM ServerPatchSchedule WHERE PatchID = @PatchID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spDevAddItemInstance
    (
    	@ItemId int,
    	@CID int,
    	@Durability float,
    	@SlotType tinyint,
    	@CurTime int,
    	@ExpirationType tinyint,
    	@UsagePeriod int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @IUID bigint
    
    
    	INSERT INTO ItemInstance (ItemID, CID, Durability, Color, SlotType, 
    				SlotID, UsagePeriod, AddUsagePeriod, CharPlayTime, UseCharPlayTime, AccumuUsageTime, 
    				UsageState, ExpirationType ) VALUES 
    				(@ItemId, @CID, @Durability, 0, @SlotType, 
    				-1, @UsagePeriod, 0, @CurTime, 0, 0, 
    				0, @ExpirationType)
    
    
    	SET @IUID = SCOPE_IDENTITY()
    	SELECT @IUID AS IUID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertCharacter
    (
    	@AID int,
    	@Name nvarchar(20),
    	@SlotIndex smallint,
    	@Sex tinyint,
    	@Class tinyint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @FindCID int
    	SELECT @FindCID = CID FROM Character WHERE Name = @Name AND DeleteFlag = 0
    	IF (@FindCID is not null)
    	BEGIN
    		SELECT CID = -1
    		return
    	END
    	
    	INSERT INTO Character (AID, Name, DeleteFlag, SlotIndex, Sex, Class, Level, AdminLevel, BP, Cash) 
    	VALUES (@AID, @Name, 0, @SlotIndex, @Sex, @Class, 1, 0, 0, 0)
    	
    	SET @FindCID = SCOPE_IDENTITY()
    
    
    	INSERT INTO CharacterLook (AID, CID) VALUES (@AID, @FindCID)
    	/*
    	IF (1 = @Class)
    	BEGIN
    		-- 1 Head(4)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10179002, @FindCID, 0, 0 
    				   , 1, 17, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    		--  2 Top(1)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10129002, @FindCID, 0, 0 
    				   , 1, 12, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- 3 Pants(2)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10139002, @FindCID, 0, 0 
    				   , 1, 13, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- 4 Hand(12)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				  ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10149002, @FindCID, 0, 0 
    				   , 1, 14, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- 5 Foot(3)
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10159002, @FindCID, 0, 0 
    				   , 1, 15, 0, 0, '2011-12-25' 
    				   , 0, 0, 0, 0, 0)
    	END
    	*/		  
    	-- ¾î½Ø½Å 
    	IF (1 = @Class)
    	BEGIN		  
    		-- ¸ÞÀÎ 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10400001, @FindCID, 0, 0 
    				   , 1, 101, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 2
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10500002, @FindCID, 0, 0 
    				   , 1, 102, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¼­ºê 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10560001, @FindCID, 0, 0 
    				   , 1, 201, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 3
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10470001, @FindCID, 0, 0 
    				   , 1, 103, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 4
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10420001, @FindCID, 0, 0 
    				   , 1, 104, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 5
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10440001, @FindCID, 0, 0 
    				   , 1, 105, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    	END
    	
    	-- ÆÄÀÌÅÍ
    	IF (2 = @Class)
    	BEGIN		  
    		-- ¸ÞÀÎ 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10410001, @FindCID, 0, 0 
    				   , 1, 101, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 2
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10510001, @FindCID, 0, 0 
    				   , 1, 102, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¼­ºê 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10570001, @FindCID, 0, 0 
    				   , 1, 201, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 3
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10430001, @FindCID, 0, 0 
    				   , 1, 103, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 4
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10470001, @FindCID, 0, 0 
    				   , 1, 104, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 5
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10480001, @FindCID, 0, 0 
    				   , 1, 105, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    	END           
    	
    	-- Çìºñ
    	IF (4 = @Class)
    	BEGIN		  
    		-- ¸ÞÀÎ 1
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10450001, @FindCID, 0, 0 
    				   , 1, 101, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 2
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10460001, @FindCID, 0, 0 
    				   , 1, 102, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 3
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10530001, @FindCID, 0, 0 
    				   , 1, 103, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)           
    		-- ¸ÞÀÎ 4
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10550001, @FindCID, 0, 0 
    				   , 1, 104, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    		-- ¸ÞÀÎ 5
    		INSERT INTO ItemInstance (ItemID, CID, Durability, Color 
    				   ,SlotType, SlotID, UsagePeriod, AddUsagePeriod, ExpiDate 
    				   ,CharPlayTime, UseCharPlayTime, AccumuUsageTime, UsageState, ExpirationType) 
    			 VALUES (10470001, @FindCID, 0, 0 
    				   , 1, 105, 0, 0, '2012-12-25' 
    				   , 0, 0, 0, 0, 0)
    	END
    						  
    			   
    	select @FindCID AS CID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertChoiceProduct
    (
    	@CID int,
    	@Type tinyint,
    	@ProdSellPoliID int, 
    	@ProdID int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @ChoiceProdID bigint
    
    
    	INSERT INTO ChoiceProduct (CID, Type, ProdSellPoliID, ProdID) 
    	VALUES (@CID, @Type, @ProdSellPoliID, @ProdID)
    
    
    	SET @ChoiceProdID = SCOPE_IDENTITY()
    	SELECT @ChoiceProdID AS ChoiceProdID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertFriend
    (
    	@CID int,
    	@FriendName varchar(20)
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @FindCID int
    	
    	SELECT @FindCID = CID FROM Character WHERE Name = @FriendName AND DeleteFlag = 0
    	
    	IF (@FindCID is null)
    	BEGIN
    		SELECT FriendCID = 0
    		return
    	END
    	
    	INSERT INTO Friend (CID, FriendCID) VALUES (@CID, @FindCID)
    	SELECT FriendCID = @FindCID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertKeeperInfo
    (
    	@ID int,
    	@IP varchar(24),
    	@Port int,
    	@Name varchar(24)
    )
    AS
    BEGIN
    	INSERT INTO KeeperList(ID, IP, Port, Name) VALUES (@ID, @IP, @Port, @Name)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertPatchSchedule
    (
    	@KeeperID int,
    	@ProgramID int,
    	@PatchTime datetime,
    	@CycleMinute int
    )
    AS
    BEGIN
    	IF (@CycleMinute = 0 AND datediff(minute, getdate(), @PatchTime) < 0)
    		return;
    
    
    	INSERT INTO ServerPatchSchedule(KeeperID, ProgramID, PatchTime, CycleMinute) 
    	VALUES (@KeeperID, @ProgramID, @PatchTime, @CycleMinute)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertProgramInfo
    (
    	@ProgramID int,
    	@KeeperID int,
    	@ProgramName varchar(32)
    )
    AS
    BEGIN 
    	INSERT INTO ProgramList(ProgramID, KeeperID, ProgramName) VALUES (@ProgramID, @KeeperID, @ProgramName)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertServerPatchLog
    (
    	@ProgramID int,
    	@PatchResult int
    )
    AS
    BEGIN
    	INSERT INTO ServerPatchLog(ProgramID, PatchTime, PatchResult) VALUES (@ProgramID, getdate(), @PatchResult)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertServerStartLog
    (
    	@ProgramID int
    )
    AS
    BEGIN 
    	INSERT INTO ServerOperationLog (ProgramID, SrartTime, EndTime) VALUES (@ProgramID, getdate(), null)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spInsertServerStopLog
    (
    	@ProgramID int
    )
    AS
    BEGIN 
    	DECLARE @FindOperationID int
    	SELECT @FindOperationID = max(OperationID) FROM ServerOperationLog WHERE ProgramID = @ProgramID
    	
    	IF @FindOperationID is not null
    	BEGIN
    		UPDATE ServerOperationLog SET EndTime = getdate() WHERE OperationID = @FindOperationID
    	END
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spLogin
    (
    	@ID nvarchar(20)
    )
    AS
    BEGIN 
    	SELECT AID, PWD FROM Login WHERE id = @ID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSaveCharacterData
    (
    	@CID int, @CharPlayTime int, @BP int, @LatestBattleType tinyint, 
    	@SetItemID int, @SetColor int, @UnderwearItemID int, @UnderwearColor int, @TopItemID int, @TopColor int, 
    	@PantsItemID int, @PantsColor int, @HandItemID int, @HandColor int, @FootItemID int, @FootColor int, 
    	@BackItemID int, @BackColor int, @HeadItemID int, @HeadColor int, @FaceItemID int, @FaceColor int, 
    	@EarringItemID int, @EarringColor int, @NeckItemID int, @NeckColor int, @FingerItemID int, @FingerColor int 
    )
    AS	
    BEGIN
    	set nocount on;
    	DECLARE @RowCount	int
    	
    	BEGIN TRAN
    	
    	-- 1
    	UPDATE Character SET CharPlayTime=@CharPlayTime, BP=@BP, LatestBattleType=@LatestBattleType WHERE CID=@CID;	SET @RowCount = @@ROWCOUNT	
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		SELECT UpdateRowCount = -1;
    		GOTO ERROR_HANDLER;
    	END
    	
    	-- 2
    	UPDATE CharacterLook SET SetItemID=@SetItemID, SetColor=@SetColor, 
    							UnderwearItemID=@UnderwearItemID, UnderwearColor=@UnderwearColor, 
    							TopItemID=@TopItemID, TopColor=@TopColor, 
    							PantsItemID=@PantsItemID, PantsColor=@PantsColor, 
    							HandItemID=@HandItemID, HandColor=@HandColor, 
    							FootItemID=@FootItemID, FootColor=@FootColor, 
    							BackItemID=@BackItemID, BackColor=@BackColor, 
    							HeadItemID=@HeadItemID, HeadColor=@HeadColor, 
    							FaceItemID=@FaceItemID, FaceColor=@FaceColor, 
    							EarringItemID=@EarringItemID, EarringColor=@EarringColor, 
    							NeckItemID=@NeckItemID, NeckColor=@NeckColor, 
    							FingerItemID=@FingerItemID, FingerColor=@FingerColor 
    		WHERE CID=@CID;	SET @RowCount = @@ROWCOUNT	
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		SELECT UpdateRowCount = -2;
    		GOTO ERROR_HANDLER;
    	END
    	
    		
    	COMMIT TRAN
    	SELECT UpdateRowCount = 1
    	return;
    	
    ERROR_HANDLER:
    	IF @@TRANCOUNT <> 0 ROLLBACK TRAN
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectChallengeQuestionNumber
    (
    	@CID	int
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    
    	SELECT ChallengeQuestionID FROM ChallengeQuestionRecord WITH (NOLOCK)
    	WHERE CID = @CID 
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectCharacterBattleRecord
    (
    	@CID	int
    )
    AS
    BEGIN 
    	SET NOCOUNT ON;
    
    
    	SELECT Type, Value FROM CharBattleRecord WITH (NOLOCK)
    	WHERE CID = @CID 
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectCharacterList
    (
    	@AID int
    )
    AS
    BEGIN 
    	select Charac.CID, Name, SlotIndex, Sex, Class, Charac.Level, CharPlayTime, AdminLevel, BP, Cash, LatestBattleType, 
    		SetItemID, SetColor, UnderwearItemID, UnderwearColor, TopItemID, TopColor,  
    		PantsItemID, PantsColor, HandItemID, HandColor, FootItemID, FootColor,  
    		BackItemID, BackColor, HeadItemID, HeadColor, FaceItemID, FaceColor, 
    		EarringItemID, EarringColor, NeckItemID, NeckColor, FingerItemID, FingerColor 
    	from Character as Charac, CharacterLook as Look 
    	where Charac.AID = @AID and Look.AID = @AID and Charac.CID = Look.CID and Charac.DeleteFlag = 0
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectChoiceProductList 
    (
    	@CID	int
    ) 
    AS
    BEGIN 
    	SET NOCOUNT ON;
    
    
    	SELECT ChoiceProdID, Type, ProdSellPoliID, ProdID FROM ChoiceProduct WITH (NOLOCK)
    	WHERE CID = @CID 
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectFriendList
    (
    	@CID int
    ) 
    AS
    BEGIN 
    	SELECT f.FriendCID, Name 
    	FROM (SELECT FriendCID FROM Friend WHERE CID = @CID) AS f, Character
    	WHERE CID = f.FriendCID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectItemInstanceList
    (
    	@CID	int
    ) 
    AS
    BEGIN 
    	SET NOCOUNT ON;
    
    
    	DECLARE @ExpirationTime int
       
        SELECT IUID, ItemID, Durability, Color, SlotType, SlotID
    		, UsagePeriod, AddUsagePeriod, CharPlayTime, UseCharPlayTime, AccumuUsageTime
    		, ExpirationType, DATEDIFF(mi, GETDATE(), ExpiDate) AS ExpirationTime		
    	FROM dbo.ItemInstance WITH (NOLOCK)
    	WHERE CID = @CID AND UsageState = 0 AND SlotType = 1;
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectKeeperList
    AS
    BEGIN
    	SELECT ID, IP, Port, Name FROM KeeperList
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectObserverList
    (	
    	@CID int
    ) 
    AS
    BEGIN 
    	SELECT CID FROM Friend WHERE FriendCID = @CID
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectPatchSchedule
    AS
    BEGIN 
    	SELECT PatchID, KeeperID, ProgramID, PatchTime, CycleMinute
    	FROM ServerPatchSchedule
    	WHERE CycleMinute <> 0 or datediff(minute, getdate(), PatchTime) > 0
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectProgramList
    AS
    BEGIN 
    	SELECT ID, KeeperID, Name FROM ServerList
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spSelectServerPatchSchedule
    (
    	@KeeperID int
    ) 
    AS
    BEGIN 
    	SELECT PatchID, ProgramID, PatchTime, CycleMinute
    	FROM ServerPatchSchedule
    	WHERE KeeperID = @KeeperID AND (CycleMinute <> 0 OR datediff(minute, getdate(), PatchTime) > 0)
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spTempInsertLogin
    (
    	@ID nvarchar(20),
    	@PWD nvarchar(20)
    ) 
    AS
    BEGIN 
    	SET NOCOUNT ON;
    	DECLARE @FindAID int
    	
    	SELECT @FindAID = AID FROM Login WHERE ID = @ID
    	
    	IF (@FindAID is null)
    	BEGIN
    		INSERT INTO Login (ID, PWD) VALUES (@ID, @PWD)
    		SELECT aid FROM Login WHERE id = @ID
    	END
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    
    
    CREATE PROCEDURE spChangeWeaponSlot
    (
    	@SlotID1 smallint, @IUID1 bigint, @SlotID2 smallint, @IUID2 bigint  
    )
    AS	
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @RowCount	int
    	
    	BEGIN TRAN
    	
    	-- 1
    	UPDATE ItemInstance SET SlotID=@SlotID1 WHERE IUID=@IUID1;	SET @RowCount = @@ROWCOUNT	
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		GOTO ERROR_HANDLER;
    	END
    	
    	-- 2
    	IF( @IUID2 <> 0 )
    	BEGIN
    		UPDATE ItemInstance SET SlotID=@SlotID2 WHERE IUID=@IUID2;	SET @RowCount = @@ROWCOUNT	
    		
    		IF( @RowCount < 1 OR @@ERROR <> 0 )
    		BEGIN
    			GOTO ERROR_HANDLER;
    		END
    	END
    		
    	
    	COMMIT TRAN
    	return;
    	
    ERROR_HANDLER:
    	IF @@TRANCOUNT <> 0 ROLLBACK TRAN
    	
    	RAISERROR(N'Failed ChangeWeaponSlot Update IUID1(%d), IUID2(%d).'
    		, 11
    		, 1
    		, @IUID1, @IUID2);
    END
    GO
    -------------------------------------------------------------------------------------------------------
    
    
    
    
    
    
    CREATE PROCEDURE spSelectPlayerDataStageSetup
    (
    	@CID int
    )
    AS
    BEGIN 
    	SELECT ID, CID, BattleType, Name, MapID, MaxPlayer, BattleRoundNum, BattleTime FROM PlayerDataStageSetup where CID = @CID 
    END
    GO
    
    
    -------------------------------------------------------------------------------------------------------
    
    
    CREATE PROCEDURE spSavePlayerDataStageSetupUpdate
    (
    	@ID int,
    	@MapID smallint,
    	@Name nvarchar(33), 
    	@MaxPlayer smallint,
    	@BattleRoundNum smallint,
    	@BattleTime smallint
    )
    AS
    BEGIN
    	UPDATE PlayerDataStageSetup SET MapID = @MapID, Name = @Name, MaxPlayer = @MaxPlayer, BattleRoundNum = @BattleRoundNum, 
    							BattleTime = @BattleTime WHERE ID = @ID
    END
    
    
    CREATE PROCEDURE spSavePlayerDataStageSetupInsert
    (
    	@CID int, 
    	@BattleType tinyint, 
    	@MapID smallint,
    	@Name nvarchar(33), 
    	@MaxPlayer smallint,
    	@BattleRoundNum smallint,
    	@BattleTime smallint
    )
    AS
    BEGIN
    	INSERT INTO PlayerDataStageSetup (CID, BattleType, MapID, Name, MaxPlayer, BattleRoundNum, BattleTime) 
    			VALUES(@CID, @BattleType, @MapID, @Name, @MaxPlayer, @BattleRoundNum, @BattleTime )
    END
    -------------------------------------------------------------------------------------------------------
    
    
    CREATE PROC spGameLogInsertBattleInfo
    (
    	@MasterCID int,
    	@HostCID int,
    	@MasterServerGroupNum smallint, 
    	@HostServerGroupNum smallint, 
    	@MapID int,
    	@BattleType smallint, 
    	@RoundCount smallint, 
    	@PlayTime	smallint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @BattleUID bigint
    
    
    	INSERT INTO GameLog_BattleInfo (MasterCID, HostCID, MasterServerGroupNum, HostServerGroupNum, MapID, BattleType, RoundCount, PlayTime, StartDate, EndDate, IsCompleted) 
    	 VALUES (@MasterCID, @HostCID, @MasterServerGroupNum, @HostServerGroupNum, @MapID, @BattleType, @RoundCount, @PlayTime, getdate(), getdate(), 0)
    
    
    	SET @BattleUID = SCOPE_IDENTITY()
    	SELECT @BattleUID AS BattleUID
    END
    GO
    -----------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spGameLogUpdateEndBattle
    (
    	@BattleUID bigint,
    	@IsCompleted tinyint
    )
    AS
    BEGIN
    	SET NOCOUNT ON;
    	DECLARE @RowCount	int
    
    
    	UPDATE GameLog_BattleInfo SET IsCompleted=@IsCompleted, EndDate=GETDATE() WHERE BattleUID=@BattleUID;	
    	SET @RowCount = @@ROWCOUNT 
    	
    	IF( @RowCount < 1 OR @@ERROR <> 0 )
    	BEGIN
    		RAISERROR(N'Failed spGameLogUpdateEndBattle Update BattleUID(%d).'
    		, 11
    		, 1
    		, @BattleUID);
    	END
    END
    GO
    -----------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spGameLogInsertKillDeath
    (
        @BattleUID BIGINT, 
        @RoundNumber_1 smallint, @AttackerCID_1 int, @VictimCID_1 int, @AttackerServerGroupNum_1 smallint, @VictimServerGroupNum_1 smallint, 
        @AttackerNPCID_1 int, @VictimNPCID_1 int, @WeaponID_1 int, 
        @RoundNumber_2 smallint, @AttackerCID_2 int, @VictimCID_2 int, @AttackerServerGroupNum_2 smallint, @VictimServerGroupNum_2 smallint, 
        @AttackerNPCID_2 int, @VictimNPCID_2 int, @WeaponID_2 int, 
        @RoundNumber_3 smallint, @AttackerCID_3 int, @VictimCID_3 int, @AttackerServerGroupNum_3 smallint, @VictimServerGroupNum_3 smallint, 
        @AttackerNPCID_3 int, @VictimNPCID_3 int, @WeaponID_3 int, 
        @RoundNumber_4 smallint, @AttackerCID_4 int, @VictimCID_4 int, @AttackerServerGroupNum_4 smallint, @VictimServerGroupNum_4 smallint, 
        @AttackerNPCID_4 int, @VictimNPCID_4 int, @WeaponID_4 int, 
        @RoundNumber_5 smallint, @AttackerCID_5 int, @VictimCID_5 int, @AttackerServerGroupNum_5 smallint, @VictimServerGroupNum_5 smallint, 
        @AttackerNPCID_5 int, @VictimNPCID_5 int, @WeaponID_5 int, 
        @RoundNumber_6 smallint, @AttackerCID_6 int, @VictimCID_6 int, @AttackerServerGroupNum_6 smallint, @VictimServerGroupNum_6 smallint, 
        @AttackerNPCID_6 int, @VictimNPCID_6 int, @WeaponID_6 int, 
        @RoundNumber_7 smallint, @AttackerCID_7 int, @VictimCID_7 int, @AttackerServerGroupNum_7 smallint, @VictimServerGroupNum_7 smallint, 
        @AttackerNPCID_7 int, @VictimNPCID_7 int, @WeaponID_7 int, 
        @RoundNumber_8 smallint, @AttackerCID_8 int, @VictimCID_8 int, @AttackerServerGroupNum_8 smallint, @VictimServerGroupNum_8 smallint, 
        @AttackerNPCID_8 int, @VictimNPCID_8 int, @WeaponID_8 int
    )
    AS
        SET NOCOUNT ON;
        
        WITH KLOG (RoundNumber, AttackerCID, VictimCID, AttackerServerGroupNum, VictimServerGroupNum, AttackerNPCID, VictimNPCID, WeaponID) AS
            (
                SELECT @RoundNumber_1, @AttackerCID_1, @VictimCID_1, @AttackerServerGroupNum_1, @VictimServerGroupNum_1, @AttackerNPCID_1, @VictimNPCID_1, @WeaponID_1  
                 UNION ALL
                SELECT @RoundNumber_2, @AttackerCID_2, @VictimCID_2, @AttackerServerGroupNum_2, @VictimServerGroupNum_2, @AttackerNPCID_2, @VictimNPCID_2, @WeaponID_2 
                 UNION ALL
                SELECT @RoundNumber_3, @AttackerCID_3, @VictimCID_3, @AttackerServerGroupNum_3, @VictimServerGroupNum_3, @AttackerNPCID_3, @VictimNPCID_3, @WeaponID_3 
    			 UNION ALL	
                SELECT @RoundNumber_4, @AttackerCID_4, @VictimCID_4, @AttackerServerGroupNum_4, @VictimServerGroupNum_4, @AttackerNPCID_4, @VictimNPCID_4, @WeaponID_4 
                 UNION ALL
                SELECT @RoundNumber_5, @AttackerCID_5, @VictimCID_5, @AttackerServerGroupNum_5, @VictimServerGroupNum_5, @AttackerNPCID_5, @VictimNPCID_5, @WeaponID_5 
                 UNION ALL
                SELECT @RoundNumber_6, @AttackerCID_6, @VictimCID_6, @AttackerServerGroupNum_6, @VictimServerGroupNum_6, @AttackerNPCID_6, @VictimNPCID_6, @WeaponID_6
                  UNION ALL
                SELECT @RoundNumber_7, @AttackerCID_7, @VictimCID_7, @AttackerServerGroupNum_7, @VictimServerGroupNum_7, @AttackerNPCID_7, @VictimNPCID_7, @WeaponID_7
                 UNION ALL
                SELECT @RoundNumber_8, @AttackerCID_8, @VictimCID_8, @AttackerServerGroupNum_8, @VictimServerGroupNum_8, @AttackerNPCID_8, @VictimNPCID_8, @WeaponID_8
            )
        INSERT INTO GameLog_KillDeath (BattleUID, RoundNumber, AttackerCID, VictimCID, AttackerServerGroupNum, VictimServerGroupNum, AttackerNPCID, VictimNPCID, WeaponID, REG_DATE)    
        SELECT @BattleUID, RoundNumber, AttackerCID, VictimCID, AttackerServerGroupNum, VictimServerGroupNum, AttackerNPCID, VictimNPCID, WeaponID, GETDATE()
          FROM KLOG
         WHERE WeaponID > 0;
    GO
    -----------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spGameLogInsertWeaponShot
    (
        @BattleUID BIGINT, 
        @RoundNumber_1 smallint, @CID_1 int, @PlayerServerGroupNum_1 smallint, @WeaponID_1 int, @FireCount_1 int, @HitCount_1 int, @Damage_1 float, 
        @RoundNumber_2 smallint, @CID_2 int, @PlayerServerGroupNum_2 smallint, @WeaponID_2 int, @FireCount_2 int, @HitCount_2 int, @Damage_2 float, 
        @RoundNumber_3 smallint, @CID_3 int, @PlayerServerGroupNum_3 smallint, @WeaponID_3 int, @FireCount_3 int, @HitCount_3 int, @Damage_3 float, 
        @RoundNumber_4 smallint, @CID_4 int, @PlayerServerGroupNum_4 smallint, @WeaponID_4 int, @FireCount_4 int, @HitCount_4 int, @Damage_4 float, 
        @RoundNumber_5 smallint, @CID_5 int, @PlayerServerGroupNum_5 smallint, @WeaponID_5 int, @FireCount_5 int, @HitCount_5 int, @Damage_5 float, 
        @RoundNumber_6 smallint, @CID_6 int, @PlayerServerGroupNum_6 smallint, @WeaponID_6 int, @FireCount_6 int, @HitCount_6 int, @Damage_6 float, 
        @RoundNumber_7 smallint, @CID_7 int, @PlayerServerGroupNum_7 smallint, @WeaponID_7 int, @FireCount_7 int, @HitCount_7 int, @Damage_7 float, 
        @RoundNumber_8 smallint, @CID_8 int, @PlayerServerGroupNum_8 smallint, @WeaponID_8 int, @FireCount_8 int, @HitCount_8 int, @Damage_8 float, 
        @RoundNumber_9 smallint, @CID_9 int, @PlayerServerGroupNum_9 smallint, @WeaponID_9 int, @FireCount_9 int, @HitCount_9 int, @Damage_9 float, 
        @RoundNumber_10 smallint, @CID_10 int, @PlayerServerGroupNum_10 smallint, @WeaponID_10 int, @FireCount_10 int, @HitCount_10 int, @Damage_10 float, 
        @RoundNumber_11 smallint, @CID_11 int, @PlayerServerGroupNum_11 smallint, @WeaponID_11 int, @FireCount_11 int, @HitCount_11 int, @Damage_11 float, 
        @RoundNumber_12 smallint, @CID_12 int, @PlayerServerGroupNum_12 smallint, @WeaponID_12 int, @FireCount_12 int, @HitCount_12 int, @Damage_12 float
    )
    AS
        SET NOCOUNT ON;
        
        WITH KLOG (RoundNumber, CID, PlayerServerGroupNum, WeaponID, FireCount, HitCount, Damage) AS
            (
                SELECT @RoundNumber_1, @CID_1, @PlayerServerGroupNum_1, @WeaponID_1, @FireCount_1, @HitCount_1, @Damage_1  
                 UNION ALL
                SELECT @RoundNumber_2, @CID_2, @PlayerServerGroupNum_2, @WeaponID_2, @FireCount_2, @HitCount_2, @Damage_2 
                 UNION ALL
                SELECT @RoundNumber_3, @CID_3, @PlayerServerGroupNum_3, @WeaponID_3, @FireCount_3, @HitCount_3, @Damage_3 
    			 UNION ALL	
                SELECT @RoundNumber_4, @CID_4, @PlayerServerGroupNum_4, @WeaponID_4, @FireCount_4, @HitCount_4, @Damage_4 
                 UNION ALL
                SELECT @RoundNumber_5, @CID_5, @PlayerServerGroupNum_5, @WeaponID_5, @FireCount_5, @HitCount_5, @Damage_5 
                 UNION ALL
                SELECT @RoundNumber_6, @CID_6, @PlayerServerGroupNum_6, @WeaponID_6, @FireCount_6, @HitCount_6, @Damage_6
                  UNION ALL
                SELECT @RoundNumber_7, @CID_7, @PlayerServerGroupNum_7, @WeaponID_7, @FireCount_7, @HitCount_7, @Damage_7
                 UNION ALL
                SELECT @RoundNumber_8, @CID_8, @PlayerServerGroupNum_8, @WeaponID_8, @FireCount_8, @HitCount_8, @Damage_8
                 UNION ALL
                SELECT @RoundNumber_9, @CID_9, @PlayerServerGroupNum_9, @WeaponID_9, @FireCount_9, @HitCount_9, @Damage_9
                 UNION ALL
                SELECT @RoundNumber_10, @CID_10, @PlayerServerGroupNum_10, @WeaponID_10, @FireCount_10, @HitCount_10, @Damage_10
                 UNION ALL
                SELECT @RoundNumber_11, @CID_11, @PlayerServerGroupNum_11, @WeaponID_11, @FireCount_11, @HitCount_11, @Damage_11
                 UNION ALL
                SELECT @RoundNumber_12, @CID_12, @PlayerServerGroupNum_12, @WeaponID_12, @FireCount_12, @HitCount_12, @Damage_12
            )
        INSERT INTO GameLog_WeaponShot (BattleUID, RoundNumber, CID, PlayerServerGroupNum, WeaponID, FireCount, HitCount, Damage, REG_DATE)    
        SELECT @BattleUID, RoundNumber, CID, PlayerServerGroupNum, WeaponID, FireCount, HitCount, Damage, GETDATE()
          FROM KLOG
         WHERE CID > 0;
    GO
    -----------------------------------------------------------------------------------------------------------
    
    
    
    
    CREATE PROC spGameLogInsertWeaponTime
    (
        @BattleUID BIGINT, 
        @CID_1 int, @PlayerServerGroupNum_1 smallint, @WeaponID_1 int, @UseTime_1 int, 
        @CID_2 int, @PlayerServerGroupNum_2 smallint, @WeaponID_2 int, @UseTime_2 int, 
        @CID_3 int, @PlayerServerGroupNum_3 smallint, @WeaponID_3 int, @UseTime_3 int, 
        @CID_4 int, @PlayerServerGroupNum_4 smallint, @WeaponID_4 int, @UseTime_4 int, 
        @CID_5 int, @PlayerServerGroupNum_5 smallint, @WeaponID_5 int, @UseTime_5 int, 
        @CID_6 int, @PlayerServerGroupNum_6 smallint, @WeaponID_6 int, @UseTime_6 int, 
        @CID_7 int, @PlayerServerGroupNum_7 smallint, @WeaponID_7 int, @UseTime_7 int, 
        @CID_8 int, @PlayerServerGroupNum_8 smallint, @WeaponID_8 int, @UseTime_8 int, 
        @CID_9 int, @PlayerServerGroupNum_9 smallint, @WeaponID_9 int, @UseTime_9 int, 
        @CID_10 int, @PlayerServerGroupNum_10 smallint, @WeaponID_10 int, @UseTime_10 int, 
        @CID_11 int, @PlayerServerGroupNum_11 smallint, @WeaponID_11 int, @UseTime_11 int, 
        @CID_12 int, @PlayerServerGroupNum_12 smallint, @WeaponID_12 int, @UseTime_12 int 
    )
    AS
        SET NOCOUNT ON;
        
        WITH KLOG (CID, PlayerServerGroupNum, WeaponID, UseTime) AS
            (
                SELECT @CID_1, @PlayerServerGroupNum_1, @WeaponID_1, @UseTime_1  
                 UNION ALL
                SELECT @CID_2, @PlayerServerGroupNum_2, @WeaponID_2, @UseTime_2 
                 UNION ALL
                SELECT @CID_3, @PlayerServerGroupNum_3, @WeaponID_3, @UseTime_3 
    			 UNION ALL	
                SELECT @CID_4, @PlayerServerGroupNum_4, @WeaponID_4, @UseTime_4 
                 UNION ALL
                SELECT @CID_5, @PlayerServerGroupNum_5, @WeaponID_5, @UseTime_5 
                 UNION ALL
                SELECT @CID_6, @PlayerServerGroupNum_6, @WeaponID_6, @UseTime_6 
                  UNION ALL
                SELECT @CID_7, @PlayerServerGroupNum_7, @WeaponID_7, @UseTime_7 
                 UNION ALL
                SELECT @CID_8, @PlayerServerGroupNum_8, @WeaponID_8, @UseTime_8 
                 UNION ALL
                SELECT @CID_9, @PlayerServerGroupNum_9, @WeaponID_9, @UseTime_9 
                 UNION ALL
                SELECT @CID_10, @PlayerServerGroupNum_10, @WeaponID_10, @UseTime_10 
                 UNION ALL
                SELECT @CID_11, @PlayerServerGroupNum_11, @WeaponID_11, @UseTime_11 
                 UNION ALL
                SELECT @CID_12, @PlayerServerGroupNum_12, @WeaponID_12, @UseTime_12 
            )
        INSERT INTO GameLog_WeaponTime (BattleUID, CID, PlayerServerGroupNum, WeaponID, UseTime, REG_DATE)    
        SELECT @BattleUID, CID, PlayerServerGroupNum, WeaponID, UseTime, GETDATE()
          FROM KLOG
         WHERE CID > 0;
    GO
    -----------------------------------------------------------------------------------------------------------

    For those who are lazy, download it and import;
    DOWNLOAD NOW!

  5. #65
    Valued Member grandao is offline
    MemberRank
    Feb 2008 Join Date
    RJ - BrasilLocation
    128Posts

    Re: GunZ 2 Alpha Source Code

    The main problem is that there are many hidden devs working in the same thing, instead of work together and make progress, is lacking communication.

  6. #66
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by grandao View Post
    The main problem is that there are many hidden devs working in the same thing, instead of work together and make progress, is lacking communication.
    If only there was something like SVN that would prevent that. Oh wait, there is.

  7. #67
    Account Upgraded | Title Enabled! x1nixmzeng is offline
    MemberRank
    Nov 2007 Join Date
    England, UKLocation
    240Posts

    Re: GunZ 2 Alpha Source Code

    I'm happy to see this go public but there would be a lot of work to do in order to get a suitable clients. Also, is this the client Dawson recorded his videos/screencasts from?

  8. #68
    igunz.net Dawson is offline
    LegendRank
    Feb 2010 Join Date
    ::1 (Canada BC)Location
    2,581Posts

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by x1nixmzeng View Post
    I'm happy to see this go public but there would be a lot of work to do in order to get a suitable clients. Also, is this the client Dawson recorded his videos/screencasts from?
    yarp.

  9. #69
    Valued Member grandao is offline
    MemberRank
    Feb 2008 Join Date
    RJ - BrasilLocation
    128Posts

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by Wizkidje View Post
    If only there was something like SVN that would prevent that. Oh wait, there is.
    you are very smart.

  10. #70
    Enthusiast BloodHunters is offline
    MemberRank
    Nov 2012 Join Date
    41Posts

    Re: GunZ 2 Alpha Source Code

    error.jpg


    Can you help get the error

  11. #71
    Ancient One cmb is offline
    DeveloperRank
    Mar 2007 Join Date
    1,035Posts

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by BloodHunters View Post
    error.jpg


    Can you help get the error
    it is recommended to use Visual Studio 2008 to compile these files, using any other version of visual studio may yield undesired results (like what you have)

  12. #72
    Enthusiast BloodHunters is offline
    MemberRank
    Nov 2012 Join Date
    41Posts

    Re: GunZ 2 Alpha Source Code

    error.jpg

    get an error

  13. #73
    Account Upgraded | Title Enabled! CheckPoint is offline
    MemberRank
    Sep 2009 Join Date
    507Posts

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by BloodHunters View Post
    error.jpg

    get an error
    Because you just converted the original solution to VS2012.

  14. #74
    Enthusiast BloodHunters is offline
    MemberRank
    Nov 2012 Join Date
    41Posts

    Re: GunZ 2 Alpha Source Code

    What should I do

  15. #75
    Ancient One cmb is offline
    DeveloperRank
    Mar 2007 Join Date
    1,035Posts

    Re: GunZ 2 Alpha Source Code

    Quote Originally Posted by BloodHunters View Post
    What should I do
    well, you could try to fix your errors in VS2012. or restore the project and solution files back to their original state, and get a non-express version of VS2008 (because the files use MFC libs and the express edition does NOT contain these) and try again.



Advertisement