changeset 682:ee978b573798

Слияние
author Ritor1
date Wed, 13 Mar 2013 18:54:30 +0600
parents b54755fa0dbc (current diff) a5750c94b022 (diff)
children d4497b76a863
files Indoor.cpp UIHouses.cpp
diffstat 13 files changed, 344 insertions(+), 349 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/Indoor.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -129,7 +129,7 @@
     }
     v6 = i + 1;
   }
-  MessWithBillboards_BLV();
+  FindBillboardsLightLevels_BLV();
   pGame->PrepareBloodsplats();
 }
 
@@ -275,15 +275,15 @@
     for (uint i = 0; i < pBspRenderer->uNumFaceIDs; ++i)
     {
       v2 = pBspRenderer->pFaceIDs[2 * i + 1];
-      if ( pBspRenderer->field_FA8[v2].std__vector_0007A8 == -1 )
+      if ( pBspRenderer->pSectors[v2].std__vector_0007A8 == -1 )
       {
         v6 = 0;
         v3 = 0;
       }
       else
       {
-        v3 = pBspRenderer->field_FA8[v2].std__vector_0007AC;
-        v6 = pBspRenderer->field_FA8[v2].pVertices;
+        v3 = pBspRenderer->pSectors[v2].std__vector_0007AC;
+        v6 = pBspRenderer->pSectors[v2].pVertices;
       }
       IndoorLocation::ExecDraw_d3d(pBspRenderer->pFaceIDs[2 * i], v3, 4, v6);
     }
@@ -293,7 +293,7 @@
     for (uint j = 0; j < pBspRenderer->uNumFaceIDs; ++j )
     {
       v5 = pBspRenderer->pFaceIDs[2 * j];
-      pBLVRenderParams->field_7C = &pBspRenderer->field_FA8[pBspRenderer->pFaceIDs[2 * j + 1]].field_C;
+      pBLVRenderParams->field_7C = &pBspRenderer->pSectors[pBspRenderer->pFaceIDs[2 * j + 1]].field_C;
       IndoorLocation::ExecDraw_sw(v5);
     }
   }
@@ -322,17 +322,17 @@
     {
       v1 = pBLVRenderParams->pRenderTarget;
       v6 = 0;
-      if ( (signed int)pBspRenderer->std__vector_000FA8 > 0 )
+      if ( (signed int)pBspRenderer->pNumSectors > 0 )
       {
         v7 = 0;
-        v2 = (char *)&pBspRenderer->field_FA8[0].field_C._viewport_space_w;
+        v2 = (char *)&pBspRenderer->pSectors[0].field_C._viewport_space_w;
         do
         {
           v3 = *((int *)v2 - 1);
           v4 = pRenderer->uTargetSurfacePitch * *((int *)v2 - 1);
           if ( v3 <= *(int *)v2 )
           {
-            v5 = (char *)&pBspRenderer->field_FA8[0].field_C.array_3D8[v3 + v7];
+            v5 = (char *)&pBspRenderer->pSectors[0].field_C.array_3D8[v3 + v7];
             do
             {
               v1[v4 + *((short *)v5 - 480)] = 255;
@@ -347,7 +347,7 @@
           v7 += 1126;
           v2 += 2252;
         }
-        while ( v6 < (signed int)pBspRenderer->std__vector_000FA8 );
+        while ( v6 < (signed int)pBspRenderer->pNumSectors );
       }
     }
   }
@@ -1276,14 +1276,14 @@
   //v3 = uFaceID;
   //v4 = this;
   //v5 = &pIndoor->pFaces[uFaceID];
-  field_FA8[std__vector_000FA8].std__vector_0007A8 = -1;
+  pSectors[pNumSectors].std__vector_0007A8 = -1;
   //v39 = &pIndoor->pFaces[uFaceID];
 
   auto pFace = &pIndoor->pFaces[uFaceID];
 
   if (pFace->TwoSided())
   {
-    auto p = &field_FA8[a2];
+    auto p = &pSectors[a2];
     //v6 = (int)((char *)this + 2252 * a2);
     //a0 = v6;
     if (p->uFaceID == uFaceID)
@@ -1301,20 +1301,20 @@
                                        + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 )
       {
         v7 = pFace->uSectorID;
-        if ( field_FA8[0].uSectorID == v7 )
+        if ( pSectors[0].uSectorID == v7 )
           v7 = pFace->uBackSectorID;
-        field_FA8[std__vector_000FA8].uSectorID = v7;
-        field_FA8[std__vector_000FA8].uFaceID = uFaceID;
-        field_FA8[std__vector_000FA8].uViewportX = pBLVRenderParams->uViewportX;
-        field_FA8[std__vector_000FA8].uViewportZ = pBLVRenderParams->uViewportZ;
-        field_FA8[std__vector_000FA8].uViewportY = pBLVRenderParams->uViewportY;
-        field_FA8[std__vector_000FA8].uViewportW = pBLVRenderParams->uViewportW;
-        field_FA8[std__vector_000FA8++].field_C._43F9E1(
+        pSectors[pNumSectors].uSectorID = v7;
+        pSectors[pNumSectors].uFaceID = uFaceID;
+        pSectors[pNumSectors].uViewportX = pBLVRenderParams->uViewportX;
+        pSectors[pNumSectors].uViewportZ = pBLVRenderParams->uViewportZ;
+        pSectors[pNumSectors].uViewportY = pBLVRenderParams->uViewportY;
+        pSectors[pNumSectors].uViewportW = pBLVRenderParams->uViewportW;
+        pSectors[pNumSectors++].field_C._43F9E1(
           pBLVRenderParams->uViewportX,
           pBLVRenderParams->uViewportY,
           pBLVRenderParams->uViewportZ,
           pBLVRenderParams->uViewportW);
-        sub_440639(std__vector_000FA8 - 1);
+        sub_440639(pNumSectors - 1);
         return;
       }
       //v5 = v39;
@@ -1361,26 +1361,24 @@
             a2 <= p->uViewportZ &&
             v12 >= p->uViewportY &&
             v37 <= p->uViewportW &&
-            sub_424829(v10, &field_FA8[std__vector_000FA8].field_C, &p->field_C, uFaceID))
+            sub_424829(v10, &pSectors[pNumSectors].field_C, &p->field_C, uFaceID))
         {
           //v17 = v39;
           v18 = pFace->uSectorID;
           if (p->uSectorID == v18 )
             v18 = pFace->uBackSectorID;
-          field_FA8[std__vector_000FA8].uSectorID = v18;
-          field_FA8[std__vector_000FA8].uFaceID = uFaceID;
-          field_FA8[std__vector_000FA8].uViewportX = pBLVRenderParams->uViewportX;
-          field_FA8[std__vector_000FA8].uViewportZ = pBLVRenderParams->uViewportZ;
-          field_FA8[std__vector_000FA8].uViewportY = pBLVRenderParams->uViewportY;
-          field_FA8[std__vector_000FA8].uViewportW = pBLVRenderParams->uViewportW;
+          pSectors[pNumSectors].uSectorID = v18;
+          pSectors[pNumSectors].uFaceID = uFaceID;
+          pSectors[pNumSectors].uViewportX = pBLVRenderParams->uViewportX;
+          pSectors[pNumSectors].uViewportZ = pBLVRenderParams->uViewportZ;
+          pSectors[pNumSectors].uViewportY = pBLVRenderParams->uViewportY;
+          pSectors[pNumSectors].uViewportW = pBLVRenderParams->uViewportW;
           //v38 = pGame->pStru10Instance;
           //a0a = pGame->pIndoorCameraD3D;
           if (p->std__vector_0007A8 == -1 )
           {
-            v29 = pGame->pStru10Instance->_49C681_DrawDebugStuff(
-                    pFace,
-                    field_FA8[std__vector_000FA8].std__vector_0007AC,
-                    field_FA8[std__vector_000FA8].pVertices);
+            v29 = pGame->pStru10Instance->_49C681_DrawDebugStuff(pFace, pSectors[pNumSectors].std__vector_0007AC,
+                    pSectors[pNumSectors].pVertices);
           }
           else
           {
@@ -1415,21 +1413,18 @@
               4,
               0,
               0);
-            v29 = pGame->pStru10Instance->_49C5DA(
-                    pFace,
-                    static_subAddFaceToRenderList_d3d_stru_F79E08,
-                    &a2,
-                    field_FA8[std__vector_000FA8].std__vector_0007AC,
-                    field_FA8[std__vector_000FA8].pVertices);
+            v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &a2,
+                    pSectors[pNumSectors].std__vector_0007AC,
+                    pSectors[pNumSectors].pVertices);
           }
           if ( v29 )
           {
-            field_FA8[std__vector_000FA8].std__vector_0007A8 = uFaceID;
-            v30 = std__vector_000FA8;
+            pSectors[pNumSectors].std__vector_0007A8 = uFaceID;
+            v30 = pNumSectors;
             if ( v30 < 150 )
             {
               v31 = v30 + 1;
-              std__vector_000FA8 = v31;
+              pNumSectors = v31;
               sub_440639(v31 - 1);
             }
           }
@@ -1496,20 +1491,20 @@
                                        + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 )
       {
         v6 = v21->uSectorID;
-        if ( v3->field_FA8[0].uSectorID == v6 )
+        if ( v3->pSectors[0].uSectorID == v6 )
           v6 = v21->uBackSectorID;
-        v3->field_FA8[v3->std__vector_000FA8].uSectorID = v6;
-        v3->field_FA8[v3->std__vector_000FA8].uFaceID = uFaceID;
-        v3->field_FA8[v3->std__vector_000FA8].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
-        v3->field_FA8[v3->std__vector_000FA8].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-        v3->field_FA8[v3->std__vector_000FA8].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-        v3->field_FA8[v3->std__vector_000FA8].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-        v3->field_FA8[v3->std__vector_000FA8++].field_C._43F9E1(
+        v3->pSectors[v3->pNumSectors].uSectorID = v6;
+        v3->pSectors[v3->pNumSectors].uFaceID = uFaceID;
+        v3->pSectors[v3->pNumSectors].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
+        v3->pSectors[v3->pNumSectors].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
+        v3->pSectors[v3->pNumSectors].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
+        v3->pSectors[v3->pNumSectors].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
+        v3->pSectors[v3->pNumSectors++].field_C._43F9E1(
           SLOWORD(pBLVRenderParams->uViewportX),
           pBLVRenderParams->uViewportY,
           SLOWORD(pBLVRenderParams->uViewportZ),
           pBLVRenderParams->uViewportW);
-        v7 = v3->std__vector_000FA8 - 1;
+        v7 = v3->pNumSectors - 1;
         goto LABEL_14;
       }
       v4 = v21;
@@ -1555,22 +1550,22 @@
           && v23 <= *((short *)v20 + 2007)
           && v12 >= *((short *)v20 + 2006)
           && v22 <= *((short *)v20 + 2008)
-          && sub_424829(v10, &v3->field_FA8[v3->std__vector_000FA8].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) )
+          && sub_424829(v10, &v3->pSectors[v3->pNumSectors].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) )
         {
           v16 = v21->uSectorID;
           if ( *((short *)v20 + 2004) == v16 )
             v16 = v21->uBackSectorID;
-          v3->field_FA8[v3->std__vector_000FA8].uSectorID = v16;
-          v3->field_FA8[v3->std__vector_000FA8].uFaceID = uFaceID;
-          v3->field_FA8[v3->std__vector_000FA8].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
-          v3->field_FA8[v3->std__vector_000FA8].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-          v3->field_FA8[v3->std__vector_000FA8].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-          v3->field_FA8[v3->std__vector_000FA8].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-          v17 = v3->std__vector_000FA8;
+          v3->pSectors[v3->pNumSectors].uSectorID = v16;
+          v3->pSectors[v3->pNumSectors].uFaceID = uFaceID;
+          v3->pSectors[v3->pNumSectors].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
+          v3->pSectors[v3->pNumSectors].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
+          v3->pSectors[v3->pNumSectors].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
+          v3->pSectors[v3->pNumSectors].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
+          v17 = v3->pNumSectors;
           if ( v17 < 150 )
           {
             v18 = v17 + 1;
-            v3->std__vector_000FA8 = v18;
+            v3->pNumSectors = v18;
             v7 = v18 - 1;
 LABEL_14:
             sub_440639(v7);
@@ -1610,7 +1605,7 @@
       if ( v1 < (signed int)pIndoor->uNumFaces )
       {
         v2 = pBspRenderer->pFaceIDs[2 * i];
-        pBLVRenderParams->field_7C = &pBspRenderer->field_FA8[pBspRenderer->pFaceIDs[2 * i + 1]].field_C;
+        pBLVRenderParams->field_7C = &pBspRenderer->pSectors[pBspRenderer->pFaceIDs[2 * i + 1]].field_C;
         v3 = sub_423B5D(v2);
         if ( v3 )
         {
@@ -3337,7 +3332,7 @@
         v51 = v40->zCalc2;
         v56 = (unsigned __int64)(v51 * (signed __int64)(sY << 16)) >> 16;
         v42 = (v56 + v40->zCalc3 + v57 + 32768) >> 16;
-        goto LABEL_46;
+        v39 = sZ - v42;
       }
 LABEL_47:
       if ( v39 >= 0 )
@@ -3353,7 +3348,6 @@
         return v38;
     }
     v42 = this->pVertices[*v40->pVertexIDs].z;
-LABEL_46:
     v39 = sZ - v42;
     goto LABEL_47;
   }
--- a/Indoor_stuff.h	Wed Mar 13 18:54:19 2013 +0600
+++ b/Indoor_stuff.h	Wed Mar 13 18:54:30 2013 +0600
@@ -75,7 +75,7 @@
    //    (void (__thiscall *)(void *))stru170_stru0::stru170_stru0,
    //    (void (__thiscall *)(void *))stru170_stru0::dtor);
     uNumFaceIDs = 0;
-    std__vector_000FA8 = 0;
+    pNumSectors = 0;
     uNumVisibleNotEmptySectors = 0;
   }
 
@@ -85,10 +85,10 @@
   void DrawFaceOutlines();
 
   unsigned int uNumFaceIDs;
-  __int16 pFaceIDs[150];
-  char field_130[3700];
-  unsigned int std__vector_000FA8;
-  BspRenderer_stru0 field_FA8[150];
+  __int16 pFaceIDs[2000];
+  //char field_130[3700];
+  unsigned int pNumSectors;
+  BspRenderer_stru0 pSectors[150];
   unsigned int uNumVisibleNotEmptySectors;
   unsigned __int16 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[6];
 };
--- a/NPC.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/NPC.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -676,6 +676,12 @@
 		pNPCDataBuff->Location2D = uLocation2D;
 		pNPCDataBuff->field_24 = 1;
 		pNPCDataBuff->joins = 1;
+		pNPCDataBuff->evt_A = 0;
+		pNPCDataBuff->evt_B = 0;
+		pNPCDataBuff->evt_C = 0;
+		pNPCDataBuff->evt_D = 0;
+		pNPCDataBuff->evt_E = 0;
+		pNPCDataBuff->evt_F = 0;
 	}
 
 //----- (00476387) --------------------------------------------------------
--- a/Outdoor.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/Outdoor.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -3151,7 +3151,7 @@
         v28->world_z = z;
         HIWORD(v34) = HIWORD(X);
         LOWORD(v34) = 0;
-        v28->uPaletteSubindex = 0;
+        v28->dimming_level = 0;
         v28->sZValue = v34 + (8 * i | OBJECT_Actor);
         v28->field_14_actor_id = i;
         v35 = pMonsterList->pMonsters;
@@ -3159,7 +3159,7 @@
         v28->field_1E = v62 | 0x200;
         v28->pSpriteFrame = v15;
         v28->uTintColor = *((int *)&v35[v36] - 36);
-        if (actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
+        if (actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime)
           v28->field_1E = v62 | 0x200;
       }
 //LABEL_58:
--- a/Party.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/Party.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -757,7 +757,7 @@
 
   memcpy(pNPCStats->pNewNPCData, pNPCStats->pNPCData, 0x94BCu);
   memcpy(pNPCStats->pGroups_copy, pNPCStats->pGroups, 0x66u);
-  pNPCStats->pNewNPCData[3].uFlags = 128;//|= 0x80u; Lady Margaret
+  pNPCStats->pNewNPCData[3].uFlags |= 128;//|= 0x80u; Lady Margaret
   _494035_timed_effects__water_walking_damage__etc();
   pEventTimer->Pause();
   return 0;
@@ -974,7 +974,7 @@
       memset(hireling, 0, sizeof(*hireling));
 
       pParty->field_709 = 0;
-      sub_44A56A();
+      Party__CountHirelings();
       viewparams->bRedrawGameUI = 1;
     }
   }
--- a/Player.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/Player.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -3391,7 +3391,7 @@
     return 1;
   }
   if ( HasItemEquipped((ITEM_EQUIP_TYPE)a2)
-    && *(int *)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(&v4->pEquipment.uOffHand + v3) + 5] == a1 )
+    && *(int *)&this->pInventoryItems[*(&v4->pEquipment.uOffHand + v3)-1] == a1 )
     return 1;
   return 0;
 }
@@ -4010,7 +4010,7 @@
             goto LABEL_84;
         }
         v28 = v47;
-        memcpy(v27, &v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v5->pInventoryIndices[v47] + 5], 0x24u);
+        memcpy(v27, &v5->pInventoryItems[v5->pInventoryIndices[v47]-1], 0x24u);
         RemoveItemAtInventoryIndex(v28);
 LABEL_79:
         v42 = 0;
@@ -7922,7 +7922,7 @@
         return v4 >= pValue;
     }
     while ( !v3->HasItemEquipped(v26)
-         || *(int *)&v3->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v27 + 5] != pValue )
+         || *(int *)&v3->pInventoryItems[*(int *)v27-1] != pValue )
     {
       v26 = (ITEM_EQUIP_TYPE)((int)v26 + 1);
       v27 += 4;
@@ -8304,7 +8304,7 @@
             case VAR_NPCs2:
               pParty->field_709 = 0;
               LOBYTE(pNPCStats->pNewNPCData[var_value].uFlags) |= 0x80u;
-              sub_44A56A();
+              Party__CountHirelings();
               viewparams->bRedrawGameUI = 1;
               break;
             case VAR_NumSkillPoints:
@@ -9261,7 +9261,7 @@
           case VAR_NPCs2:
             pParty->field_709 = 0;
             LOBYTE(pNPCStats->pNewNPCData[val].uFlags) |= 0x80u;
-            sub_44A56A();
+            Party__CountHirelings();
             viewparams->bRedrawGameUI = 1;
             break;
           case VAR_NumSkillPoints:
@@ -9377,7 +9377,7 @@
               {
                 pParty->field_709 = 0;
                 LOBYTE(pNPCStats->pNewNPCData[(int)pValue].uFlags) &= 0x7Fu;
-                sub_44A56A();
+                Party__CountHirelings();
                 viewparams->bRedrawGameUI = 1;
               }
               break;
@@ -9404,7 +9404,7 @@
               if ( pParty->pHirelings[1].uProfession == pValue )
                 memset(&pParty->pHirelings[1], 0, 0x4Cu);
               pParty->field_709 = 0;
-              sub_44A56A();
+              Party__CountHirelings();
               break;
             case 243:
               v17 = (char *)&this->uSkillPoints;
--- a/Render.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/Render.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -208,10 +208,10 @@
       if ( v2 != -1 )
       {
         if ( pRenderer->pRenderD3D )
-          pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->uPaletteSubindex);
+          pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->dimming_level);
         else
         {
-          soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->uPaletteSubindex, 1);
+          soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->dimming_level, 1);
           if (p->field_1E & 0x0100)
             soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette];
           if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 )
@@ -3027,7 +3027,7 @@
       if (pRenderer->pRenderD3D)
         pRenderer->TransformBillboard(&billboard,
                                       &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID],
-                                      pBillboard->uPaletteSubindex, pBillboard);
+                                      pBillboard->dimming_level, pBillboard);
       else
       {
           assert(false);
@@ -3239,7 +3239,7 @@
                   LOWORD(v26) = 0;
                   v27 = (object->uAttributes & 0x20) == 0;
                   v3->sZValue = v26 + (8 * i | OBJECT_Item);
-                  v3->uPaletteSubindex = 0;
+                  v3->dimming_level = 0;
                   v3->uTintColor = 0;
                   if ( !v27 )
                   {
@@ -3747,7 +3747,7 @@
                     LOWORD(v30) = 0;
                     v27->uIndoorSectorID = 0;
                     v27->sZValue = v30 + v31;
-                    v27->uPaletteSubindex = 0;
+                    v27->dimming_level = 0;
                     v27->pSpriteFrame = v8;
                     v27->uTintColor = 0;
                   }
@@ -8075,7 +8075,7 @@
 
 
 //----- (004A43B1) --------------------------------------------------------
-void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int uPaletteSubindex)
+void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int dimming_level)
 {
   RenderBillboardTransform_local0 *v4; // ebx@2
   double v5; // st7@2
@@ -8116,10 +8116,10 @@
     pSoftBillboarda = v5;
     v6 = v5;
     v7 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v6));
-    v8 = uPaletteSubindex;
+    v8 = dimming_level;
     v9 = v7;
-    v28 = uPaletteSubindex & 0xFF000000;
-    if ( uPaletteSubindex & 0xFF000000 )
+    v28 = dimming_level & 0xFF000000;
+    if ( dimming_level & 0xFF000000 )
       pBillboardRenderListD3D[v9].uOpacity = RenderBillboardD3D::Opaque_3;
     else
       pBillboardRenderListD3D[v9].uOpacity = RenderBillboardD3D::Transparent;
@@ -8137,14 +8137,14 @@
       v31 = v31 * -1.0;
     if ( v4->uTintColor && v26->bTinting )
     {
-      v11 = ::GetActorTintColor(v8, 0, pSoftBillboarda, 0, 0);
+      v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboarda, 0, 0);
       v12 = sub_4A19D8(v4->uTintColor, v11);
       if ( v28 )
         v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1);
     }
     else
     {
-      v12 = ::GetActorTintColor(v8, 0, pSoftBillboarda, 0, 0);
+      v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboarda, 0, 0);
     }
     v13 = (double)v25;
     pBillboardRenderListD3D[v9].pQuards[0].specular = 0;
@@ -8554,7 +8554,7 @@
 
 
 //----- (004A4023) --------------------------------------------------------
-void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int paletteSubindex, RenderBillboard *pBillboard)
+void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard)
 {
   unsigned int v8; // esi@2
   double v14; // st6@14
@@ -8581,7 +8581,7 @@
   v30 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_x_scaler_packedfloat);
   v29 = (a2->_screenspace_y_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_y_scaler_packedfloat);
 
-  unsigned int diffuse = ::GetActorTintColor(paletteSubindex, 0, a2->zbuffer_depth, 0, pBillboard);
+  unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard);
   if (a2->uTintColor & 0x00FFFFFF && bTinting)
   {
     diffuse = sub_4A19D8(a2->uTintColor, diffuse);
--- a/Render.h	Wed Mar 13 18:54:19 2013 +0600
+++ b/Render.h	Wed Mar 13 18:54:30 2013 +0600
@@ -75,7 +75,7 @@
   __int16 world_z;
   __int16 uScreenSpaceX;
   __int16 uScreenSpaceY;
-  unsigned __int16 uPaletteSubindex;
+  unsigned __int16 dimming_level;
   unsigned int uTintColor;
   SpriteFrame *pSpriteFrame;
 
@@ -328,8 +328,8 @@
   void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8);
   void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
   void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
-  void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int paletteSubindex, RenderBillboard *pBillboard);
-  void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int uPaletteSubindex);
+  void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard);
+  void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int dimming_level);
   int MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6);
   void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9);
   void _4A4CC9(struct stru6_stru1_indoor_sw_billboard *a1, int a2);
--- a/UIHouses.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/UIHouses.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -1014,17 +1014,17 @@
   *(float *)&v83 = v2;
   *(float *)&v89 = v2 * v2;
   v3 = (signed __int64)(*(float *)&v89 * 0.1);
-  v4 = v3 * (100 - pPlayer->GetMerchant()) / 100;
-  if ( v4 < v3 / 3 )
-    v4 = v3 / 3;
+  pItemNum = v3 * (100 - pPlayer->GetMerchant()) / 100;
+  if ( pItemNum < v3 / 3 )
+    pItemNum = v3 / 3;
   v5 = 1;
-  pOutString = (GUIFont *)v4;
-  if ( v4 <= 0 )
+  pOutString = (GUIFont *)pItemNum;
+  if ( pItemNum <= 0 )
     pOutString = (GUIFont *)1;
   v6 = (signed __int64)(*(float *)&v89 * *(float *)&v83 * 0.0099999998);
   v7 = v6 * (100 - pPlayer->GetMerchant()) / 100;
   if ( v7 < v6 / 3 )
-    v7 = v6 / 3;
+  v7 = v6 / 3;
   v83 = v7;
   if ( v7 <= 0 )
   {
@@ -1058,19 +1058,16 @@
       strcat(v77, "\n \n");
       v75[0] = 0;
       pTextHeight = 0;
-      v31 = (signed int)window_SpeakInHouse->ptr_1C;
-      if ( v31 >= 108 && v31 <= 120 )
+      if ( (signed int)window_SpeakInHouse->ptr_1C >= 108 && (signed int)window_SpeakInHouse->ptr_1C <= 120 )
       {
         sprintf(v75, "\xC" "%05d", pDialogueWindow->pCurrentPosActiveItem == 5 ? pColorYellow : pColorWhite);
         strcat(v75, pGlobalTXT_LocalizationStrings[611]); // Play Arcomage
         pTextHeight = pFontArrus->CalcTextHeight(v75, &dialog_window, 0, 0);
       }
-      v34 = pDialogueWindow->pStartingPosActiveItem;
-      v35 = v34 + pDialogueWindow->pNumPresenceButton;
+      pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
       v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
       v37 = -pDialogueWindow->pNumPresenceButton < 0;
-      pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
-      if ( !(v37 ^ v34 < v35) )
+      if ( !(v37 ^ pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton) )
       {
         sprintf(pTmpBuf, "%s%s%s%s", Dest, a1, v77, v75);
         dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf, 3);
@@ -1078,7 +1075,7 @@
       }
       while ( 1 )
       {
-        pButton = pDialogueWindow->GetControl((unsigned int)pOutString);
+        pButton = pDialogueWindow->GetControl(pNumActiveItem);
         if ( pButton->uControlParam == 15 )
         {
           v46 = pTextHeight;
@@ -1114,8 +1111,8 @@
           v41 = v39 + v40 - 1;
           pButton->uW = v41;
         }
-        pOutString = (GUIFont *)((char *)pOutString + 1);
-        if ( (signed int)pOutString >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem )
+        pNumActiveItem++;
+        if ( pNumActiveItem >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem )
         {
           sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
           dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf, 3);
@@ -2439,7 +2436,6 @@
   }
 }
 
-
 //----- (004BA928) --------------------------------------------------------
 void __cdecl ArmorShopDialog()
     {
--- a/mm7_3.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/mm7_3.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -10922,7 +10922,7 @@
 }
 
 //----- (00486B4E) --------------------------------------------------------
-char __fastcall sr_sub_486B4E_push_outdoor_edges(RenderVertexSoft *a1, int *a2, int *a3, stru148 *a4)
+char __fastcall sr_sub_486B4E_push_outdoor_edges(RenderVertexSoft *a1, int *a2, int *a3, stru148 *a4)//maybe DrawPolygonSW
 {
   stru148 *v4; // esi@1
   RenderVertexSoft *v5; // edi@1
@@ -11148,19 +11148,19 @@
 
   if (pBLVRenderParams->uPartySectorID)
   {
-    pBspRenderer->field_FA8[0].uSectorID = pBLVRenderParams->uPartySectorID;
-    pBspRenderer->field_FA8[0].uViewportW = pBLVRenderParams->uViewportW;
-    pBspRenderer->field_FA8[0].uViewportZ = pBLVRenderParams->uViewportZ;
-    pBspRenderer->field_FA8[0].uViewportY = pBLVRenderParams->uViewportY;
-    pBspRenderer->field_FA8[0].uViewportX = pBLVRenderParams->uViewportX;
-    pBspRenderer->field_FA8[0].field_C._43F9E1(
+    pBspRenderer->pSectors[0].uSectorID = pBLVRenderParams->uPartySectorID;
+    pBspRenderer->pSectors[0].uViewportW = pBLVRenderParams->uViewportW;
+    pBspRenderer->pSectors[0].uViewportZ = pBLVRenderParams->uViewportZ;
+    pBspRenderer->pSectors[0].uViewportY = pBLVRenderParams->uViewportY;
+    pBspRenderer->pSectors[0].uViewportX = pBLVRenderParams->uViewportX;
+    pBspRenderer->pSectors[0].field_C._43F9E1(
       pBLVRenderParams->uViewportX,
       pBLVRenderParams->uViewportY,
       pBLVRenderParams->uViewportZ,
       pBLVRenderParams->uViewportW);
-    pBspRenderer->field_FA8[0].uFaceID = -1;
-    pBspRenderer->field_FA8[0].std__vector_0007A8 = -1;
-    pBspRenderer->std__vector_000FA8 = 1;
+    pBspRenderer->pSectors[0].uFaceID = -1;
+    pBspRenderer->pSectors[0].std__vector_0007A8 = -1;
+    pBspRenderer->pNumSectors = 1;
     sub_440639(0);
   }
 
@@ -11524,7 +11524,7 @@
 
   v1 = a1;
   v2 = 0;
-  v3 = &pIndoor->pSectors[pBspRenderer->field_FA8[a1].uSectorID];
+  v3 = &pIndoor->pSectors[pBspRenderer->pSectors[a1].uSectorID];
   if ( pRenderer->pRenderD3D )
   {
     for (uint i = 0; i < v3->uNumNonBSPFaces; ++i)
@@ -11562,7 +11562,7 @@
   //Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode);
 
   v10 = a1;
-  v12 = &pBspRenderer->field_FA8[a1];
+  v12 = &pBspRenderer->pSectors[a1];
   while ( 1 )
   {
     v2 = &pIndoor->pSectors[v12->uSectorID];
@@ -16256,7 +16256,7 @@
 
 
 //----- (0044A56A) --------------------------------------------------------
-void __cdecl sub_44A56A()
+void __cdecl Party__CountHirelings()
 {
   pParty->field_70A = 0;
 
--- a/mm7_4.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/mm7_4.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -3027,7 +3027,7 @@
 //----- (00491F87) --------------------------------------------------------
 void __cdecl DrawHiredNPCs()
 {
-  int v6; // eax@15
+  //int v6; // eax@15
   char v7; // al@17
   unsigned int v8; // eax@18
   int v9; // esi@18
@@ -3040,7 +3040,7 @@
   char pContainer[20]; // [sp+Ch] [bp-30h]@18
   unsigned int v17; // [sp+20h] [bp-1Ch]@19
   signed int uFrameID; // [sp+24h] [bp-18h]@19
-  int i; // [sp+28h] [bp-14h]@15
+  //int i; // [sp+28h] [bp-14h]@15
   unsigned int v20; // [sp+2Ch] [bp-10h]@20
   unsigned int v21; // [sp+30h] [bp-Ch]@19
   int v22; // [sp+34h] [bp-8h]@2
@@ -3062,7 +3062,7 @@
 
     for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
     {
-      if (pNPCStats->pNewNPCData[i].uFlags == 128)
+      if (pNPCStats->pNewNPCData[i].uFlags & 128)
       {
         if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
         {
@@ -3072,12 +3072,10 @@
       }
     }
 
-    v6 = (unsigned __int8)pParty->field_709;
-    for ( i = (unsigned __int8)pParty->field_709; i < v22; v6 = i++ + 1 )
-    {
-      if ( v23 >= 2 )
-        break;
-      v7 = pTmpBuf[v6];
+    //v6 = (unsigned __int8)pParty->field_709;
+	for ( int i = (unsigned __int8)pParty->field_709; i < v22 && v23 < 2; i++ )
+    {
+      v7 = pTmpBuf[i];
       if ( (unsigned __int8)v7 >= 2 )
       {
         sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
@@ -9590,9 +9588,9 @@
     Party::TakeGold(pPrice);
   }
   //LOBYTE(v2->uFlags) |= 0x80u;
-  pCurrentNPCInfo->uFlags = 128;
+  pCurrentNPCInfo->uFlags |= 128;
   pParty->field_709 = 0;
-  sub_44A56A();
+  Party__CountHirelings();
   if ( pParty->pHirelings[0].pName )
   {
     memcpy(&pParty->pHirelings[1], pCurrentNPCInfo, sizeof(pParty->pHirelings[1]));
@@ -9607,7 +9605,7 @@
   }
   strcpy(v22, v24);
   pParty->field_709 = 0;
-  sub_44A56A();
+  Party__CountHirelings();
   PrepareHouse((HOUSE_ID)(int)window_SpeakInHouse->ptr_1C);
   dialog_menu_id = 1;
 
@@ -10813,7 +10811,7 @@
 //----- (004BC49B) --------------------------------------------------------
 void OnSelectNPCDialogueOption(DIALOGUE_TYPE newDialogueType)
 {
-    //unsigned int v1; // esi@1
+	//unsigned int v1; // esi@1
     NPCData *speakingNPC; // ebp@1
     //unsigned int v3; // eax@1
     int npc_event_id; // ecx@10
@@ -10830,208 +10828,210 @@
     const char *v15; // [sp-4h] [bp-14h]@60
 
     //v1 = _this;
-  speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
+	speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
     //v3 = v1;
-  uDialogueType = newDialogueType;
-  if (!speakingNPC->uFlags)
-  {
-    speakingNPC->uFlags = 1;
-        //v3 = uDialogueType;
-  }
-  if ((newDialogueType > DIALOGUE_24) || (newDialogueType < DIALOGUE_19))
-  {
-        if (newDialogueType != DIALOGUE_76)
-            {
-            if (newDialogueType == DIALOGUE_PROFESSION_DETAILS)
-                {
-                dialogue_show_profession_details = ~dialogue_show_profession_details;
-                }
-            else
-                {
-                if ( (signed int)newDialogueType > 84 && (signed int)newDialogueType <= 88 )
-                    {
-                    ArenaFight();
-                    return;
-                    }
-                }
-            goto LABEL_87;
-            }
-        if (speakingNPC->Hired())
-            {
-            v8 = 0;
-            if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-                {
-                v6 = (char *)pNPCStats->pNewNPCData;
-                while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) )
-                    {
-                    ++v8;
-                    v6 += 76;
-                    if ( v8 >= (signed int)pNPCStats->uNumNewNPCs )
-                        goto LABEL_44;
-                    }
-                goto LABEL_43;
-                }
-LABEL_44:
-            if ( !pParty->pHirelings[0].pName || _strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) )
-                {
-                if ( !pParty->pHirelings[1].pName || _strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) )
-                    {
-LABEL_51:
-                    pParty->field_709 = 0;
-                    sub_44A56A();
-                    dword_591084 = 0;
-                    pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-
-                    goto LABEL_89;
-                    }
-                v11 = &pParty->pHirelings[1];
-                }
-            else
-                {
-                v11 = pParty->pHirelings;
-                }
-            memset(v11, 0, sizeof(NPCData));
-            goto LABEL_51;
-            }
-        if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName )
-            {
-            v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full""
-LABEL_64:
-            ShowStatusBarString(v7, 2u);
-            goto LABEL_87;
-            }
-        //v9 = v2->uProfession;
-        if ( speakingNPC->uProfession != 51 )
-            {
-            v10 = pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice;
-            if ( pParty->uNumGold < v10 )
-                {
-                ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
-                dialogue_show_profession_details = false;
-                uDialogueType = 13;
-                if ( uActiveCharacter )
-                    pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
-                v7 = pGlobalTXT_LocalizationStrings[155];
-                ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-                goto LABEL_87;
-                }
-            Party::TakeGold(v10);
-            }
-        LOBYTE(speakingNPC->uFlags) |= 0x80u;
-        if ( pParty->pHirelings[0].pName )
-            {
-            memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1]));
-            v15 = speakingNPC->pName;
-            v13 = pParty->pHireling2Name;
-            }
-        else
-            {
-            memcpy(pParty->pHirelings, speakingNPC, 0x4Cu);
-            v15 = speakingNPC->pName;
-            v13 = pParty->pHireling1Name;
-            }
-        strcpy(v13, v15);
-        pParty->field_709 = 0;
-        sub_44A56A();
-
-        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-
-        if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
-            pDialogue_SpeakingActor->uAIState = Removed;
-        if ( uActiveCharacter )
-            pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
-        goto LABEL_87;
-        if (newDialogueType == DIALOGUE_9)
-            {
-            if ( !sub_4BB756(speakingNPC->uProfession) )
-                {
-                if ( speakingNPC->uProfession != 41 )
-                    speakingNPC->bHasUsedTheAbility = 1;
-
-                pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-                }
-            else
-                {
-                ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!"
-                }
-
-            goto LABEL_87;
-            }
-        if (newDialogueType == DIALOGUE_13)
-            {
-            if (!speakingNPC->Hired())
-                {
-                sub_4B3E1E();
-                dialogue_show_profession_details = false;
-                goto LABEL_87;
-                }
-            else
-                {
-                v5 = 0;
-                if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-                    {
-                    v6 = (char *)pNPCStats->pNewNPCData;
-                    while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) )
-                        {
-                        ++v5;
-                        v6 += 76;
-                        if ( v5 >= (signed int)pNPCStats->uNumNewNPCs )
-                            goto LABEL_44;
-                        }
-LABEL_43:
-                    v6[8] &= 0x7Fu;
-                    goto LABEL_44;
-                    }
-                goto LABEL_44;
-                }
-            }
-        }
-    else
-        {
-        switch(newDialogueType)
-            {
-        case DIALOGUE_19:  npc_event_id = speakingNPC->evt_A; break;
-        case DIALOGUE_20:  npc_event_id = speakingNPC->evt_B; break;
-        case DIALOGUE_21:  npc_event_id = speakingNPC->evt_C; break;
-        case DIALOGUE_22:	 npc_event_id = speakingNPC->evt_D; break;
-        case DIALOGUE_23:  npc_event_id = speakingNPC->evt_E; break;
-        case DIALOGUE_24:	 npc_event_id = speakingNPC->evt_F; break;
-            }
-        if ( (npc_event_id >= 200) && (npc_event_id <= 310) )
-            sub_4B3FE5(npc_event_id); //200-310
-        else if (( npc_event_id >= 400) && (npc_event_id <= 410) )
-            { //400-410
-            dword_F8B1D8 = newDialogueType;
-            DrawJoinGuildWindow(npc_event_id - 400);
-            }
-        else
-            {
-            switch ( npc_event_id )
-                {
-            case 139:
-                sub_4B1ECE();
-                break;
-            case 311:
-                sub_4BBA85_bounties();
-                break;
-            case 399:
-                sub_4BBCDD();
-                break;
-            default:
-                activeLevelDecoration = (LevelDecoration*)1;
-                ptr_F8B1E8 = 0;
-                EventProcessor(npc_event_id, 0, 1);
-                activeLevelDecoration = NULL;
-                break;
-                }
-            }
-        }
-LABEL_87:
-    if ( !dword_7241C8 )
-        pGame->Draw();
-LABEL_89:
-    dword_7241C8 = 0;
-    }
+	uDialogueType = newDialogueType;
+	if (!speakingNPC->uFlags)
+	{
+		speakingNPC->uFlags = 1;
+		//v3 = uDialogueType;
+	}
+
+	if(newDialogueType == DIALOGUE_PROFESSION_DETAILS)
+	{
+		dialogue_show_profession_details = ~dialogue_show_profession_details;
+	}
+	else if(newDialogueType == DIALOGUE_76)
+	{
+		if (speakingNPC->Hired())
+		{
+			v8 = 0;
+			if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+			{
+				v6 = (char *)pNPCStats->pNewNPCData;
+				while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) )
+				{
+					++v8;
+					v6 += 76;
+					if ( v8 >= (signed int)pNPCStats->uNumNewNPCs )
+						break;
+				}
+				if( v8 < (signed int)pNPCStats->uNumNewNPCs )
+					v6[8] &= 0x7Fu;
+			}
+			if ( pParty->pHirelings[0].pName && !_strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) )
+			{
+				v11 = pParty->pHirelings;
+				memset(v11, 0, sizeof(NPCData));
+			}
+			else if ( pParty->pHirelings[1].pName && !_strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) )
+			{
+				v11 = &pParty->pHirelings[1];
+				memset(v11, 0, sizeof(NPCData));
+			}
+			pParty->field_709 = 0;
+			Party__CountHirelings();
+			dword_591084 = 0;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+			dword_7241C8 = 0;
+			return;
+		}
+		if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName )
+		{
+			v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full""
+			ShowStatusBarString(v7, 2u);
+		}
+		else
+		{
+			//v9 = v2->uProfession;
+			if ( speakingNPC->uProfession != 51 )
+			{
+				v10 = pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice;
+																	if ( pParty->uNumGold < v10 )
+			{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
+				dialogue_show_profession_details = false;
+				uDialogueType = 13;
+				if ( uActiveCharacter )
+					pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
+				v7 = pGlobalTXT_LocalizationStrings[155];
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+				if ( !dword_7241C8 )
+					pGame->Draw();
+				dword_7241C8 = 0;
+				return;
+			}
+				Party::TakeGold(v10);
+			}
+			LOBYTE(speakingNPC->uFlags) |= 0x80u;
+			if ( pParty->pHirelings[0].pName )
+			{
+				memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1]));
+				v15 = speakingNPC->pName;
+				v13 = pParty->pHireling2Name;
+			}
+			else
+			{
+				memcpy(pParty->pHirelings, speakingNPC, 0x4Cu);
+				v15 = speakingNPC->pName;
+				v13 = pParty->pHireling1Name;
+			}
+			strcpy(v13, v15);
+			pParty->field_709 = 0;
+			Party__CountHirelings();
+
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+
+			if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
+				pDialogue_SpeakingActor->uAIState = Removed;
+			if ( uActiveCharacter )
+				pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
+		}
+	}
+	else if ( (signed int)newDialogueType > 84 && (signed int)newDialogueType <= 88 )
+	{
+		ArenaFight();
+		return;
+	}
+	else if(newDialogueType == DIALOGUE_9)
+	{
+		if ( !sub_4BB756(speakingNPC->uProfession) )
+		{
+			if ( speakingNPC->uProfession != 41 )
+				speakingNPC->bHasUsedTheAbility = 1;
+
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+		}
+		else
+		{
+			ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!"
+		}
+	}
+	else if(newDialogueType == DIALOGUE_13)
+	{
+		if (!speakingNPC->Hired())
+		{
+			sub_4B3E1E();
+			dialogue_show_profession_details = false;
+		}
+		else
+		{
+			v5 = 0;
+			if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+			{
+				v6 = (char *)pNPCStats->pNewNPCData;
+				while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) )
+				{
+					++v5;
+					v6 += 76;
+					if ( v5 >= (signed int)pNPCStats->uNumNewNPCs )
+						break;
+				}
+				if ( v5 < (signed int)pNPCStats->uNumNewNPCs )
+					v6[8] &= 0x7Fu;
+			}
+			if ( pParty->pHirelings[0].pName && !_strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) )
+			{
+				v11 = pParty->pHirelings;
+				memset(v11, 0, sizeof(NPCData));
+			}
+			else if ( pParty->pHirelings[1].pName && !_strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) )
+			{
+				v11 = &pParty->pHirelings[1];
+				memset(v11, 0, sizeof(NPCData));
+			}
+			pParty->field_709 = 0;
+			Party__CountHirelings();
+			dword_591084 = 0;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+			dword_7241C8 = 0;
+			return;
+		}
+	}
+	else if(newDialogueType >= 19 && newDialogueType <= 24)
+	{
+		switch(newDialogueType)
+		{
+			case DIALOGUE_19:  npc_event_id = speakingNPC->evt_A; break;
+			case DIALOGUE_20:  npc_event_id = speakingNPC->evt_B; break;
+			case DIALOGUE_21:  npc_event_id = speakingNPC->evt_C; break;
+			case DIALOGUE_22:	 npc_event_id = speakingNPC->evt_D; break;
+			case DIALOGUE_23:  npc_event_id = speakingNPC->evt_E; break;
+			case DIALOGUE_24:	 npc_event_id = speakingNPC->evt_F; break;
+		}
+		if ( (npc_event_id >= 200) && (npc_event_id <= 310) )
+			sub_4B3FE5(npc_event_id); //200-310
+		else if (( npc_event_id >= 400) && (npc_event_id <= 410) )
+		{ //400-410
+			dword_F8B1D8 = newDialogueType;
+			DrawJoinGuildWindow(npc_event_id - 400);
+		}
+		else
+		{
+			switch ( npc_event_id )
+			{
+				case 139:
+					sub_4B1ECE();
+					break;
+				case 311:
+					sub_4BBA85_bounties();
+					break;
+				case 399:
+					sub_4BBCDD();
+					break;
+				default:
+					activeLevelDecoration = (LevelDecoration*)1;
+					ptr_F8B1E8 = 0;
+					EventProcessor(npc_event_id, 0, 1);
+					activeLevelDecoration = NULL;
+					break;
+			}
+		}
+	}
+	if ( !dword_7241C8 )
+		pGame->Draw();
+	dword_7241C8 = 0;
+}
 
 
 
--- a/mm7_5.cpp	Wed Mar 13 18:54:19 2013 +0600
+++ b/mm7_5.cpp	Wed Mar 13 18:54:30 2013 +0600
@@ -1367,7 +1367,7 @@
                       {
                         pParty->field_709 = 0;
                         LOBYTE(pNPCStats->pNewNPCData[dword_5B65CC].uFlags) &= 0x7Fu;
-                        sub_44A56A();
+                        Party__CountHirelings();
                         viewparams->bRedrawGameUI = v0;
                         dword_5B65CC = 0;
                       }
@@ -1377,7 +1377,7 @@
                       {
                         pParty->field_709 = 0;
                         LOBYTE(pNPCStats->pNewNPCData[dword_5B65CC].uFlags) &= 0x7Fu;
-                        sub_44A56A();
+                        Party__CountHirelings();
                         viewparams->bRedrawGameUI = v0;
                         dword_5B65CC = 0;
                       }
@@ -9251,22 +9251,21 @@
   int v6; // ebx@3
 
   uNumVisibleNotEmptySectors = 0;
-  for (uint i = 0; i < std__vector_000FA8; ++i)
+  for (uint i = 0; i < pNumSectors; ++i)
   {
       v6 = 0;
       if (!uNumVisibleNotEmptySectors)
       {
-//LABEL_7:
-        pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
+        pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = pSectors[i].uSectorID;
       }
       else
       {
-        while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != field_FA8[i].uSectorID )
+        while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != pSectors[i].uSectorID )
         {
           ++v6;
           if ( v6 >= uNumVisibleNotEmptySectors)
           {
-            pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
+            pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = pSectors[i].uSectorID;
             continue;
           }
         }
@@ -9276,16 +9275,16 @@
 
 
 //----- (0043F515) --------------------------------------------------------
-void MessWithBillboards_BLV()
+void FindBillboardsLightLevels_BLV()
 {
   for (uint i = 0; i < uNumBillboardsToDraw; ++i)
   {
     auto p = pBillboardRenderList + i;
 
     if (p->field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !p->uIndoorSectorID)
-      p->uPaletteSubindex = 0;
+      p->dimming_level = 0;
     else
-      p->uPaletteSubindex = _43F55F_get_billboard_light_level(p, -1);
+      p->dimming_level = _43F55F_get_billboard_light_level(p, -1);
   }
 }
 
@@ -9301,7 +9300,7 @@
   else
   {
     if ( uBaseLightLevel == -1 )
-      v3 = a1->uPaletteSubindex;
+      v3 = a1->dimming_level;
     else
       v3 = uBaseLightLevel;
   }
--- a/mm7_data.h	Wed Mar 13 18:54:19 2013 +0600
+++ b/mm7_data.h	Wed Mar 13 18:54:30 2013 +0600
@@ -1981,7 +1981,7 @@
 void __fastcall PrepareDrawLists_BLV(struct IndoorLocation_drawstru *_this);
 int /*__usercall*/ sr_sub_4D6FB0/*<eax>*/(struct stru315 *a1/*<ebp>*/);
 int /*__usercall*/ sr_sub_4D705A/*<eax>*/(struct stru315 *a1/*<ebp>*/);
-void __cdecl MessWithBillboards_BLV();
+void __cdecl FindBillboardsLightLevels_BLV();
 int __fastcall _43F55F_get_billboard_light_level(struct RenderBillboard *a1, int uBaseLightLevel);
 int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z);
 void PrepareBspRenderList_BLV();
@@ -2044,7 +2044,7 @@
 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb
 bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2);
 void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
-void __cdecl sub_44A56A();
+void __cdecl Party__CountHirelings();
 void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds);
 void __cdecl ShowNothingHereStatus();
 signed int __cdecl const_2();