# HG changeset patch # User Nomad # Date 1364182038 -7200 # Node ID 346f7069676a17e9b6bd96c809e23e8a28205dde # Parent 1e2be0f5eb30d5300d24050f452ba5340fe166de Indoor::GetSector and various stuff diff -r 1e2be0f5eb30 -r 346f7069676a DecalBuilder.cpp --- a/DecalBuilder.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/DecalBuilder.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -467,7 +467,7 @@ if (pFace->uAttributes & 0x400000) return true; - if (pFace->Animated()) + if (pFace->Fluid()) return true; for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i) diff -r 1e2be0f5eb30 -r 346f7069676a Game.cpp --- a/Game.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/Game.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -22,6 +22,7 @@ #include "Arcomage.h" #include "texts.h" #include "Actor.h" +#include "GUIFont.h" #include "Log.h" //#include "MM7.h" @@ -119,6 +120,11 @@ } pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); LABEL_22: + + //DEBUG: force redraw gui + viewparams->bRedrawGameUI = true; + + pRenderer->BeginScene(); if (pRenderer->pRenderD3D) pMouse->DrawCursorToTarget(); @@ -166,12 +172,35 @@ pOtherOverlayList->DrawTurnBasedIcon(v4); GameUI_DrawTorchlightAndWizardEye(); } + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + sprintf(pTmpBuf, "Party Sector ID: %u/%u\n", pBLVRenderParams->uPartySectorID, pIndoor->uNumSectors); + pPrimaryWindow->DrawText(pFontArrus, 16, 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); + } + sprintf(pTmpBuf, "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + uint uFaceID; + auto floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, pBLVRenderParams->uPartySectorID, &uFaceID); + sprintf(pTmpBuf, "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); + } + else + { + int on_water, _a6; + auto floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false); + sprintf(pTmpBuf, "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6); + } + pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); + GUI_UpdateWindows(); pParty->UpdatePlayersAndHirelingsEmotions(); ++stru_51076C.field_8; _unused_5B5924_is_travel_ui_drawn = false; if (v4) - pMouse->field_14 = 1; + pMouse->bRedraw = true; pMouse->_469EA4(); pMouse->DrawCursor(); pMouse->_469E1C(); diff -r 1e2be0f5eb30 -r 346f7069676a Indoor.cpp --- a/Indoor.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/Indoor.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -23,6 +23,9 @@ #include "PaletteManager.h" #include "MapInfo.h" #include "IndoorCamera.h" +#include "GUIWindow.h" +#include "GUIButton.h" +#include "GUIFont.h" #include "mm7_data.h" @@ -375,10 +378,14 @@ if (viewparams->draw_d3d_outlines) _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; + _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; + _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES; + //INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES + _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed; _this.field_1C_mb_fov = 65; - _this.vPosition.x = pParty->vPosition.x - ((stru_5C6E00->Cos(pParty->sRotationY) * (signed __int64)pParty->y_rotation_granularity) >> 16); - _this.vPosition.y = pParty->vPosition.y - ((stru_5C6E00->Sin(pParty->sRotationY) * (signed __int64)pParty->y_rotation_granularity) >> 16); + _this.vPosition.x = pParty->vPosition.x - fixpoint_mul(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); + _this.vPosition.y = pParty->vPosition.y - fixpoint_mul(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel; _this.sRotationX = pParty->sRotationX; _this.sRotationY = pParty->sRotationY; @@ -537,7 +544,7 @@ if (pDecalBuilder->uNumDecals > 0) pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID); - if (pFace->Animated() && + if (pFace->Fluid() && pFace->uBitmapID == pRenderer->hd_water_tile_id ) { __debugbreak(); @@ -545,7 +552,7 @@ goto LABEL_42; } - if (pFace->Animated()) + if (pFace->Fluid()) { //auto v24 = GetTickCount() / 4; //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi; @@ -1467,6 +1474,7 @@ } if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); + //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); } } @@ -3121,10 +3129,10 @@ ///Vec3_short_ *v29; // eax@26 //Vec3_short_ *v30; // edx@26 //int v31; // edx@26 - signed int v32; // edi@27 + //signed int v32; // edi@27 signed __int64 v33; // qtt@27 //Vec3_short_ *v34; // edx@27 - int v35; // edx@32 + //int v35; // edx@32 int v37; // edi@38 int pSectorID; // ebx@40 int v39; // eax@41 @@ -3150,12 +3158,10 @@ int v59; // [sp+110h] [bp-4h]@16 v4 = 0; - //v7 = __OFSUB__(this->uNumSectors, 1); - //v5 = this->uNumSectors == 1; - //v6 = this->uNumSectors - 1 < 0; + v43[0] = 0; + v55 = 0; - v43[0] = 0; - //v56 = 1; + if (uNumSectors < 2) return 0; @@ -3163,126 +3169,101 @@ { auto pSector = pSectors + i; - if (pSector->pBounding.x1 <= sX && pSector->pBounding.x2 >= sX) - if (pSector->pBounding.y1 <= sY && pSector->pBounding.y2 >= sY) - if (pSector->pBounding.z1 - 64 <= sZ && pSector->pBounding.z2 + 64 >= sZ) - { + if (pSector->pBounding.x1 > sX || pSector->pBounding.x2 < sX || + pSector->pBounding.y1 > sY || pSector->pBounding.y2 < sY || + pSector->pBounding.z1 - 64 > sZ || pSector->pBounding.z2 + 64 < sZ) + continue; + //Log::Warning(L"Sector[%u]", i); - v51 = pSector->uNumFloors + pSector->uNumPortals; - if (!v51) - continue; - - //v9 = pSector->uNumFloors; - //v10 = v9 + pSector->uNumPortals; - //v11 = 0; - //v44 = v9; - //v48 = 0; - - //v12 = -2 * v9; - //v53 = -2 * v9; - for (uint j = 0; j < v51; ++j) - { - unsigned int uFaceID; - if (j < pSector->uNumFloors) - uFaceID = pSector->pFloors[j]; - else - uFaceID = pSector->pPortals[j - pSector->uNumFloors]; - - auto pFace = pFaces + uFaceID; - //v14 = (signed __int16)v13; - //v15 = this->pFaces; - //v46 = v13; - //v14 *= 96; - //v45 = v13 * sizeof(BLVFace); - //v16 = pFaces + uFaceID; - //v17 = v16->uPolygonType; - if (pFace->uPolygonType == POLYGON_Floor || - pFace->uPolygonType == POLYGON_InBetweenFloorAndWall) - { - //pVertexIDs = pFace->pVertexIDs; - //v19 = this->pVertices; - //v20 = pVertices[pFace->pVertexIDs[0]].y; - v54 = 0; - //v57 = 0; - //v5 = v16->uNumVertices == 0; - v59 = pVertices[pFace->pVertexIDs[0]].y >= sY; - - //v21 = pFace->pVertexIDs + 1; - for (uint k = 0; k < pFace->uNumVertices; k++) - { - if (v54 >= 2) - break; - - //v49 = &pVertices[pFace->pVertexIDs[k]]; - auto v2 = &pVertices[pFace->pVertexIDs[k]]; - //v22 = pVertex->y; - //v47 = pVertex->y; - v50 = v2->y >= sY; - if ( v59 != v50 ) - { - //v58 = &pVertices[pFace->pVertexIDs[k - 1]]; - auto v1 = &pVertices[pFace->pVertexIDs[k]]; - //v23 = v58->x; - //HIWORD(v24) = HIWORD(v49); - //LOWORD(v24) = v49->x; - //v49 = v24; - //v59 = v49->x; - v25 = v1->x >= sX ? 0 : 2; - v26 = v25 | v2->x < sX; - if ( v26 != 3 ) - { - if (!v26) - ++v54; - else - { - if (v1->x >= v2->x) - { - int _a58; + v51 = pSector->uNumFloors + pSector->uNumPortals; + if (!v51) + continue; + + + for (uint j = 0; j < v51; ++j) + { + uint uFaceID; + if (j < pSector->uNumFloors) + uFaceID = pSector->pFloors[j]; + else + uFaceID = pSector->pPortals[j - pSector->uNumFloors]; + + auto pFace = pFaces + uFaceID; + if (pFace->uPolygonType != POLYGON_Floor && + pFace->uPolygonType != POLYGON_InBetweenFloorAndWall) + continue; + + v54 = 0; + v50 = pVertices[pFace->pVertexIDs[0]].y >= sY; + + for (uint k = 1; k < pFace->uNumVertices; k++) + { + v59 = v50; + + if (v54 >= 2) + break; + + auto v2 = &pVertices[pFace->pVertexIDs[k]]; + v50 = v2->y >= sY; + + if ( v59 == v50 ) + continue; + + auto v1 = &pVertices[pFace->pVertexIDs[k - 1]]; + v25 = v2->x >= sX ? 0 : 2; + v26 = v25 | (v1->x < sX); + + if (v26 == 3) + continue; + + if (!v26) + ++v54; + else + { + if (v1->x >= v2->x) + { + /*int _a58; int _a59; v32 = v1->x - v2->x; LODWORD(v33) = v32 << 16; - HIDWORD(v33) = v32 >> 16; - _a58 = v33 / (v1->y - v2->y); - _a59 = (unsigned __int64)(_a58 * (__int64)(sY - v2->y)) >> 16; - - if (v59 + pVertices[k].x > sX) - ++v54; - } - else - { - int _a58; + HIDWORD(v33) = v32 >> 16;*/ + //fixpoint_div(v1->x - v2->x, v1->y - v2->y); + //_a58 = v33 / (v1->y - v2->y); + //_a59 = fixpoint_mul(_a58, sY - v2->y); + auto x_div_y = fixpoint_div(v1->x - v2->x, v1->y - v2->y); + auto rval = fixpoint_mul(x_div_y, sY - v2->y); // a / b * c - looks like projection + if (rval + v2->x > sX) + ++v54; + } + else + { + auto x_div_y = fixpoint_div(v2->x - v1->x, v2->y - v1->y); + auto res = fixpoint_mul(x_div_y, sY - v1->y); + + if (res + v1->x > sX) + ++v54; + + /*int _a58; int _a59; - v32 = v2->x - v1->x; + auto v32 = v2->x - v1->x; LODWORD(v33) = v32 << 16; HIDWORD(v33) = v32 >> 16; _a58 = v33 / (v2->y - v1->y); - _a59 = (unsigned __int64)(_a58 * (signed __int64)(sY - v1->y)) >> 16; + _a59 = fixpoint_mul(_a58, sY - v1->y); if (_a59 + pVertices[k].x > sX) - ++v54; - } - } - } - } - - v59 = v50; - } - - if (pFace->uNumVertices) - { - if (v54 == 1) - { - v35 = v55++; - v43[v35] = uFaceID; - } - } - } + ++v54;*/ } - v4 = v43[0]; } + } + + if (pFace->uNumVertices && v54 == 1) + v43[v55++] = uFaceID; + } } + v4 = v43[0]; if ( v55 == 1 ) return this->pFaces[v4].uSectorID; v37 = 0; diff -r 1e2be0f5eb30 -r 346f7069676a Indoor.h --- a/Indoor.h Sun Mar 24 23:45:50 2013 +0200 +++ b/Indoor.h Mon Mar 25 05:27:18 2013 +0200 @@ -252,7 +252,7 @@ #define FACE_PORTAL 0x00000001 // portal/two-sided #define FACE_CAN_SATURATE_COLOR 0x00000002 -#define FACE_TEXTURE_ANIMATED 0x00000010 // like wavy water +#define FACE_FLUID 0x00000010 // wavy animated water or lava #define FACE_INVISIBLE 0x00002000 #define FACE_TEXTURE_FRAME 0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID #define FACE_OUTLINED 0x00010000 // outline face edges @@ -285,7 +285,7 @@ inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;} inline bool Visible() const {return !Invisible();} inline bool Portal() const {return uAttributes & FACE_PORTAL;} - inline bool Animated() const {return uAttributes & FACE_TEXTURE_ANIMATED;} + inline bool Fluid() const {return uAttributes & FACE_FLUID;} inline bool Clickable() const {return uAttributes & FACE_CLICKABLE;} @@ -527,6 +527,10 @@ #pragma pack(push, 1) struct BLVRenderParams { + inline BLVRenderParams(): + uFlags(0) + {} + int Reset(struct IndoorLocation_drawstru *a2); int field_0_timer_; diff -r 1e2be0f5eb30 -r 346f7069676a IndoorCamera.h --- a/IndoorCamera.h Sun Mar 24 23:45:50 2013 +0200 +++ b/IndoorCamera.h Mon Mar 25 05:27:18 2013 +0200 @@ -4,6 +4,7 @@ #define INDOOR_CAMERA_DRAW_SW_OUTLINES 1 #define INDOOR_CAMERA_DRAW_D3D_OUTLINES 2 +#define INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES 4 /* 157 */ #pragma pack(push, 1) struct IndoorCamera diff -r 1e2be0f5eb30 -r 346f7069676a IndoorCameraD3D.cpp --- a/IndoorCameraD3D.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/IndoorCameraD3D.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -998,6 +998,59 @@ do_draw_debug_line_sw(&a2[v5], uDiffuse, a2, uDiffuse, 0, a5); } + +void IndoorCameraD3D::DebugDrawPortal(BLVFace *pFace) +{ + assert(pFace->uNumVertices <= 32); + + RenderVertexSoft sw[32]; + for (uint i = 0; i < pFace->uNumVertices; ++i) + { + sw[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x; + sw[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y; + sw[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z; + } + ViewTransform(sw, pFace->uNumVertices); + Project(sw, pFace->uNumVertices, 0); + + + + RenderVertexD3D3 v[32]; + for (uint i = 0; i < pFace->uNumVertices; ++i) + { + v[i].pos.x = sw[i].vWorldViewProjX; + v[i].pos.y = sw[i].vWorldViewProjY; + v[i].pos.z = 1.0 - 1.0 / (sw[i].vWorldViewPosition.x * 0.061758894); + v[i].rhw = 1.0 / sw[i].vWorldViewPosition.x; + v[i].diffuse = 0x80F020F0; + v[i].specular = 0; + //v[i].texcoord.x = pFace->pVertexUIDs[i] / (double)pTex->uTextureWidth; + //v[i].texcoord.y = pFace->pVertexUIDs[i] / (double)pTex->uTextureHeight; + v[i].texcoord.x = 0; + v[i].texcoord.y = 0; + } + + + //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); + //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); + + ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); + ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + v, + pFace->uNumVertices, + 28)); + + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); + //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); + //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); +} + //----- (00437906) -------------------------------------------------------- void IndoorCameraD3D::PrepareAndDrawDebugOutline(BLVFace *pFace, unsigned int uDiffuse) { diff -r 1e2be0f5eb30 -r 346f7069676a IndoorCameraD3D.h --- a/IndoorCameraD3D.h Sun Mar 24 23:45:50 2013 +0200 +++ b/IndoorCameraD3D.h Mon Mar 25 05:27:18 2013 +0200 @@ -158,6 +158,8 @@ void ViewTransfrom_OffsetUV(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *pOutVertices, struct stru320 *a5); char ApplyViewTransform_TrueIfStillVisible(int x, int y, int z, signed int *pOutX, int *pOutZ, int *pOutY, char bDoNotShow); + void DebugDrawPortal(struct BLVFace *pFace); + //void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D *, bool); IndoorCameraD3D_Vec3 field_4[3]; //IndoorCameraD3D_Vec3 field_14; diff -r 1e2be0f5eb30 -r 346f7069676a Mouse.cpp --- a/Mouse.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/Mouse.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -89,7 +89,7 @@ v2->uCursorTextureID_2 = v9; v2->AllocCursorSystemMem(); v2->field_C = 0; - v2->field_14 = 1; + v2->bRedraw = 1; v2->bActive = 1; if ( !areWeLoadingTexture ) { @@ -378,7 +378,7 @@ v8 = v1->pCursorBitmapRect.z; v1->bActive = 0; v1->uCursorBitmapWidth = v8 - v5->x; - v11 = v1->field_14 == 0; + v11 = v1->bRedraw == 0; v1->uCursorBitmapHeight = v1->pCursorBitmapRect.w - v1->pCursorBitmapRect.y; if ( !v11 ) { @@ -393,7 +393,7 @@ pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, &v1->pCursorBitmapRect); - v1->field_14 = 0; + v1->bRedraw = false; } } } diff -r 1e2be0f5eb30 -r 346f7069676a Mouse.h --- a/Mouse.h Sun Mar 24 23:45:50 2013 +0200 +++ b/Mouse.h Mon Mar 25 05:27:18 2013 +0200 @@ -84,7 +84,7 @@ int field_8; int field_C; unsigned int bInitialized; - int field_14; + unsigned int bRedraw; int field_18; int field_1C; int field_20; diff -r 1e2be0f5eb30 -r 346f7069676a Outdoor.cpp --- a/Outdoor.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/Outdoor.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -88,6 +88,7 @@ pIndoorCamera->flags = 0; if (viewparams->draw_d3d_outlines) pIndoorCamera->flags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; + //INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES pIndoorCamera->sRotationX = pParty->sRotationX; pIndoorCamera->sRotationY = pParty->sRotationY; diff -r 1e2be0f5eb30 -r 346f7069676a Outdoor.h --- a/Outdoor.h Sun Mar 24 23:45:50 2013 +0200 +++ b/Outdoor.h Mon Mar 25 05:27:18 2013 +0200 @@ -89,7 +89,8 @@ inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;} inline bool Visible() const {return !Invisible();} - inline bool TwoSided() const {return uAttributes & FACE_PORTAL;} + inline bool Portal() const {return uAttributes & FACE_PORTAL;} + inline bool Fluid() const {return uAttributes & FACE_FLUID;} struct Plane_int_ pFacePlane; int zCalc1; diff -r 1e2be0f5eb30 -r 346f7069676a Render.cpp --- a/Render.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/Render.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -7609,8 +7609,7 @@ } } - if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_D3D_OUTLINES || - pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_D3D_OUTLINES ) + if (pIndoorCamera->flags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES || pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES) pGame->pIndoorCameraD3D->debug_outline_d3d(d3d_vertex_buffer, uNumVertices, 0x00FFFFFF, 0.0); } // 4A26BC: could not find valid save-restore pair for esi diff -r 1e2be0f5eb30 -r 346f7069676a UIHouses.cpp --- a/UIHouses.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/UIHouses.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -1484,13 +1484,6 @@ v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; if ( v37 < v36 / 3 ) v37 = v36 / 3; - - __debugbreak(); - //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23] - // or - //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36] - // or - //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1] //if (false) if(byte_4ED970_skill_learn_ability_by_class_table[v35->classType][uMessageParam-36]) diff -r 1e2be0f5eb30 -r 346f7069676a mm7_1.cpp --- a/mm7_1.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/mm7_1.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -58,11 +58,18 @@ bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive); bool __fastcall Initialize(HINSTANCE hInst, char *pCmdLine); + +//----- (004A1780) mm6_chinese--------------------------------------------- +int fixpoint_div(int a1, int a2) +{ + return ((__int64)a1 << 16) / a2; +} + //----- (004453C0) mm6----------------------------------------------------- //----- (004A1760) mm6_chinese--------------------------------------------- int fixpoint_mul(int a1, int a2) { - return ((__int64)a1 * a2) >> 16; + return ((__int64)a1 * (__int64)a2) / 65536; } //----- (004196A0) -------------------------------------------------------- diff -r 1e2be0f5eb30 -r 346f7069676a mm7_3.cpp --- a/mm7_3.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/mm7_3.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -7756,7 +7756,7 @@ } //----- (0048257A) -------------------------------------------------------- -int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4) +int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int a4) { unsigned int v4; // ebx@1 unsigned int v5; // edi@1 @@ -7787,11 +7787,11 @@ dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5); dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1); dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1); - *a3 = 0; + *pIsOnWater = false; if ( pOutdoor->ActuallyGetSomeOtherTileInfo(v4, v5) & 2 ) - *a3 = 1; + *pIsOnWater = true; v14 = 0; - if ( !a4 && *a3 ) + if ( !a4 && *pIsOnWater ) v14 = -60; if ( dword_76D518_terrain_cell_world_pos_around_party_y != dword_76D51C_terrain_cell_world_pos_around_party_y || dword_76D51C_terrain_cell_world_pos_around_party_y != dword_76D520_terrain_cell_world_pos_around_party_y diff -r 1e2be0f5eb30 -r 346f7069676a mm7_4.cpp --- a/mm7_4.cpp Sun Mar 24 23:45:50 2013 +0200 +++ b/mm7_4.cpp Mon Mar 25 05:27:18 2013 +0200 @@ -439,7 +439,7 @@ } //----- (0046D49E) -------------------------------------------------------- -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int a4, int *a5, int *a6, int a7) +int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *a6, int bWaterWalk) { BSPModel *pBModel; // esi@4 ODMFace *pFace; // ecx@11 @@ -474,7 +474,7 @@ v46 = 1; dword_721160[0] = -1; dword_721110[0] = -1; - odm_floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, a5, a7); + odm_floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, pIsOnWater, bWaterWalk); if ( (signed int)pOutdoor->uNumBModels <= 0 ) { *a6 = 0; @@ -605,9 +605,9 @@ if ( v27 ) { v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]]; - *a5 = 0; - if ( v32->uAttributes & 0x10 ) - *a5 = 1; + *pIsOnWater = false; + if ( v32->Fluid()) + *pIsOnWater = true; } if ( odm_floor_level[v27] >= odm_floor_level[0] ) odm_floor_level[0] = odm_floor_level[v27]; diff -r 1e2be0f5eb30 -r 346f7069676a mm7_data.h --- a/mm7_data.h Sun Mar 24 23:45:50 2013 +0200 +++ b/mm7_data.h Mon Mar 25 05:27:18 2013 +0200 @@ -1969,7 +1969,7 @@ bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2); void __cdecl check_event_triggers(); int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID); -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int a4, int *a5, int *a6, int a7); +int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *a6, int bWaterWalk); int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4); void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out); unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID); @@ -2169,6 +2169,7 @@ void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity); int fixpoint_mul(int, int); +int fixpoint_div(int, int); #define ErrD3D(hr) do {extern void ErrHR(HRESULT, const char *, const char *, const char *, int); ErrHR(hr, "Direct3D", __FUNCTION__, __FILE__, __LINE__);} while(0)