wined3d: Enabling too many lights is silently ignored.

I'm resending this patch because my reply to Henri's concern came too late. 
Henri noted that I am enabling lights that do not exist. Existing tests show 
that if no light is assigned to the index, LightEnable creates a light with a 
set of default parameters, so the tests should be fine.

From 9ee4c61805b50886f79e87d744b52f27b7b00b4e Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan@codeweavers.com>
Date: Thu, 29 Nov 2007 13:22:47 +0100
Subject: [PATCH] WineD3D: Enabling too many lights is silently ignored

This patch adds tests for all d3d versions that show that Windows
pretends that enabling more lights than supported succeeds. D3D_OK is
returned, and the light is reported as enabled.

What is not tested in this patch is the rendering output of this
situation, thus the FIXME is still written.
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 6d9e7bb..9ae5bf0 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2845,7 +2845,9 @@
         } else {
             TRACE("Light already disabled, nothing to do\n");
         }
+        lightInfo->enabled = FALSE;
     } else {
+        lightInfo->enabled = TRUE;
         if (lightInfo->glIndex != -1) {
             /* nop */
             TRACE("Nothing to do as light was enabled\n");
@@ -2860,8 +2862,15 @@
                 }
             }
             if(lightInfo->glIndex == -1) {
-                ERR("Too many concurrently active lights\n");
-                return WINED3DERR_INVALIDCALL;
+                /* Our tests show that Windows returns D3D_OK in this situation, even with
+                 * D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE devices. This
+                 * is consistent among ddraw, d3d8 and d3d9. GetLightEnable returns TRUE
+                 * as well for those lights.
+                 *
+                 * TODO: Test how this affects rendering
+                 */
+                FIXME("Too many concurrently active lights\n");
+                return WINED3D_OK;
             }
 
             /* i == lightInfo->glIndex */
@@ -2893,7 +2902,7 @@
         return WINED3DERR_INVALIDCALL;
     }
     /* true is 128 according to SetLightEnable */
-    *pEnable = lightInfo->glIndex != -1 ? 128 : 0;
+    *pEnable = lightInfo->enabled ? 128 : 0;
     return WINED3D_OK;
 }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a06083d..3b87fa0 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -549,6 +549,7 @@
     LONG         glIndex;
     BOOL         changed;
     BOOL         enabledChanged;
+    BOOL         enabled;
 
     /* Converted parms to speed up swapping lights */
     float                         lightPosn[4];