Gamma, Armor Textures and Mouselook Patches for Lineage2

Greg Furstenwerth <[email protected]> Thu, 10 Jun 2004 17:58:54 -0700
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
I would like to submit the following patches for allowing Lineage2 to 
use mouselooking, gamma on objects to be normal and armor to render 
properly on characters.

Patches Created by
Hendrik Cannoodt "Gryphon" "Griffinzrule"
Greg Furstenwerth "SlicerDicer" "Slicer"


Index: dlls/d3dgl/texstate.c
===================================================================
RCS file: /cvsroot/winex/dlls/d3dgl/texstate.c,v
retrieving revision 1.11
diff -u -r1.11 texstate.c
--- dlls/d3dgl/texstate.c       17 Mar 2004 04:19:27 -0000      1.11
+++ dlls/d3dgl/texstate.c       11 Jun 2004 00:31:47 -0000
@@ -713,7 +713,27 @@
 static inline DWORD D3D_GL_color_op(GL_D3D_priv* priv, DWORD Stage, 
DWORD State)
 {
     DWORD cstate = _TSS(Stage,COLOROP);
+    /*this line is needed for the Lineage2
+    * armor problem. Without it some
+    * armors are rendered black*/
+    if (cstate == 18) {
+    cstate = 2;
+    _TSS(Stage,COLOROP) = 2;
+    }
+
     DWORD astate = _TSS(Stage,ALPHAOP);
+    /* this patch is for the Lineage2
+    * building gamma problem. Without
+    * it buildings and rocks are rendered
+    * practicly white */
+    if ((cstate == 5)) {
+    DWORD aar1 = _TSS(Stage,ALPHAARG1);
+    if (((astate == 4) && (aar1 == 2)) || ((astate == 2) && (aar1 == 
2)) || ((astate == 4) && (aar1 == 1))) {
+    cstate = 2;
+    _TSS(Stage,COLOROP) = cstate;
+    }
+
+}
     GL_TEXOP *cop = D3D_GL_get_tex_op(priv, cstate, NULL);
     GL_TEXOP *aop = D3D_GL_get_tex_op(priv, astate, cop);
     _CTSS(Stage,COLOROP);




Index: dlls/dinput/mouse/main.c
===================================================================
RCS file: /cvsroot/winex/dlls/dinput/mouse/main.c,v
retrieving revision 1.57
diff -u -r1.57 main.c
--- dlls/dinput/mouse/main.c    1 Jun 2004 22:13:10 -0000       1.57
+++ dlls/dinput/mouse/main.c    11 Jun 2004 00:47:08 -0000
@@ -105,6 +105,8 @@

 BOOL WINAPI DINPUT_ForceSetCursorPos(INT,INT);

+BOOL LineAge2_warp_problem; /* Warping should only be done while 
mouse_looking */
+
 typedef enum {
   WARP_NEEDED,  /* Warping is needed */
   WARP_STARTED, /* Warping has been done, waiting for the warp event */
@@ -458,6 +460,7 @@
           RECT window_rect;
           BOOL do_abs_calc = TRUE;
           BOOL changed = FALSE;
+         int change_pos_mouse;

           GetWindowRect(This->win, &window_rect);
           min_x = window_rect.left;
@@ -477,10 +480,10 @@
          }

          /* Now, warp handling */
-         if ((This->need_warp == WARP_STARTED) &&
-             (hook->pt.x == This->mapped_center.x) && (hook->pt.y == 
This->mapped_center.y)) {
+         /*if ((This->need_warp == WARP_STARTED) &&
+            (hook->pt.x == This->mapped_center.x) && (hook->pt.y == 
This->mapped_center.y)) {*/
            /* Warp has been done... */
-           This->abs_prev_point.x = hook->pt.x;
+         /*This->abs_prev_point.x = hook->pt.x;
            This->abs_prev_point.y = hook->pt.y;
            This->prevX = hook->pt.x;
            This->prevY = hook->pt.y;
@@ -489,19 +492,45 @@
            This->need_warp = WARP_DONE;
            suppress_warp = TRUE;
            goto end;
-         }
+
+         }*/
+
+        /* Warping away from screen edge when mouse_looking */
+        /* currently code is not compatible with absolute mouse (not 
verified) */
+        /* and not compatible with the MOUSE_HACK flag */
+        /* It seems that lineage seems to start with a warp and since 
the arrow */
+        /* is at the left position, it gets warped 100 to the right. 
Looks silly, I know */
+        /* The -100 +100 trick isn't the state of the art, but it works 
perfectly if your */
+        /* your horisontal screen resolution is higher then 400 pixels. */
+        /* if not, it's time to buy a new screen */
+        if ((This->need_warp == WARP_STARTED) && (LineAge2_warp_problem 
== TRUE)) {
+        LineAge2_warp_problem = FALSE;
+        change_pos_mouse = 0;
+        if (This->abs_pretend_point.x >= max_x-100)
+        change_pos_mouse = -100;
+        if (This->abs_pretend_point.x <= min_x+100)
+        change_pos_mouse = +100;
+        if (change_pos_mouse != 0) {
+        This->abs_pretend_point.x += change_pos_mouse;
+        hook->pt.x += change_pos_mouse;
+        This->abs_prev_point.x += change_pos_mouse;
+        This->prevX += change_pos_mouse;
+        DINPUT_ForceSetCursorPos(hook->pt.x, hook->pt.y );
+        }
+        This->need_warp = WARP_DONE;
+        }

          This->m_state.lX += hook->pt.x - This->prevX;
          This->m_state.lY += hook->pt.y - This->prevY;

 #ifdef MOUSE_HACK
-          if ((This->need_warp == WARP_DONE) &&
+         /* if ((This->need_warp == WARP_DONE) &&
               (hook->pt.x == This->mapped_center.x) && (hook->pt.y == 
This->mapped_center.y))
           {
             This->abs_prev_point.x = hook->pt.x;
             This->abs_prev_point.y = hook->pt.y;
             do_abs_calc = FALSE;
-          }
+          }*/
 #endif
          /* Relative mouse input with absolute mouse event : the real 
fun starts here... */
          if (hook->pt.x != This->prevX) {
@@ -676,8 +705,8 @@
   EnterCriticalSection(&This->crit);
   This->warp_time = current;
   TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, 
This->mapped_center.y);
-  DINPUT_ForceSetCursorPos( This->mapped_center.x, This->mapped_center.y );
-
+  //DINPUT_ForceSetCursorPos( This->mapped_center.x, 
This->mapped_center.y );
+  LineAge2_warp_problem = TRUE;
 #ifdef MOUSE_HACK
   This->abs_prev_point.x = This->mapped_center.x;
   This->abs_prev_point.y = This->mapped_center.y;