37 #include "../OurMath.h"
39 #include "../stru123.h"
62 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
63 300, 300, 300, 404, 302, 306, 308, 304, 308, 302, 400, 302, 300,
64 308, 308, 306, 308, 308, 304, 300, 404, 406, 300, 400, 406, 404,
65 306, 302, 408, 304, 300, 300, 300, 300, 300, 300, 300, 300, 300,
66 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 404, 304,
67 400, 300, 300, 404, 304, 400, 300, 300, 404, 304, 400, 300, 300};
70 "mdt12.blv",
"d18.blv",
"mdt14.blv",
"d37.blv",
71 "mdk01.blv",
"mdt01.blv",
"mdr01.blv",
"mdt10.blv",
72 "mdt09.blv",
"mdt15.blv",
"mdt11.blv"};
77 sizeof(this->pFacePlane_old));
94 this->uNumVertices =
data->uNumVertices;
95 this->field_5E =
data->field_5E;
96 this->field_5F =
data->field_5F;
115 TorchLightPower = 800;
119 int MinTorch = TorchLightPower;
124 int mod = ((ran - (RAND_MAX * .4)) / 200);
128 if (TorchLightPower < MinTorch)
129 TorchLightPower = MinTorch;
130 if (TorchLightPower > MaxTorch)
131 TorchLightPower = MaxTorch;
220 extern float _calc_fov(
int viewport_width,
int angle_degree);
243 nullptr, 4,
nullptr);
363 render->DrawBillboardList_BLV();
378 (double)(
face->pFacePlane.vNormal.x & 0xFFFF) * 0.000015259022 +
379 (double)(
face->pFacePlane.vNormal.x >> 16);
381 (double)(
face->pFacePlane.vNormal.y & 0xFFFF) * 0.000015259022 +
382 (double)(
face->pFacePlane.vNormal.y >> 16);
384 (double)(
face->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022 +
385 (double)(
face->pFacePlane.vNormal.z >> 16);
387 (double)(
face->pFacePlane.dist & 0xFFFF) * 0.000015259022 +
388 (double)(
face->pFacePlane.dist >> 16);
403 this->uNumVertices =
face->uNumVertices;
404 this->resource =
face->resource;
405 this->pVertexIDs =
face->pVertexIDs;
411 unsigned int uNumVertices,
415 unsigned int uNumVerticesa;
424 static stru154 FacePlaneHolder;
452 static_vertices_buff_in[i].
u = (
signed short)pFace->
pVertexUIDs[i];
453 static_vertices_buff_in[i].
v = (
signed short)pFace->
pVertexVIDs[i];
459 static_vertices_buff_in, &uNumVerticesa),
462 static_vertices_buff_in, &uNumVerticesa,
463 static_vertices_calc_out,
465 false, 0) != 1 || uNumVerticesa) {
520 if (pFace->
Fluid()) {
530 float angle = (eightSeconds / 8000.0f) * 2 * 3.1415
f;
533 for (
uint i = 0; i < uNumVerticesa; ++i)
544 ColourMask = 0xFF808080;
549 render->DrawIndoorSky(uNumVerticesa, uFaceID);
552 render->DrawIndoorPolygon(uNumVerticesa, pFace, PID(
OBJECT_BModel, uFaceID), ColourMask, 0);
585 unsigned int uFaceID) {
586 unsigned __int16 pTransitionSector;
605 if (
nodes[node_id].uFaceID == uFaceID)
return;
624 if (
nodes[0].uSectorID == pTransitionSector)
654 if (num_vertices < 2)
return;
660 for (
uint i = 1; i < num_vertices; ++i) {
675 if (face_max_screenspace_x >=
nodes[node_id].uViewportX &&
676 face_min_screenspace_x <=
nodes[node_id].uViewportZ &&
677 face_max_screenspace_y >=
nodes[node_id].uViewportY &&
678 face_min_screenspace_y <=
nodes[node_id].uViewportW &&
680 &
nodes[node_id].PortalScreenData, uFaceID)) {
684 if (
nodes[node_id].uSectorID == pTransitionSector)
693 if (
nodes[node_id].viewing_portal_id == -1) {
694 v29 =
engine->pStru10Instance->CalcPortalShape(
712 static_subAddFaceToRenderList_d3d_stru_F7AA08, &pNewNumVertices,
713 static_subAddFaceToRenderList_d3d_stru_F79E08,
714 nodes[node_id].std__vector_0007AC, 4, 0, 0);
716 v29 =
engine->pStru10Instance->_49C5DA(
717 pFace, static_subAddFaceToRenderList_d3d_stru_F79E08,
813 pVertices = (Vec3_short_ *)malloc(15000 *
sizeof(Vec3_short_));
824 memset(
pVertices, 0, 15000 *
sizeof(Vec3_short_));
840 for (
uint i = 0; i < 11; ++i)
848 (sLightID <= pIndoor->
uNumLights - 1) && (sLightID >= 0)) {
859 int respawn_interval_days,
char *pDest) {
870 blv_filename.replace(blv_filename.length() - 4, 4,
".blv");
874 Error(
"Unable to find %s in Games.LOD", blv_filename.c_str());
883 char *pData = (
char*)rawData;
905 for (
unsigned int i = 0; i <
uNumFaces; ++i) {
945 strncpy(pTexName, pData, 10);
964 strncpy(pTexName, pData, 10);
967 if (!strcmp(pTexName,
""))
1091 dlv_filename.replace(dlv_filename.length() - 4, 4,
".dlv");
1093 bool bResetSpawn =
false;
1094 size_t dlv_size = 0;
1096 if (rawData !=
nullptr) {
1097 pData = (
char*)rawData;
1113 respawn_interval_days = 0x1BAF800;
1116 bool bRespawnLocation =
false;
1119 bRespawnLocation =
true;
1122 char SavedOutlines[875];
1125 memset(SavedOutlines, 0, 875);
1127 memcpy(SavedOutlines, pData, 875);
1203 memcpy(
pDoors, pData, 0x3E80);
1271 memcpy(&
stru1, pData, 0x38u);
1287 int FoundFaceStore[50];
1288 bool Vert2AboveParty;
1291 int VertsPassChecks;
1294 FoundFaceStore[0] = 0;
1296 int NumFoundFaceStore = 0;
1310 if (!FloorsAndPortals)
continue;
1312 for (
uint j = 0; j < FloorsAndPortals; ++j) {
1314 if (j < pSector->uNumFloors)
1315 uFaceID = pSector->
pFloors[j];
1324 VertsPassChecks = 0;
1328 bool Vert1AboveParty = Vert2AboveParty;
1330 if (VertsPassChecks >= 2)
break;
1333 Vert2AboveParty =
v2->y >= sY;
1335 if (Vert1AboveParty == Vert2AboveParty)
continue;
1338 v25 =
v2->x >= sX ? 0 : 2;
1339 v26 = v25 | (
v1->x < sX);
1341 if (v26 == 3)
continue;
1346 if (
v1->x >=
v2->x) {
1361 if (
res +
v2->x > sX) ++VertsPassChecks;
1367 if (
res +
v1->x > sX) ++VertsPassChecks;
1383 if (pFace->
uNumVertices && VertsPassChecks == 1) FoundFaceStore[NumFoundFaceStore++] = uFaceID;
1388 if (NumFoundFaceStore == 1)
return this->
pFaces[FoundFaceStore[0]].
uSectorID;
1390 if (!NumFoundFaceStore)
return 0;
1395 if (NumFoundFaceStore > 0) {
1397 for (
int v37 = 0; v37 < NumFoundFaceStore; ++v37) {
1401 if (this->
pFaces[FoundFaceStore[v37]].uPolygonType ==
1430 a3->z = 0xFFFF0000u;
1439 a3->y = 0xFFFF0000u;
1451 a2->x = (
signed __int64)(a1.
x * 65536.0);
1452 a2->y = (
signed __int64)(a1.
y * 65536.0);
1456 a3->z = 0xFFFF0000u;
1465 a3->y = 0xFFFF0000u;
1484 int event_index = 0;
1592 for (v88 = 0; v88 < door->
uNumFaces; ++v88) {
1595 v18 =
face->pFacePlane_old.vNormal.y;
1596 v73 = *(
int *)&v17->x;
1597 v19 =
face->pFacePlane_old.vNormal.z;
1598 v20 = -(v19 * (
int)v17->z +
1599 (
signed __int16)v73 *
face->pFacePlane_old.vNormal.x +
1600 HEXRAYS_SHIWORD(v73) * v18);
1601 face->pFacePlane_old.dist = v20;
1602 face->pFacePlane.dist =
1603 -((double)v17->z *
face->pFacePlane.vNormal.z +
1604 (
double)v17->y *
face->pFacePlane.vNormal.y +
1605 (double)v17->x *
face->pFacePlane.vNormal.x);
1607 v24 = abs(v20 >> 15);
1608 v25 = abs(
face->pFacePlane_old.vNormal.z);
1611 "Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow "
1612 "dividing facet->d [%i] by facet->nz [%i]",
1614 face->pFacePlane_old.dist,
1615 face->pFacePlane_old.vNormal.z);
1616 HEXRAYS_LODWORD(v27) =
face->pFacePlane_old.dist << 16;
1617 HEXRAYS_HIDWORD(v27) =
face->pFacePlane_old.dist >> 16;
1618 face->zCalc3 = -v27 /
face->pFacePlane_old.vNormal.z;
1622 face->_get_normals(&v70, &v67);
1650 v37 = v70.x * v82 + v70.y * v36 + v70.z * v35;
1651 v38 = v67.x * v82 + v67.y * v36 + v67.z * v35;
1653 *
face->pVertexUIDs = v39;
1655 *
face->pVertexVIDs = v40;
1658 for (
uint j = 1; j <
face->uNumVertices; ++j) {
1660 v76 = ((__int64)v70.z * v43->z + (__int64)v70.x * v43->x +
1661 (__int64)v70.y * v43->y) >>
1663 v77 = ((__int64)v67.x * v43->x + (__int64)v67.y * v43->y +
1664 (__int64)v43->z * v67.z) >>
1666 if (v76 < v39) v39 = v76;
1667 if (v77 < v40) v40 = v77;
1668 if (v76 > v84) v84 = v76;
1669 if (v77 > v82) v82 = v77;
1670 face->pVertexUIDs[j] = v76;
1671 face->pVertexVIDs[j] = v77;
1673 if (
face->uAttributes & 0x00001000) {
1676 if (
face->uAttributes & 0x8000) {
1677 if (
face->resource) {
1685 if (
face->uAttributes & FACE_UNKNOW6) {
1688 if (
face->uAttributes & FACE_INDOOR_DOOR) {
1696 if (
face->uAttributes & FACE_TEXTURE_FLOW) {
1700 v75 = v84 + v82 + v83;
1706 v75 = v84 + v82 + v83;
1739 unsigned int uSectorID;
1744 unsigned int uFaceID;
1747 unsigned int actor_id;
1749 if (
engine->config->no_actors)
1752 for (actor_id = 0; actor_id <
uNumActors; actor_id++) {
1756 !
pActors[actor_id].uMovementSpeed)
1758 uSectorID =
pActors[actor_id].uSectorID;
1761 pActors[actor_id].vPosition.z, &uSectorID, &uFaceID);
1762 pActors[actor_id].uSectorID = uSectorID;
1763 v3 =
pActors[actor_id].pMonsterInfo.uFlying;
1766 if (!
pActors[actor_id].CanAct()) v62 = 0;
1767 v4 =
pActors[actor_id].vPosition.z;
1769 if (
pActors[actor_id].vPosition.z >
v2 + 1) v59 = 1;
1772 pActors[actor_id].vPosition.y, v4);
1773 pActors[actor_id].uSectorID = v5;
1776 pActors[actor_id].vPosition.z, v5, &uFaceID);
1777 if (!v5 || v56 == -30000)
continue;
1779 if (
pActors[actor_id].uCurrentActionAnimation ==
1781 v6 =
pActors[actor_id].uMovementSpeed;
1784 HEXRAYS_LODWORD(v10) =
pActors[actor_id].uMovementSpeed /
1785 (
unsigned __int16)
pActors[actor_id]
1789 v10 = (
signed __int64)((
double)
pActors[actor_id]
1798 v6 = (
signed __int64)((
double)v6 *
1800 if (v6 > 1000) v6 = 1000;
1801 pActors[actor_id].vVelocity.x =
1803 pActors[actor_id].vVelocity.y =
1809 pActors[actor_id].vVelocity.x =
1811 pActors[actor_id].vVelocity.y =
1814 pActors[actor_id].vVelocity.z =
1817 if (
pActors[actor_id].vPosition.z <= v56) {
1818 pActors[actor_id].vPosition.z = v56 + 1;
1820 if (
pActors[actor_id].vVelocity.z < 0)
1821 pActors[actor_id].vVelocity.z = 0;
1824 pActors[actor_id].vVelocity.z -=
1829 pActors[actor_id].vVelocity.z +=
1833 if (
pActors[actor_id].vVelocity.x *
pActors[actor_id].vVelocity.x +
1844 for (uSectorID = 0; uSectorID < 100; uSectorID++) {
1850 pActors[actor_id].uActorRadius + 1;
1852 pActors[actor_id].uActorRadius +
1856 pActors[actor_id].uActorRadius + 1;
1865 for (v61 = 0; v61 < 100; ++v61) {
1874 pActors[actor_id].vPosition.z);
1877 pActors[actor_id].vPosition.y);
1880 pActors[actor_id].vPosition.x);
1882 pActors[actor_id].uActorRadius +
1900 v30 =
pActors[actor_id].vPosition.x +
1903 v31 =
pActors[actor_id].vPosition.y +
1906 v32 =
pActors[actor_id].vPosition.z +
1921 if (v33 == -30000)
continue;
1922 if (
pActors[actor_id].uCurrentActionAnimation != 1 ||
1923 v33 >=
pActors[actor_id].vPosition.z - 100 || v59 ||
1926 pActors[actor_id].vPosition.x +=
1929 pActors[actor_id].vPosition.y +=
1932 pActors[actor_id].vPosition.z +=
1943 pActors[actor_id].vVelocity.x =
1945 pActors[actor_id].vVelocity.y =
1947 pActors[actor_id].vVelocity.z =
1950 pActors[actor_id].vVelocity.z);
1955 .pMonsterInfo.uHostilityType) {
1963 pActors[actor_id].vVelocity.x);
1967 pActors[actor_id].vVelocity.y);
1971 pActors[actor_id].vVelocity.z);
1983 pActors[actor_id].vVelocity.x =
1988 pActors[actor_id].vVelocity.y =
1993 pActors[actor_id].vVelocity.z =
2007 pActors[actor_id].vVelocity.x);
2011 pActors[actor_id].vVelocity.y);
2015 pActors[actor_id].vVelocity.z);
2022 pActors[actor_id].vVelocity.x =
2025 pActors[actor_id].vVelocity.x);
2026 pActors[actor_id].vVelocity.y =
2029 pActors[actor_id].vVelocity.y);
2030 pActors[actor_id].vVelocity.z =
2033 pActors[actor_id].vVelocity.z);
2039 if (
pActors[actor_id].GetActorsRelation(
2048 pActors[actor_id].vVelocity.y = 0;
2049 pActors[actor_id].vVelocity.x = 0;
2061 pActors[actor_id].vVelocity.x =
2064 pActors[actor_id].vVelocity.x);
2065 pActors[actor_id].vVelocity.y =
2068 pActors[actor_id].vVelocity.y);
2069 pActors[actor_id].vVelocity.z =
2072 pActors[actor_id].vVelocity.z);
2078 pActors[actor_id].vVelocity.x =
2081 pActors[actor_id].vVelocity.x);
2082 pActors[actor_id].vVelocity.y =
2085 pActors[actor_id].vVelocity.y);
2086 pActors[actor_id].vVelocity.z =
2089 pActors[actor_id].vVelocity.z);
2096 pActors[actor_id].vVelocity.x *
2097 pActors[actor_id].vVelocity.x +
2098 pActors[actor_id].vVelocity.y *
2099 pActors[actor_id].vVelocity.y);
2101 pActors[actor_id].vPosition.x -
2103 pActors[actor_id].vPosition.y -
2105 pActors[actor_id].vVelocity.x =
2108 pActors[actor_id].vVelocity.y =
2111 pActors[actor_id].vVelocity.x =
2114 pActors[actor_id].vVelocity.x);
2115 pActors[actor_id].vVelocity.y =
2118 pActors[actor_id].vVelocity.y);
2119 pActors[actor_id].vVelocity.z =
2122 pActors[actor_id].vVelocity.z);
2131 pActors[actor_id].vVelocity.z = 0;
2132 pActors[actor_id].vPosition.z =
2139 if (
pActors[actor_id].vVelocity.x *
2142 pActors[actor_id].vVelocity.y *
2146 pActors[actor_id].vVelocity.y = 0;
2147 pActors[actor_id].vVelocity.x = 0;
2151 pActors[actor_id].vVelocity.x);
2155 pActors[actor_id].vVelocity.y);
2159 pActors[actor_id].vVelocity.z);
2182 pActors[actor_id].vVelocity.x +=
2187 pActors[actor_id].vVelocity.y +=
2192 pActors[actor_id].vVelocity.z +=
2221 pActors[actor_id].vPosition.x +=
2227 pActors[actor_id].vPosition.y +=
2233 pActors[actor_id].vPosition.z +=
2242 pActors[actor_id].vVelocity.x,
2243 pActors[actor_id].vVelocity.y);
2257 58500,
pActors[actor_id].vVelocity.x);
2259 58500,
pActors[actor_id].vVelocity.y);
2261 58500,
pActors[actor_id].vVelocity.z);
2265 pActors[actor_id].vPosition.x =
2267 pActors[actor_id].vPosition.y =
2269 pActors[actor_id].vPosition.z =
2278 }
else if (
pActors[actor_id].vPosition.x & 1) {
2279 pActors[actor_id].uYawAngle += 100;
2281 pActors[actor_id].uYawAngle -= 100;
2288 if (!
pActors[actor_id].pMonsterInfo.uHostilityType ||
2297 pActors[actor_id].vVelocity.z = 0;
2298 pActors[actor_id].vVelocity.y = 0;
2299 pActors[actor_id].vVelocity.x = 0;
2311 unsigned int respawn_interval;
2312 unsigned int map_id;
2322 respawn_interval = 0;
2345 map_info = (
MapInfo *)bLoading;
2351 respawn_interval, (
char *)&pDest) -
2355 if (v4 == 1) Error(
"File %s is not a BLV File",
pCurrentMapName.c_str());
2357 if (v4 == 2) Error(
"Attempt to open new level before clearing old");
2358 if (v4 == 3) Error(
"Out of memory loading indoor level");
2364 if (!map_id) pDest = 0;
2368 if (spawn->IsMonsterSpawn())
2417 unsigned char r = 255,
g = 255,
b = 255;
2419 render->config->is_using_colored_lights) {
2469 if (
pActors[i].uAttributes & ACTOR_UNKNOW7) {
2471 pActors[i].pMonsterInfo.field_3E = 19;
2472 pActors[i].uAttributes |= ACTOR_UNKNOW11;
2482 pActors[i].pMonsterInfo.uHostilityType =
2484 if (
pActors[i].pMonsterInfo.field_3E != 11 &&
2485 pActors[i].pMonsterInfo.field_3E != 19 &&
2487 pActors[i].pMonsterInfo.field_3E = 5;
2491 pActors[i].pMonsterInfo.field_3E = 19;
2492 pActors[i].uAttributes |= ACTOR_UNKNOW11;
2516 for (
uint pl_id = 1; pl_id <= 4; ++pl_id) {
2517 if (
pPlayers[pl_id]->CanAct()) v34[v30++] = pl_id;
2531 unsigned int *pFaceID) {
2540 bool current_vertices_Y;
2542 bool next_vertices_Y;
2547 static int blv_floor_id[50];
2548 static int blv_floor_level[50];
2550 static __int16 blv_floor_face_vert_coord_Y[104];
2551 static __int16 blv_floor_face_vert_coord_X[104];
2563 blv_floor_face_vert_coord_X[2 * j] =
2566 blv_floor_face_vert_coord_X[2 * j + 1] =
2569 blv_floor_face_vert_coord_Y[2 * j] =
2572 blv_floor_face_vert_coord_Y[2 * j + 1] =
2576 blv_floor_face_vert_coord_X[2 * pFloor->
uNumVertices] =
2577 blv_floor_face_vert_coord_X[0];
2578 blv_floor_face_vert_coord_Y[2 * pFloor->
uNumVertices] =
2579 blv_floor_face_vert_coord_Y[0];
2581 next_vertices_Y = blv_floor_face_vert_coord_Y[0] >=
y;
2585 if (number_hits >= 2)
break;
2587 current_vertices_Y = next_vertices_Y;
2588 next_vertices_Y = blv_floor_face_vert_coord_Y[j + 1] >=
y;
2591 if (current_vertices_Y == next_vertices_Y)
continue;
2593 v14 = blv_floor_face_vert_coord_X[j + 1] >=
x ? 0 : 2;
2594 v15 = v14 | (blv_floor_face_vert_coord_X[j] <
x);
2603 blv_floor_face_vert_coord_Y[j + 1] -
2604 blv_floor_face_vert_coord_Y[j]);
2606 (
signed int)blv_floor_face_vert_coord_X[j + 1] -
2607 (
signed int)blv_floor_face_vert_coord_X[j],
2610 if (
res + blv_floor_face_vert_coord_X[j] >=
x)
2615 if (number_hits == 1) {
2616 if (v55 >= 50)
break;
2623 (short)(pFloor->
zCalc3 >> 16);
2624 blv_floor_level[v55] = v21;
2625 blv_floor_id[v55] = pSector->
pFloors[i];
2641 blv_floor_face_vert_coord_X[2 * j] =
2644 blv_floor_face_vert_coord_X[2 * j + 1] =
2647 blv_floor_face_vert_coord_Y[2 * j] =
2650 blv_floor_face_vert_coord_Y[2 * j + 1] =
2654 blv_floor_face_vert_coord_X[2 * portal->
uNumVertices] =
2655 blv_floor_face_vert_coord_X[0];
2656 blv_floor_face_vert_coord_Y[2 * portal->
uNumVertices] =
2657 blv_floor_face_vert_coord_Y[0];
2659 v47 = blv_floor_face_vert_coord_Y[0] >=
y;
2663 if (v54 >= 2)
break;
2664 v47 = blv_floor_face_vert_coord_Y[j + 1] >=
y;
2666 v28 = blv_floor_face_vert_coord_X[j + 1] >=
x ? 0 : 2;
2667 v29 = v28 | (blv_floor_face_vert_coord_X[j] <
x);
2673 y - blv_floor_face_vert_coord_Y[j],
2674 blv_floor_face_vert_coord_Y[j + 1] -
2675 blv_floor_face_vert_coord_Y[j]);
2677 blv_floor_face_vert_coord_X[j + 1] -
2678 blv_floor_face_vert_coord_X[j],
2680 if (
res + blv_floor_face_vert_coord_X[j] >=
x)
2687 if (v55 >= 50)
break;
2688 blv_floor_level[v55] = -29000;
2689 blv_floor_id[v55] = pSector->
pPortals[i];
2696 *pFaceID = blv_floor_id[0];
2698 return blv_floor_level[0];
2700 if (!v55)
return -30000;
2701 *pFaceID = blv_floor_id[0];
2719 int result = blv_floor_level[0];
2720 for (
uint i = 1; i < v55; ++i) {
2721 v38 = blv_floor_level[i];
2723 if (v38 >
result && v38 <=
z + 5) {
2724 result = blv_floor_level[i];
2726 *pFaceID = blv_floor_id[i];
2728 }
else if (v38 <
result) {
2729 result = blv_floor_level[i];
2731 *pFaceID = blv_floor_id[i];
2757 v6 = ((
signed int)(
pActors[i].uYawAngle +
2762 v8 =
pActors[i].uCurrentActionTime;
2764 if (
pActors[i].uCurrentActionAnimation == 1)
2767 if (
pActors[i].uCurrentActionAnimation == 1)
2784 if (v9->
uFlags & 2) v41 = 2;
2785 if (v9->
uFlags & 0x40000) v41 |= 0x40;
2786 if (v9->
uFlags & 0x20000) v41 |= 0x80;
2787 if ((256 << v6) & v9->
uFlags) v41 |= 4;
2797 ->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] ==
2804 pActors[i].vPosition.z, &view_x, &view_y, &view_z);
2806 if (abs(view_x) >= abs(view_y)) {
2807 int projected_x = 0;
2808 int projected_y = 0;
2810 &projected_x, &projected_y);
2816 pActors[i].uAttributes |= ACTOR_VISIBLE;
2902 if (v4->
uFlags & 2) v34 = 2;
2903 if (v4->
uFlags & 0x40000) v34 |= 0x40;
2904 if (v4->
uFlags & 0x20000) v34 |= 0x80;
2906 if ((256 << v9) & v4->
uFlags) v34 |= 4;
2926 &view_x, &view_y, &view_z);
2932 int projected_x = 0;
2933 int projected_y = 0;
3037 if (v9 == -1)
break;
3056 memset(&particle, 0,
sizeof(particle));
3094 if (v11->
uFlags & 2) v30 = 2;
3095 if (v11->
uFlags & 0x40000) v30 |= 0x40;
3096 if (v11->
uFlags & 0x20000) v30 |= 0x80;
3097 if ((256 << v9) & v11->
uFlags) v30 |= 4;
3106 &view_x, &view_y, &view_z);
3109 if (abs(view_x) >= abs(view_y)) {
3110 int projected_x = 0;
3111 int projected_y = 0;
3186 for (
uint i = 0; i <
window->GetHeight(); ++i) {
3187 if (i < y || i >
w) {
3321 v49 =
integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z);
3323 if (v49) v50 = 65536 / v49;
3325 v143 = dist_x * v50;
3329 v123 = std::max(outx, sX);
3330 v119 = std::min(outx, sX);
3332 v131 = std::max(outy, sY);
3333 v127 = std::min(outy, sY);
3335 v139 = std::max(outz, sZ);
3336 v135 = std::min(outz, sZ);
3338 for (a5b = 0; a5b < 2; a5b++) {
3363 v20 = v63 + v64 + v65 == 0;
3364 v66 = v63 + v64 + v65;
3365 v107 = v63 + v64 + v65;
3366 if (
face->Portal() || v119 >
face->pBounding.x2 ||
3367 v123 < face->pBounding.x1 || v127 >
face->pBounding.y2 ||
3368 v131 < face->pBounding.y1 || v135 >
face->pBounding.z2 ||
3369 v139 < face->pBounding.z1 || v20)
3371 v68 = -(
face->pFacePlane_old.dist +
3372 sX *
face->pFacePlane_old.vNormal.x +
3373 sY *
face->pFacePlane_old.vNormal.y +
3374 sZ *
face->pFacePlane_old.vNormal.z);
3376 if (
face->pFacePlane_old.dist +
3377 sX *
face->pFacePlane_old.vNormal.x +
3378 sY *
face->pFacePlane_old.vNormal.y +
3379 sZ *
face->pFacePlane_old.vNormal.z <
3383 if (
face->pFacePlane_old.dist +
3384 sX *
face->pFacePlane_old.vNormal.x +
3385 sY *
face->pFacePlane_old.vNormal.y +
3386 sZ *
face->pFacePlane_old.vNormal.z >
3390 v69 = abs(-(
face->pFacePlane_old.dist +
3391 sX *
face->pFacePlane_old.vNormal.x +
3392 sY *
face->pFacePlane_old.vNormal.y +
3393 sZ *
face->pFacePlane_old.vNormal.z)) >>
3395 if (v69 <= abs(v66)) {
3428 v77 =
integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z);
3430 if (v77) v78 = 65536 / v77;
3432 v144 = dist_x * v78;
3436 v120 = std::max(outx, sX);
3437 v124 = std::min(outx, sX);
3439 v132 = std::max(outy, sY);
3440 v128 = std::min(outy, sY);
3442 v140 = std::max(outz, sZ);
3443 v136 = std::min(outz, sZ);
3445 for (a5c = 0; a5c < 2; a5c++) {
3446 if (v113)
return !v114 || !v113;
3457 v20 = yb + vf + v_4b == 0;
3458 v91 = yb + vf + v_4b;
3459 vc = yb + vf + v_4b;
3460 if (
face->Portal() || v120 >
face->pBounding.x2 ||
3461 v124 < face->pBounding.x1 || v128 >
face->pBounding.y2 ||
3462 v132 < face->pBounding.y1 || v136 >
face->pBounding.z2 ||
3463 v140 < face->pBounding.z1 || v20)
3465 v93 = -(
face->pFacePlane_old.dist +
3466 sX *
face->pFacePlane_old.vNormal.x +
3467 sY *
face->pFacePlane_old.vNormal.y +
3468 sZ *
face->pFacePlane_old.vNormal.z);
3470 if (
face->pFacePlane_old.dist +
3471 sX *
face->pFacePlane_old.vNormal.x +
3472 sY *
face->pFacePlane_old.vNormal.y +
3473 sZ *
face->pFacePlane_old.vNormal.z <
3477 if (
face->pFacePlane_old.dist +
3478 sX *
face->pFacePlane_old.vNormal.x +
3479 sY *
face->pFacePlane_old.vNormal.y +
3480 sZ *
face->pFacePlane_old.vNormal.z >
3484 v_4c = abs(-(
face->pFacePlane_old.dist +
3485 sX *
face->pFacePlane_old.vNormal.x +
3486 sY *
face->pFacePlane_old.vNormal.y +
3487 sZ *
face->pFacePlane_old.vNormal.z)) >>
3489 if (v_4c <= abs(v91)) {
3518 v9 =
integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z);
3520 if (v9) v10 = 65536 / v9;
3521 v125 = dist_x * v10;
3523 v121 = dist_y * v10;
3525 v145 = std::max(outx, sX);
3526 v149 = std::min(outx, sX);
3528 v137 = std::max(outy, sY);
3529 v141 = std::min(outy, sY);
3531 v129 = std::max(outz, sZ);
3532 v133 = std::min(outz, sZ);
3541 v20 = v17 + v18 + v19 == 0;
3542 v21 = v17 + v18 + v19;
3543 v109 = v17 + v18 + v19;
3544 if (v149 >
face.pBoundingBox.x2 ||
3545 v145 <
face.pBoundingBox.x1 ||
3546 v141 >
face.pBoundingBox.y2 ||
3547 v137 <
face.pBoundingBox.y1 ||
3548 v133 >
face.pBoundingBox.z2 ||
3549 v129 <
face.pBoundingBox.z1 || v20)
3551 v23 = -(
face.pFacePlane.dist +
3552 sX *
face.pFacePlane.vNormal.x +
3553 sY *
face.pFacePlane.vNormal.y +
3554 sZ *
face.pFacePlane.vNormal.z);
3556 if (
face.pFacePlane.dist +
3557 sX *
face.pFacePlane.vNormal.x +
3558 sY *
face.pFacePlane.vNormal.y +
3559 sZ *
face.pFacePlane.vNormal.z <
3563 if (
face.pFacePlane.dist +
3564 sX *
face.pFacePlane.vNormal.x +
3565 sY *
face.pFacePlane.vNormal.y +
3566 sZ *
face.pFacePlane.vNormal.z >
3570 v24 = abs(-(
face.pFacePlane.dist +
3571 sX *
face.pFacePlane.vNormal.x +
3572 sY *
face.pFacePlane.vNormal.y +
3573 sZ *
face.pFacePlane.vNormal.z)) >>
3575 if (v24 <= abs(v21)) {
3607 v32 =
integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z);
3609 if (v32) v33 = 65536 / v32;
3610 v126 = dist_x * v33;
3612 v122 = dist_y * v33;
3614 v146 = std::max(outx, sX);
3615 v150 = std::min(outx, sX);
3617 v138 = std::max(outy, sY);
3618 v142 = std::min(outy, sY);
3620 v130 = std::max(outz, sZ);
3621 v134 = std::min(outz, sZ);
3630 v20 = ya + ve + v_4 == 0;
3631 v40 = ya + ve + v_4;
3633 if (v150 >
face.pBoundingBox.x2 ||
3634 v146 <
face.pBoundingBox.x1 ||
3635 v142 >
face.pBoundingBox.y2 ||
3636 v138 <
face.pBoundingBox.y1 ||
3637 v134 >
face.pBoundingBox.z2 ||
3638 v130 <
face.pBoundingBox.z1 || v20)
3640 v42 = -(
face.pFacePlane.dist +
3641 sX *
face.pFacePlane.vNormal.x +
3642 sY *
face.pFacePlane.vNormal.y +
3643 sZ *
face.pFacePlane.vNormal.z);
3645 if (
face.pFacePlane.dist +
3646 sX *
face.pFacePlane.vNormal.x +
3647 sY *
face.pFacePlane.vNormal.y +
3648 sZ *
face.pFacePlane.vNormal.z <
3652 if (
face.pFacePlane.dist +
3653 sX *
face.pFacePlane.vNormal.x +
3654 sY *
face.pFacePlane.vNormal.y +
3655 sZ *
face.pFacePlane.vNormal.z >
3659 v_4a = abs(-(
face.pFacePlane.dist +
3660 sX *
face.pFacePlane.vNormal.x +
3661 sY *
face.pFacePlane.vNormal.y +
3662 sZ *
face.pFacePlane.vNormal.z)) >>
3664 if (v_4a <= abs(v40)) {
3689 return !v114 || !v113;
3718 switch (PID_TYPE(a1)) {
3751 int bmodel_id = a1 >> 9;
3752 int face_id = v17 & 0x3F;
3756 if (
pOutdoor->
pBModels[bmodel_id].pFaces[face_id].uAttributes & FACE_HAS_EVENT ||
3814 signed int direction1;
3815 signed int direction2;
3820 if (pNumVertices <= 1)
return false;
3835 for (
uint i = 1; i < pNumVertices; ++i) {
3843 if (max_y == min_y)
return false;
3848 current_ID = min_y_ID;
3849 min_y_ID2 = min_y_ID;
3851 for (
uint i = 0; i < pNumVertices; ++i) {
3852 current_ID += direction2;
3853 if (current_ID < pNumVertices) {
3854 if (current_ID < 0) current_ID += pNumVertices;
3856 current_ID -= pNumVertices;
3860 min_y_ID2 = current_ID;
3861 min_y_ID = current_ID;
3866 v13 = min_y_ID2 + direction2;
3867 if (v13 < pNumVertices) {
3868 if (v13 < 0) v13 += pNumVertices;
3870 v13 -= pNumVertices;
3887 for (v69 = 0; v69 < pNumVertices; ++v69) {
3889 if (v15 < pNumVertices) {
3890 if (v15 < 0) v15 += pNumVertices;
3892 v15 -= pNumVertices;
3901 v18 = direction1 + v61;
3902 if (v18 < pNumVertices) {
3903 if (v18 < 0) v18 += pNumVertices;
3905 v18 -= pNumVertices;
3920 if (min_y <= max_y) {
3921 for (v70 = min_y; v70 <= max_y; ++v70) {
3924 v13 = direction2 + v13;
3925 if (v13 < pNumVertices) {
3926 if (v13 < 0) v13 += pNumVertices;
3928 v13 -= pNumVertices;
3945 if (v18 < pNumVertices) {
3946 if (v18 < 0) v18 += pNumVertices;
3948 v18 -= pNumVertices;
3982 if (max_y < near_portal->_viewport_space_y)
return false;
3984 if (min_y < near_portal->_viewport_space_y)
3988 if (min_y <= max_y) {
3989 for (min_y; min_y <= max_y; ++min_y) {
3997 if (max_y < min_y)
return false;
3998 for (max_y; max_y >= min_y; --max_y) {
4005 if (min_y >= max_y)
return false;
4008 for (v46 = max_y - min_y + 1; v46; --v46) {
4027 for (v49; v49 <= max_y; ++v49) {
4051 int left_num_vertices;
4052 int right_num_vertices;
4053 int top_num_vertices;
4054 int bottom_num_vertices;
4055 bool current_vertices_flag;
4056 int depth_num_vertices;
4057 bool next_vertices_flag;
4079 if (!(pFace->
Portal()))
return 0;
4108 bool bFound =
false;
4116 if (!bFound)
return 0;
4132 depth_num_vertices = 0;
4139 current_vertices_flag =
4145 if (current_vertices_flag ^
4146 next_vertices_flag) {
4149 if (next_vertices_flag) {
4191 assert(_t._internal ==
t);
4192 assert(_x._internal ==
4194 assert(_y._internal ==
4196 assert(_z._internal ==
4248 depth_num_vertices++;
4250 if (next_vertices_flag) {
4252 pNextVertices = depth_num_vertices++;
4260 current_vertices_flag = next_vertices_flag;
4273 for (
uint i = 0; i < depth_num_vertices; ++i) {
4281 pScreenX = 0x400000;
4283 pScreenX = 0xFFC00000;
4286 pScreenX = 0xFFC00000;
4288 pScreenX = 0x400000;
4299 pScreenY = 0x400000;
4301 pScreenY = 0xFFC00000;
4304 pScreenY = 0xFFC00000;
4306 pScreenY = 0x400000;
4343 left_num_vertices = 0;
4350 if (depth_num_vertices < 1)
return 0;
4351 for (
uint i = 1; i <= depth_num_vertices; ++i) {
4354 if (current_vertices_flag ^ next_vertices_flag) {
4355 if (next_vertices_flag) {
4417 left_num_vertices++;
4419 if (next_vertices_flag) {
4420 pNextVertices = left_num_vertices++;
4426 current_vertices_flag = next_vertices_flag;
4430 right_num_vertices = 0;
4437 if (left_num_vertices < 1)
return 0;
4438 for (
uint i = 1; i <= left_num_vertices; ++i) {
4441 if (current_vertices_flag ^ next_vertices_flag) {
4442 if (next_vertices_flag) {
4473 right_num_vertices++;
4475 if (next_vertices_flag) {
4476 pNextVertices = right_num_vertices++;
4482 current_vertices_flag = next_vertices_flag;
4486 top_num_vertices = 0;
4494 if (right_num_vertices < 1)
return 0;
4495 for (
uint i = 1; i <= right_num_vertices; ++i) {
4498 if (current_vertices_flag ^ next_vertices_flag) {
4499 if (next_vertices_flag) {
4527 current_vertices_flag = next_vertices_flag;
4528 if (next_vertices_flag) {
4529 pNextVertices = top_num_vertices++;
4538 bottom_num_vertices = 0;
4545 if (top_num_vertices < 1)
return 0;
4546 for (
uint i = 1; i <= top_num_vertices; ++i) {
4549 if (current_vertices_flag ^ next_vertices_flag) {
4550 if (next_vertices_flag) {
4575 bottom_num_vertices++;
4577 if (next_vertices_flag) {
4578 pNextVertices = bottom_num_vertices++;
4584 current_vertices_flag = next_vertices_flag;
4588 if (!bottom_num_vertices)
return 0;
4651 return bottom_num_vertices;
4668 unsigned int uFaceEvent;
4669 bool party_running_flag;
4671 unsigned int uSectorID;
4672 bool party_walking_flag;
4673 unsigned int uFaceID;
4692 party_running_flag =
false;
4693 party_walking_flag =
false;
4699 &uSectorID, &uFaceID);
4709 if (floor_level == -30000 || uFaceID == -1) {
4711 new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
4712 if (floor_level == -30000 || uFaceID == -1) {
4726 static int dword_720CDC = 0;
4729 if (dword_720CDC != v67) {
4773 fall_start = floor_level;
4774 bFeatherFall =
true;
4777 bFeatherFall =
false;
4781 if (fall_start - party_z > 512 && !bFeatherFall &&
4782 party_z <= floor_level + 1) {
4787 for (
uint i = 0; i < 4; ++i) {
4797 .GetActualEndurance())) *
4805 if (party_z > floor_level + 1) hovering =
true;
4807 bool not_high_fall =
false;
4809 if (party_z - floor_level <= 32) {
4811 not_high_fall =
true;
4821 if (party_z <= floor_level + 1) {
4822 party_z = floor_level + 1;
4834 bool on_water =
false;
4843 (
signed __int64)((
signed int)(
pParty
4844 ->y_rotation_speed *
4852 if (
engine->config->turn_speed > 0)
4858 if (
engine->config->turn_speed > 0)
4865 if (
engine->config->turn_speed > 0)
4872 if (
engine->config->turn_speed > 0)
4881 party_walking_flag =
true;
4886 party_walking_flag =
true;
4891 party_walking_flag =
true;
4896 party_walking_flag =
true;
4901 party_running_flag =
true;
4906 party_running_flag =
true;
4910 if (_view_angle > 128)
4917 if (_view_angle < -128)
4927 party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) &&
4944 for (
uint pl = 1; pl <= 4; pl++) {
4945 if (!
pPlayers[pl]->HasEnchantedItemEquipped(72) &&
4977 for (
uint i = 0; i < 100; i++) {
4978 new_party_z = party_z;
4997 for (
uint j = 0; j < 100; ++j) {
5000 for (v80 = 0; v80 < (
signed int)
uNumActors; ++v80)
5020 if (v42 == -30000 || v42 - new_party_z > 128)
return;
5034 unsigned long long v87 =
5139 if (party_running_flag &&
5140 (!hovering || not_high_fall)) {
5141 if (
integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 16) {
5150 }
else if (party_walking_flag &&
5151 (!hovering || not_high_fall)) {
5153 if (
integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 8) {
5168 if (!hovering || !not_high_fall)
5188 for (door_id = 0; door_id < 200; ++door_id) {
5191 if (door_id >= 200) {
5192 Error(
"Unable to find Door ID: %i!", uDoorID);
5252 if (a2 != 1)
return;
5314 unsigned int uFaceID;
5321 if ((
pActors[mon_id].pMonsterInfo.uID < 121 ||
5322 pActors[mon_id].pMonsterInfo.uID > 123) &&
5323 (
pActors[mon_id].pMonsterInfo.uID < 124 ||
5324 pActors[mon_id].pMonsterInfo.uID > 126) &&
5325 (
pActors[mon_id].pMonsterInfo.uID < 133 ||
5326 pActors[mon_id].pMonsterInfo.uID > 135) &&
5331 for (face_id; face_id < 100; ++face_id) {
5332 v6 = rand() % 1024 + 512;
5338 bool bInWater =
false;
5342 0, &bInWater, &v27, 0);
5353 v11 = face_id == 100;
5357 v11 = face_id == 100;
5362 for (
uint i = 0; i < 100; ++i) {
5363 v12 = rand() % 512 + 256;
5377 if (v18 != -30000) {
5421 return a1.
Create(0, 0, 0, 0);
5431 std::array<int, 52> dword_4F5CC8_ys;
5432 std::array<int, 52> dword_4F5D98_xs;
5434 if (
face->uAttributes & FACE_XY_PLANE) {
5437 for (
int i = 0; i <
face->uNumVertices; i++) {
5443 if (
face->uAttributes & FACE_XZ_PLANE) {
5445 for (
int i = 0; i <
face->uNumVertices; i++) {
5451 for (
int i = 0; i <
face->uNumVertices; i++) {
5458 dword_4F5D98_xs[
face->uNumVertices] = dword_4F5D98_xs[0];
5459 dword_4F5CC8_ys[
face->uNumVertices] = dword_4F5CC8_ys[0];
5460 for (
int i = 0; i <
face->uNumVertices && a3a < 2; i++) {
5461 if ((dword_4F5CC8_ys[i] >= v8) ^ (dword_4F5CC8_ys[i + 1] >= v8)) {
5463 if (!(dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] < a4a)) {
5464 if ((dword_4F5D98_xs[i + 1] < a4a && dword_4F5D98_xs[i] >= a4a)) {
5473 v25 =
fixpoint_div(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i],
5474 dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]);
5475 if (dword_4F5D98_xs[i] + (
fixpoint_mul(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 0x8000 >> 16) >= a4a)
5482 if (a3a != 1)
result = 0;
5490 std::array<int, 52> dword_4F5B24_ys;
5491 std::array<int, 52> dword_4F5BF4_xs;
5495 if (
face->uAttributes & FACE_XY_PLANE) {
5498 for (
int i = 0; i <
face->uNumVertices; i++) {
5499 dword_4F5BF4_xs[i + 1] = a5->
pVertices[
face->pVertexIDs[i]].x;
5500 dword_4F5B24_ys[i + 1] = a5->
pVertices[
face->pVertexIDs[i]].y;
5503 if (
face->uAttributes & FACE_XY_PLANE) {
5505 for (
int i = 0; i <
face->uNumVertices; i++) {
5506 dword_4F5BF4_xs[i + 1] = a5->
pVertices[
face->pVertexIDs[i]].x;
5507 dword_4F5B24_ys[i + 1] = a5->
pVertices[
face->pVertexIDs[i]].z;
5511 for (
int i = 0; i <
face->uNumVertices; i++) {
5512 dword_4F5BF4_xs[i + 1] = a5->
pVertices[
face->pVertexIDs[i]].y;
5513 dword_4F5B24_ys[i + 1] = a5->
pVertices[
face->pVertexIDs[i]].z;
5518 dword_4F5BF4_xs[
face->uNumVertices + 1] = dword_4F5BF4_xs[1];
5519 dword_4F5B24_ys[
face->uNumVertices + 1] = dword_4F5B24_ys[1];
5520 for (
int i = 0; i <
face->uNumVertices; i++) {
5521 if (a5a >= 2)
break;
5522 if ((dword_4F5B24_ys[i + 1] >= a3) ^ (dword_4F5B24_ys[i + 2] >= a3)) {
5523 if (dword_4F5BF4_xs[i + 2] >= a4a || dword_4F5BF4_xs[i] >= a4a) {
5524 if (dword_4F5BF4_xs[i + 2] >= a4a &&
5525 dword_4F5BF4_xs[i + 1] >= a4a) {
5531 dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1];
5532 __int64 _b = (__int64)(a3 - dword_4F5B24_ys[i + 1]) << 16;
5534 if (dword_4F5BF4_xs[i + 1] +
5535 ((((((__int64)(dword_4F5BF4_xs[i + 2] -
5536 dword_4F5BF4_xs[i + 1])
5549 if (a5a != 1)
return false;
5558 OutPlaneNorm.
x = 0.0;
5559 OutPlaneNorm.
y = 0.0;
5560 OutPlaneNorm.
z = 0.0;
5579 if (fabsf(pNormal->
z) < 1e-6
f)
5581 else if (fabsf(pNormal->
x) < 1e-6
f && fabsf(pNormal->
y) < 1e-6
f)
5627 if (v38.
x != 0.0 || v38.
y != 0.0 || v38.
z != 0.0) {
5630 pOutNormal->
x = v38.
x;
5631 pOutNormal->
y = v38.
y;
5632 pOutNormal->
z = v38.
z;
5649 *pOutDist = (double)(pFace->
pFacePlane.
dist & 0xFFFF) / 65535.0f +
5668 unsigned int *pSectorID,
5669 unsigned int *pFaceID) {
5674 if (
result == -30000 || !*pSectorID) {
5677 if (
result == -30000 || !*pSectorID) {
5681 if (
result == -30000 || !*pSectorID) {
5685 if (
result == -30000 || !*pSectorID) {
5706 this->velocity.y * this->velocity.y +
5707 this->velocity.x * this->velocity.x);
5713 this->speed =
speed;
5749 v18 = this->prolly_normal_d + this->
normal.x;
5750 if (this->
normal.x <= this->normal2.x)
5751 v18 = this->prolly_normal_d + this->
normal2.x;
5758 v22 = this->prolly_normal_d + this->
normal.y;
5759 if (this->
normal.y <= this->normal2.y)
5764 if (this->
normal.z >= this->normal2.z)