diff Render.cpp @ 168:ee11772d0ad2

New sky (turn on -new_sky console command) cube textures are stored in /daata/skybox/%name%_xn.tga %name%%_xp.tga %name%_zn.tga etc
author Nomad
date Thu, 14 Feb 2013 13:58:34 +0200
parents 8ab4484c22e0
children d1dde383af89
line wrap: on
line diff
--- a/Render.cpp	Tue Feb 12 11:59:49 2013 +0200
+++ b/Render.cpp	Thu Feb 14 13:58:34 2013 +0200
@@ -1825,7 +1825,7 @@
       for (unsigned int k = 0; k < 4; ++k)
       {
         memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
-        array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
+        array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
       }
 
       assert(v6 < 1000); // many random crashes here
@@ -2059,19 +2059,19 @@
             //goto LABEL_162;
           //}
           memcpy(&array_50AC10[0], v102, 0x30u);
-          array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
+          array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
           array_50AC10[0].u = 0.0;
           array_50AC10[0].v = 0.0;
           memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1]));
-          array_50AC10[1].flt_20 = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097);
+          array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097);
           array_50AC10[1].u = 0.0;
           array_50AC10[1].v = 1.0;
           memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2]));
-          array_50AC10[2].flt_20 = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097);
+          array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097);
           array_50AC10[2].u = 1.0;
           array_50AC10[2].v = 1.0;
           memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3]));
-          array_50AC10[3].flt_20 = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097);
+          array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097);
           array_50AC10[3].u = 1.0;
           array_50AC10[3].v = 0.0;
           /*if ( !(byte_76D5C0 & 1) )
@@ -2199,15 +2199,15 @@
           goto LABEL_112;
         }*/
       memcpy(&array_50AC10[0], v102, 0x30u);
-      array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
+      array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
       array_50AC10[0].u = 0.0;
       array_50AC10[0].v = 0.0;
       memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1]));
-      array_50AC10[1].flt_20 = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097;
+      array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097;
       array_50AC10[1].u = 0.0;
       array_50AC10[1].v = 1.0;
       memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2]));
-      array_50AC10[2].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097;
+      array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097;
       array_50AC10[2].u = 1.0;
       array_50AC10[2].v = 1.0;
       static stru154 static_sub_0048034E_stru_76D590;
@@ -2328,15 +2328,15 @@
         goto LABEL_162;
       }
       memcpy(&array_50AC10[0], v102, 0x30u);
-      array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
+      array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
       array_50AC10[0].u = 0.0;
       array_50AC10[0].v = 0.0;
       memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1]));
-      array_50AC10[1].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097;
+      array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097;
       array_50AC10[1].u = 1.0;
       array_50AC10[1].v = 1.0;
       memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2]));
-      array_50AC10[2].flt_20 = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097;
+      array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097;
       array_50AC10[2].u = 1.0;
       array_50AC10[2].v = 0.0;
       static stru154 static_sub_0048034E_stru_76D578;
@@ -2640,22 +2640,22 @@
           goto LABEL_104;
         v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001);
         memcpy(array_50AC10, v104, 0x30u);
-        array_50AC10[0].flt_20 = v26;
+        array_50AC10[0]._rhw = v26;
         array_50AC10[0].u = 0.0;
         array_50AC10[0].v = 0.0;
         v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001;
         memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1]));
-        array_50AC10[1].flt_20 = 1.0 / v27;
+        array_50AC10[1]._rhw = 1.0 / v27;
         array_50AC10[1].u = 0.0;
         array_50AC10[1].v = 1.0;
         v28 = v103->vWorldViewPosition.x + 0.0000001;
         memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2]));
-        array_50AC10[2].flt_20 = 1.0 / v28;
+        array_50AC10[2]._rhw = 1.0 / v28;
         array_50AC10[2].u = 1.0;
         array_50AC10[2].v = 1.0;
         v29 = v102->vWorldViewPosition.x + 0.0000001;
         memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3]));
-        array_50AC10[3].flt_20 = 1.0 / v29;
+        array_50AC10[3]._rhw = 1.0 / v29;
         array_50AC10[3].u = 1.0;
         array_50AC10[3].v = 0.0;
         pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1);
@@ -2761,17 +2761,17 @@
       goto LABEL_74;
     v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001);
     memcpy(array_50AC10, v104, 0x30u);
-    array_50AC10[0].flt_20 = v48;
+    array_50AC10[0]._rhw = v48;
     array_50AC10[0].u = 0.0;
     array_50AC10[0].v = 0.0;
     v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001;
     memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1]));
-    array_50AC10[1].flt_20 = 1.0 / v49;
+    array_50AC10[1]._rhw = 1.0 / v49;
     array_50AC10[1].u = 0.0;
     array_50AC10[1].v = 1.0;
     v50 = v103->vWorldViewPosition.x + 0.0000001;
     memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2]));
-    array_50AC10[2].flt_20 = 1.0 / v50;
+    array_50AC10[2]._rhw = 1.0 / v50;
     array_50AC10[2].u = 1.0;
     array_50AC10[2].v = 1.0;
     pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0);
@@ -2855,17 +2855,17 @@
           }
           v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001);
           memcpy(array_50AC10, v104, 0x30u);
-          array_50AC10[0].flt_20 = v62;
+          array_50AC10[0]._rhw = v62;
           array_50AC10[0].u = 0.0;
           array_50AC10[0].v = 0.0;
           v63 = v103->vWorldViewPosition.x + 0.0000001;
           memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1]));
-          array_50AC10[1].flt_20 = 1.0 / v63;
+          array_50AC10[1]._rhw = 1.0 / v63;
           array_50AC10[1].u = 1.0;
           array_50AC10[1].v = 1.0;
           v64 = v102->vWorldViewPosition.x + 0.0000001;
           memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2]));
-          array_50AC10[2].flt_20 = 1.0 / v64;
+          array_50AC10[2]._rhw = 1.0 / v64;
           array_50AC10[2].u = 1.0;
           array_50AC10[2].v = 0.0;
           pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1);
@@ -4831,7 +4831,7 @@
       {
         memset(&Dst, 0, 0x7Cu);
         Dst.dwSize = 124;
-        if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, 1u) )
+        if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
           return;
         v28 = Dst.lpSurface;
         v5 = Dst.lPitch >> 1;
@@ -5027,7 +5027,7 @@
       {
         memset(&Dst, 0, 0x7Cu);
         Dst = 124;
-        if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, 1u) )
+        if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) )
           return;
         v42 = v20;
         v6 = v19 >> 1;
@@ -6136,7 +6136,7 @@
   {
     memset(&pDesc, 0, 0x7Cu);
     pDesc.dwSize = 124;
-    if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, 1u) )
+    if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) )
     {
       pRenderer->pBackBuffer4->Unlock(0);
       v19 = ptr_400E8;
@@ -6469,7 +6469,7 @@
 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags)
 {
   IDirectDrawSurface4 *v4; // esi@1
-  bool result; // eax@1
+  HRESULT result; // eax@1
   HRESULT v6; // eax@4
   int v7; // [sp-8h] [bp-14h]@10
   unsigned int v8; // [sp-4h] [bp-10h]@10
@@ -6839,7 +6839,7 @@
   DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3
     memset(&pDesc, 0, 0x7Cu);
     pDesc.dwSize = 124;
-    LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, 1u);
+    LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT);
     *pOutSurfacePtr = pDesc.lpSurface;
     v4 = pDesc.lPitch;
   }
@@ -6884,7 +6884,7 @@
   DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3
     memset(&pDesc, 0, 0x7Cu);
     pDesc.dwSize = 124;
-    LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, 1u);
+    LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT);
     *pOutSurface = pDesc.lpSurface;
     v4 = pDesc.lPitch;
   }
@@ -7617,7 +7617,7 @@
    pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX;
    pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY;
    pVertices[i].pos.z = 0.99989998;
-   pVertices[i].rhw = array_50AC10[i].flt_20;
+   pVertices[i].rhw = array_50AC10[i]._rhw;
 
    pVertices[i].diffuse = GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0);
    v7 = 0;
@@ -7659,7 +7659,7 @@
       pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX;
       pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY;
       pVertices[i].pos.z = 0.99989998;
-      pVertices[i].rhw = array_50AC10[i].flt_20;
+      pVertices[i].rhw = array_50AC10[i]._rhw;
 
       pVertices[i].diffuse = GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0);
       v7 = 0;
@@ -8831,7 +8831,7 @@
         memset(&desc, 0, sizeof(DDSURFACEDESC2));
         desc.dwSize = sizeof(DDSURFACEDESC2);
 
-        if ( LockSurface_DDraw4(pNextSurf, &desc, 0x21u) )
+        if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
         {
           Dst.sub_451007_scale_image_bicubic(
             pHWLTexture->pPixels,
@@ -8865,7 +8865,7 @@
         memset(&desc, 0, sizeof(DDSURFACEDESC2));
         desc.dwSize = sizeof(DDSURFACEDESC2);
 
-      if ( LockSurface_DDraw4(*pOutSurface, &desc, 0x21u) )
+      if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
       {
         bMipMaps = 0;
         v13 = pHWLTexture->pPixels;
@@ -8941,7 +8941,7 @@
     //v8 = pSprite;
     memset(&Dst, 0, 0x7Cu);
     Dst.dwSize = 124;
-    if ( LockSurface_DDraw4((IDirectDrawSurface4 *)v2->pTextureSurface, &Dst, 0x21u) )
+    if ( LockSurface_DDraw4((IDirectDrawSurface4 *)v2->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
     {
       v9 = v5->pPixels;
       v10 = Dst.lpSurface;
@@ -8999,7 +8999,7 @@
       {
         memset(&Dst, 0, 0x7Cu);
         Dst.dwSize = 124;
-        if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x801u) )
+        if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) )
         {
           v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface;
           v3 = Dst.lPitch >> 1;