CREATE PROCEDURE p_fzero_ranking @ListId int AS BEGIN -- For each game -- Drop temporary tmp_List table and recreate it drop table tmp_List CREATE TABLE tmp_List ( [ListId] [int] NULL, [UserId] [int] NULL, [ListDataId] [int] NULL , [total1] [int] NULL, [total2] [int] NULL, [total3] [int] NULL, [total4] [int] NULL, [total5] [int] NULL, [intvalue1] [int] NULL, [intvalue2] [int] NULL, [intvalue3] [int] NULL, [intvalue4] [int] NULL, [intvalue5] [int] NULL, [intvalue6] [int] NULL, [intvalue7] [int] NULL, [intvalue8] [int] NULL, [intvalue9] [int] NULL, [intvalue10] [int] NULL, [intvalue11] [int] NULL, [intvalue12] [int] NULL, [intvalue13] [int] NULL, [intvalue14] [int] NULL, [intvalue15] [int] NULL, [intvalue16] [int] NULL, [intvalue17] [int] NULL, [intvalue18] [int] NULL, [intvalue19] [int] NULL, [intvalue20] [int] NULL, [intvalue21] [int] NULL, [intvalue22] [int] NULL, [intvalue23] [int] NULL, [intvalue24] [int] NULL, [intvalue25] [int] NULL, [intvalue26] [int] NULL, [intvalue27] [int] NULL, [intvalue28] [int] NULL, [intvalue29] [int] NULL, [intvalue30] [int] NULL, [intvalue31] [int] NULL, [intvalue32] [int] NULL, [intvalue33] [int] NULL, [intvalue34] [int] NULL, [intvalue35] [int] NULL, [intvalue36] [int] NULL, [intvalue37] [int] NULL, [intvalue38] [int] NULL, [intvalue39] [int] NULL, [intvalue40] [int] NULL, [strvalue1] [varchar] (255) NULL, [strvalue2] [varchar] (255) NULL, [strvalue3] [varchar] (255) NULL, [strvalue4] [varchar] (255) NULL, [strvalue5] [varchar] (255) NULL, [strvaluelong1] [varchar] (2000) NULL, [strvaluelong2] [varchar] (2000) NULL ) ON [PRIMARY] DECLARE @IntValue1 int, @IntValue2 int, @IntValue3 int, @IntValue4 int, @IntValue5 int, @IntValue6 int, @IntValue7 int, @IntValue8 int, @IntValue9 int, @IntValue10 int, @IntValue11 int, @IntValue12 int, @IntValue13 int, @IntValue14 int, @IntValue15 int, @IntValue16 int, @IntValue17 int, @IntValue18 int, @IntValue19 int, @IntValue20 int, @IntValue21 int, @IntValue22 int, @IntValue23 int, @IntValue24 int, @IntValue25 int, @IntValue26 int, @IntValue27 int, @IntValue28 int, @IntValue29 int, @IntValue30 int, @IntValue31 int, @ListDataId int; DECLARE @curRank int, @curTime int, @PlayerTime int, @TotalTime int, @rowCount int, @UserId int, @absentRank int, @RankStr varchar(250), @Points int; -- START OF LOOP 1 -- First loop - create entry for every user in the temporary table and set the rank of the first DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue1 as PlayerTime, L.ordernum AS TotalTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue1 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime,@TotalTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; INSERT INTO tmp_List (ListId,UserId,IntValue1,total1,strvalue1) VALUES (@ListId,@UserId,@PlayerTime,@curRank,'_01' + STR(@curRank,5)) SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime,@TotalTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @rowCount + 1; -- END OF LOOP 1 -- NEW - DELETE RECORDS IF USER HAS MORE THAN ONE (8/2/04) DELETE FROM tmp_List WHERE UserId IN (SELECT UserId FROM tmp_List group by userid having count(UserId)>1) -- INTVALUE2 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue2 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue2 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_02' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE3 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue3 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue3 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_03' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE4 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue4 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue4 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_04' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE5 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue5 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue5 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_05' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE6 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue6 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue6 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_06' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE7 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue7 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue7 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_07' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE8 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue8 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue8 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_08' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE9 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue9 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue9 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_09' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE10 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue10 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue10 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_10' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE11 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue11 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue11 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_11' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE12 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue12 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue12 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_12' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE13 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue13 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue13 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_13' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE14 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue14 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue14 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_14' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE15 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue15 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue15 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_15' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; IF @ListId <> 492 -- (START) OF MORE-THAN-15 (Ladder 492/SNES has only 15 tracks) BEGIN -- INTVALUE16 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue16 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue16 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_16' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE17 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue17 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue17 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_17' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE18 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue18 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue18 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_18' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE19 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue19 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue19 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_19' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE20 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue20 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue20 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_20' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; IF @ListId <> 490 -- (START) OF MORE-THAN-20 (Ladder 490/BF has only 20 tracks) BEGIN -- INTVALUE21 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue21 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue21 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_21' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; IF @ListId <> 493 AND @ListId <> 489 -- (START) OF MORE-THAN-21 (Ladder 493/MV and 489/BF G/P/C has only 21 tracks) BEGIN -- INTVALUE22 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue22 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue22 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_22' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE23 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue23 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue23 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_23' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE24 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue24 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue24 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_24' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; IF @ListId <> 491 -- (START) OF MORE-THAN-24 (Ladder 491/X has only 24 tracks) BEGIN -- INTVALUE25 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue25 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue25 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_25' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; -- INTVALUE26 DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.intvalue26 as PlayerTime FROM t_list_data L WHERE L.listid = @ListId AND L.UserId NOT IN (120435,125584,120199) ORDER BY L.intvalue26 SET @curRank = 0; SET @curTime = 0; SET @rowCount = 0; OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN SET @rowCount = @rowCount + 1; IF @PlayerTime <> @curTime SET @curRank = @rowCount; UPDATE tmp_List SET total1=total1+@curRank, strvalue1=strvalue1+'_26' + STR(@curRank,5) WHERE UserId=@UserId SET @curTime = @PlayerTime; FETCH NEXT FROM List_Cursor INTO @UserId,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor SET @absentRank = @absentRank + @rowCount + 1; END -- (END) OF MORE-THAN-24 END -- (END) OF MORE-THAN-21 END -- (END) OF MORE-THAN-20 END -- (END) OF MORE-THAN-15 -- NOW, update the F-Zero Championship ladder with new totals for this game -- NOTE: every player must already exist in the champ ladder - ensured by p_fzero_champs DECLARE List_Cursor CURSOR FORWARD_ONLY FOR SELECT L.UserId, L.total1, L.strvalue1, L.intvalue1 FROM tmp_List L OPEN List_Cursor FETCH NEXT FROM List_Cursor INTO @UserId,@Points,@RankStr,@PlayerTime WHILE @@FETCH_STATUS = 0 BEGIN -- Update champs ladder IF @ListId = 489 -- BF Gold/Platinum/Champ Ladder UPDATE t_List_Data SET intvalue20=intvalue20+(@Points*3150/@absentRank),intvalue21=@Points,strvalue1=strvalue1 + '_489' + str(@PlayerTime) WHERE UserId=@UserId AND ListId=488 IF @ListId = 490 -- BF Bronze/Silver Ladder UPDATE t_List_Data SET intvalue17=intvalue17+(@Points*2850/@absentRank),intvalue18=@Points,strvalue1=strvalue1 + '_490' + str(@PlayerTime) WHERE UserId=@UserId AND ListId=488 IF @ListId = 491 -- X Ladder UPDATE t_List_Data SET intvalue7=intvalue7+(@Points*6000/@absentRank),intvalue8=@Points,strvalue1=strvalue1 + '_491' + str(@PlayerTime) WHERE UserId=@UserId AND ListId=488 IF @ListId = 492 -- SNES Ladder UPDATE t_List_Data SET intvalue11=intvalue11+(@Points*6000/@absentRank),intvalue12=@Points,strvalue1=strvalue1 + '_492' + str(@PlayerTime) WHERE UserId=@UserId AND ListId=488 IF @ListId = 493 -- MV Ladder UPDATE t_List_Data SET intvalue14=intvalue14+(@Points*6000/@absentRank),intvalue15=@Points,strvalue1=strvalue1 + '_493' + str(@PlayerTime) WHERE UserId=@UserId AND ListId=488 IF @ListId = 494 -- GX Open Ladder UPDATE t_List_Data SET intvalue1=intvalue1+(@Points*6000/@absentRank),intvalue2=@Points,strvalue1=strvalue1 + '_494' + str(@PlayerTime) WHERE UserId=@UserId AND ListId=488 IF @ListId = 499 -- GX Max Speed Ladder UPDATE t_List_Data SET intvalue4=intvalue4+(@Points*6000/@absentRank),intvalue5=@Points,strvalue1=strvalue1 + '_499' + str(@PlayerTime) WHERE UserId=@UserId AND ListId=488 -- Update ranking strings UPDATE t_List_Data SET strvalue1=@RankStr WHERE UserId=@UserId AND ListId=@ListId FETCH NEXT FROM List_Cursor INTO @UserId,@Points,@RankStr,@PlayerTime END CLOSE List_Cursor DEALLOCATE List_Cursor -- Update all non ladder participants with worst possible score for the ladder IF @ListId = 489 -- BF Gold/Platinum/Champ Ladder UPDATE t_List_Data SET intvalue20=intvalue20+3150,intvalue21=@absentRank WHERE ListId=488 AND intvalue21 IS NULL IF @ListId = 490 -- BF Bronze/Silver Ladder UPDATE t_List_Data SET intvalue17=intvalue17+2850,intvalue18=@absentRank WHERE ListId=488 AND intvalue18 IS NULL IF @ListId = 491 -- X Ladder UPDATE t_List_Data SET intvalue7=intvalue7+6000,intvalue8=@absentRank WHERE ListId=488 AND intvalue8 IS NULL IF @ListId = 492 -- SNES Ladder UPDATE t_List_Data SET intvalue11=intvalue11+6000,intvalue12=@absentRank WHERE ListId=488 AND intvalue12 IS NULL IF @ListId = 493 -- MV Ladder UPDATE t_List_Data SET intvalue14=intvalue14+6000,intvalue15=@absentRank WHERE ListId=488 AND intvalue15 IS NULL IF @ListId = 494 -- GX Open Ladder UPDATE t_List_Data SET intvalue1=intvalue1+6000,intvalue2=@absentRank WHERE ListId=488 AND intvalue2 IS NULL IF @ListId = 499 -- GX Max Speed Ladder UPDATE t_List_Data SET intvalue4=intvalue4+6000,intvalue5=@absentRank WHERE ListId=488 AND intvalue5 IS NULL -- Just dump to the screen for diagnostics --SELECT @absentRank as AbsentRank, @rowCount as NumPlayers END GO