1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
4#include "editground.hpp"
12#include "editarea.hpp"
15#include "framevu1.hpp"
19#include "objanime.hpp"
48 if (parts_no < 0 || parts_no >= 24) {
69 slot = &area_list[area_no];
72 if (source->
info == NULL) {
76 placeable = area->
CheckParts(source, x, y, z, rot_y);
84 parts_id = (*slot)->SearchPartsID(x, y, z);
86 if (parts_id >= 0 && CheckDelete(area, source, x, y, z) == 0) {
88 target = &
parts[parts_id];
105 if (placeable == 0) {
125 for (parts_id = 0; parts_id < 128; target++, parts_id++) {
131 if (parts_id == 128) {
140 for (i = 0; i < span[0]; i++) {
141 for (j = 0; j < span[1]; j++) {
142 float cell_x = x - (float) ((span[0] >> 1) - i) * area->
GetUnitSize();
143 float cell_z = z - (float) ((span[1] >> 1) - j) * area->
GetUnitSize();
146 DeleteMapParts(&deleted_parts_no, &deleted_rot_y, cell_x, y, cell_z);
152 memcpy(target, source,
sizeof(
CMapParts));
154 (*slot)->GetGrid(&grid, x, y, z);
158 if (width % 2 == 1) {
159 grid.
x += 0.5f * (*slot)->GetUnitSize();
162 if (height % 2 == 1) {
163 grid.
z += 0.5f * (*slot)->GetUnitSize();
166 grid.
y = (*slot)->GetAlt(grid.
x, grid.
y, grid.
z);
167 target->
unit_size = (*slot)->GetUnitSize();
168 sceVu0FVECTOR position = {0.0f, 0.0f, 0.0f, 1.0f};
169 position[0] = grid.
x;
170 position[1] = grid.
y;
171 position[2] = grid.
z;
174 target->
area = area_no;
175 (*slot)->SetMapParts(parts_id,
parts, x, y, z, rot_y);
233 int deleted_parts_no;
243 area->
GetPos(&cell, x, y, z);
244 cell.
x += column_step;
260 area->
GetPos(&position, cell.
x, cell.
y, cell.
z);
261 DeleteMapParts(&deleted_parts_no, &deleted_rot_y, position.
x + 1.0f, position.
y, position.
z + 1.0f);
270 int piece = (code & 0xFF0) >> 4;
271 int rot_y = code & 0xF;
273 if (piece - 1 < 0 || piece - 1 >= 16) {
281 for (
int i = 0; i < 4; i++) {
284 object->SetFrame(frame, i);
288 object->shadow_frame = GetShadowFrame(&
river_parts[(u32) (piece - 1)]);
289 object->shade_frame = GetShadeFrame(&
river_parts[(u32) (piece - 1)]);
290 object->camera_frame = GetCameraFrame(&
river_parts[(u32) (piece - 1)]);
291 object->ripple_frame = GetRippleFrame(&
river_parts[(u32) (piece - 1)]);
295 object->SetRotY(rot_y);
309 area->
GetPos(&cell, x, y, z);
310 cell.
x += column_step;
330 int piece = (code & 0xFF0) >> 4;
331 int rot_y = code & 0xF;
333 if (piece - 1 < 0 || piece - 1 >= 6) {
341 for (
int i = 0; i < 4; i++) {
344 object->SetFrame(frame, i);
348 object->SetRotY(rot_y);
371 if (CheckDelete(area, target, x, y, z) != 0) {
377 sceVu0FVECTOR position;
381 *out_parts_no = plot;
414 sceVu0FVECTOR position;
416 area->
DeleteMapParts(parts_id,
parts, (
float) (1.0f + position[0]), position[1], (
float) (1.0f + position[2]));
426 SetRoadParts(position[0], position[1], position[2], 1, 0);
427 SetRoadParts(position[0], position[1], position[2], 0, 1);
428 SetRoadParts(position[0], position[1], position[2], -1, 0);
429 SetRoadParts(position[0], position[1], position[2], 0, -1);
440 for (
int i = 0; i < 4; i++) {
441 if (
areas[i] == NULL) {
445 if (
areas[i]->CheckArea(x, y, z)) {
476 for (
int i = 0; i < 128; i++,
object++) {
502 return &
parts[parts_id];
510 sceVu0FVECTOR position;
512 if (parts_id < 0 || parts_id >= 128) {
524 position[1] += 50.0f;
531 sceVu0FVECTOR position;
532 int stop = effect_parts_id < 0 || effect_parts_id >= 128;
570 if (CheckDelete(area, focus, x, y, z)) {
581static inline float Magnitude(
float value) {
582 return value < 0.0f ? -value : value;
587 sceVu0FVECTOR eye = {0.0f, 0.0f, 0.0f, 0.0f};
590 sceVu0FVECTOR forward;
593 sceVu0FVECTOR to_center;
594 sceVu0FVECTOR center;
595 sceVu0FVECTOR corner_a;
596 sceVu0FVECTOR corner_b;
597 sceVu0FVECTOR corner_max;
598 sceVu0FVECTOR corner_min;
602 if (camera != NULL) {
605 sceVu0SubVector(dir, ref, eye);
608 sceVu0SubVector(forward, ref, eye);
610 sceVu0Normalize(forward, forward);
611 sceVu0ScaleVector(forward, forward, 500.0f);
612 sceVu0AddVector(ref, eye, forward);
615 sceVu0CopyVector(eye, ref);
616 sceVu0CopyVector(dir, ref);
621 for (i = 0; i < 4; i++) {
631 sceVu0CopyVector(box.
max, box.
min);
638 if (MGClipBox(&box)) {
644 sceVu0AddVector(center, box.
max, box.
min);
645 sceVu0ScaleVector(center, center, 0.5f);
646 sceVu0SubVector(to_center, center, eye);
647 dots[i] = sceVu0InnerProduct(to_center, dir);
649 if (dots[i] > 0.0f) {
654 sceVu0CopyVector(corner_max, box.
max);
655 corner_max[1] = 0.0f;
656 sceVu0CopyVector(corner_min, box.
min);
657 corner_min[1] = 0.0f;
658 corner_a[0] = box.
max[0];
660 corner_a[2] = box.
min[2];
661 corner_b[0] = box.
min[0];
663 corner_b[2] = box.
max[2];
667 if (ref[0] < box.
min[0]) {
671 if (ref[0] > box.
max[0]) {
675 if (ref[2] < box.
min[2]) {
679 if (ref[2] > box.
max[2]) {
685 if (side_x < 0 && side_z < 0) {
686 dists[i] = DistVector(ref, corner_min);
687 }
else if (side_x == 0 && side_z < 0) {
688 gap = ref[2] - corner_min[2];
689 dists[i] = gap < 0.0f ? -gap : gap;
690 }
else if (side_x > 0 && side_z < 0) {
691 dists[i] = DistVector(ref, corner_a);
692 }
else if (side_x < 0 && side_z == 0) {
693 gap = ref[0] - corner_min[0];
694 dists[i] = gap < 0.0f ? -gap : gap;
695 }
else if (side_x == 0 && side_z == 0) {
697 }
else if (side_x > 0 && side_z == 0) {
698 gap = ref[0] - corner_max[0];
699 dists[i] = gap < 0.0f ? -gap : gap;
700 }
else if (side_x < 0 && side_z > 0) {
701 dists[i] = DistVector(ref, corner_b);
702 }
else if (side_x == 0 && side_z > 0) {
703 gap = ref[2] - corner_max[2];
704 dists[i] = gap < 0.0f ? -gap : gap;
705 }
else if (side_x > 0 && side_z > 0) {
706 dists[i] = DistVector(ref, corner_max);
709 if (range > 0.0f && dists[i] > range) {
720 int nearest_dist = -1;
722 for (
int j = 0; j < 4; j++) {
723 if (
areas[j] == NULL) {
731 if (dists[j] < 0.0f) {
737 nearest_dist = dists[j];
738 }
else if (nearest_dist > dists[j]) {
740 nearest_dist = dists[j];
746 if (dists[0] > dists[2]) {
771 for (
int k = 0; k < 4; k++) {
772 if (
areas[k] == NULL) {
782 if (dists[k] > 0.0f && dists[k] < 600.0f) {
793 sceVu0FVECTOR position;
803 if (
areas[x] == NULL) {
810 if (area_count == 0) {
814 for (area_no = 0; area_no < area_count; area_no++) {
819 for (x = 2; x < width - 2; x++) {
820 for (z = 2; z < height - 2; z++) {
827 position[0] = grid.
x;
829 position[2] = grid.
z;
831 if (!(bounds[3] <= 0.0f) && !(DistVector(bounds, position) <= bounds[3])) {
835 for (
int i = 0; i < avoid_count; i++) {
836 float distance = DistVector(avoid[i], position);
838 if (distance < avoid[i][3]) {
849 cells[found++] = (area_no << 16) | (x | (z << 8));
859 int cell = cells[rand() % found];
860 int column = cell & 0xFF;
861 int row = (cell >> 8) & 0xFF;
862 area_no = (cell >> 16) & 0xFF;
875 for (i = 0; i < 128; i++,
object++) {
884 if (count >= limit) {
888 *out_parts++ = object;
892 if (fixed_box == NULL) {
896 for (i = 0; i < 64; i++) {
907 if (count >= limit) {
911 *out_parts++ = fixed;
919 for (
int i = 0; i < 4; i++) {
920 if (
areas[i] != NULL) {
930 out_box->
max[0] = out_box->
max[1] = out_box->
max[2] = 0.0f;
931 out_box->
max[3] = 1.0f;
932 out_box->
min[0] = out_box->
min[1] = out_box->
min[2] = 0.0f;
933 out_box->
min[3] = 1.0f;
937 if (
areas[area_no] != NULL) {
943 sceVu0FVECTOR transform;
944 sceVu0FVECTOR frame_rotation;
949 if (marker->
kind != EPARTS_FUNC_VILLAGER || marker->
link_id != villager) {
963 sceVu0CopyVector(out_position, marker->
position);
971 frame->SetPosition(transform);
973 frame->SetRotation(transform[0], transform[1], transform[2]);
974 out_position[3] = 1.0f;
975 frame->GetWorldPosition(out_position, out_position);
976 frame->GetRotation(frame_rotation);
977 out_position[3] = AngleLimit(frame_rotation[1] + marker->
rotation[1]);
985 for (
int i = 0; i < 4; i++) {
986 if (
areas[i] == NULL) {
994void CEditGround::Draw(
float time,
int pass,
int lowest,
int highest,
int fixed_lowest,
int fixed_highest) {
995 sceVu0FVECTOR lod_distance = {50.0f, 300.0f, 500.0f, 800.0f};
996 sceVu0FVECTOR position;
997 sceVu0FVECTOR ambient;
1000 for (i = 0; i < 64; i++) {
1008 for (i = 0; i < 128; i++,
object++) {
1013 if (object->
handle < 0) {
1029 sceVu0FVECTOR focus_ambient = {32.0f, 32.0f, 128.0f, 128.0f};
1030 MGGetAmbient(ambient);
1033 MGSetAmbient(focus_ambient);
1036 object->DrawParts(time, lod_distance, lowest, highest, NULL);
1037 MGSetAmbient(ambient);
1046 for (i = 0; i < 4; i++, surface++) {
1047 if (surface->
draw == 0) {
1055 for (j = 0; j < 4; j++) {
1065 row = rows * (float) rand() / 2.1474836e9f;
1070 column = rows * (float) rand() / 2.1474836e9f;
1076 surface->
water.Hamon();
1082 sceVu0FVECTOR position;
1084 sceVu0FVECTOR parts_position;
1091 sceVu0Normalize(dir, dir);
1093 for (i = 0; i < 4; i++, surface++) {
1094 if (surface->
draw == 0) {
1099 sceVu0CopyVector(position, surface->
offset);
1104 if (owner == NULL) {
1110 if (frame != NULL && surface->
name[0] !=
'\0') {
1111 frame = frame->SearchFrame(surface->
name);
1113 if (frame != NULL && !(frame->
attr.
draw_on & 1)) {
1124 sceVu0AddVector(position, position, parts_position);
1125 water->
frame.SetPosition(position);
1127 water->
frame.SetRotation(parts_position[0], parts_position[1], parts_position[2]);
1129 if (surface->
follow[0]) {
1130 position[0] = eye[0] + 50.0f * dir[0];
1133 if (surface->
follow[1]) {
1134 position[1] = eye[1];
1137 if (surface->
follow[2]) {
1138 position[2] = eye[2] + 50.0f * dir[2];
1142 rotation.
z = rotation.
y = rotation.
x = 0.0f;
1143 water->
frame.SetRotation(rotation.
x, rotation.
y, rotation.
z);
1144 water->
frame.SetPosition(position);
1147 DrawVu1__6CWaterFP10RenderInfoP13sceVif1PacketP1(water, &mgRenderInfo, GetVif1Packet(), NULL);
1152 sceVu0FVECTOR position;
1153 sceVu0FVECTOR corner;
1157 for (i = 0; i < 128; i++,
object++) {
1162 if (object->
handle < 0) {
1181 if (object->
area < 0) {
1194 position[0] += 0.5f * size;
1195 position[2] += 0.5f * size;
1198 sceVu0CopyVector(corner, position);
1199 corner[0] = position[0] - size;
1202 corner[2] = position[2] - size;
1205 corner[0] = position[0];
1212 for (
int j = 0; j < 64; j++) {
1220 sceVu0FVECTOR transform;
1221 sceVu0FVECTOR position;
1225 for (i = 0; i < 128; i++,
object++) {
1230 if (object->
handle < 0) {
1258 object->GetPosition(transform);
1259 object->ripple_frame->SetPosition(transform);
1260 object->SetRotY(object->
GetRotY());
1261 object->GetRotation(transform);
1262 object->ripple_frame->SetRotation(transform[0], transform[1], transform[2]);
1266 for (
int j = 0; j < 64; j++) {
1288 sceVu0FVECTOR position;
1290 sceVu0FVECTOR clip_position;
1295 if (near_distance < 1.0f) {
1296 near_distance = -10000000;
1301 for (i = 0; i < 128; i++,
object++) {
1306 if (object->
handle < 0) {
1322 object->GetPosition(position);
1324 sceVu0ApplyMatrix(view, mgRenderInfo.
view_scaled, position);
1330 if (view[2] > near_distance && view[2] < far_distance) {
1331 object->DrawShade();
1336 if (view[2] > 300.0f) {
1340 object->DrawShadow(fast);
1345 for (
int j = 0; j < 64; j++) {
1356 sceVu0CopyVector(position, fixed->
pos);
1358 sceVu0ApplyMatrix(view, mgRenderInfo.
view_scaled, position);
1360 if (view[2] > near_distance && view[2] < far_distance) {
1366 if (view[2] > 300.0f) {
1370 fixed->DrawShadow(fast);
1377 static int old_parts = -1;
1380 sceVu0FMATRIX light_direction;
1381 sceVu0FMATRIX light_colour;
1382 sceVu0FVECTOR ambient;
1397 if (plot < 0 || plot >= 24) {
1398 sceVu0CopyVector(model_pos, position);
1402 area_code =
GetAreaCode(position[0], position[1], position[2]);
1404 if (area_code < 0) {
1405 sceVu0CopyVector(model_pos, position);
1409 area =
areas[area_code];
1414 if (area->
CheckAreaRect(position[0], position[1], position[2], width, height) == 0) {
1415 sceVu0CopyVector(model_pos, position);
1419 area->
GetPos(&grid, position[0], position[1], position[2]);
1420 fits = area->
CheckParts(source, position[0], position[1], position[2], rot_y);
1421 occupant = area->
SearchPartsID(position[0], position[1], position[2]);
1424 if (CheckDelete(area, source, position[0], position[1], position[2]) != 0) {
1428 if (occupant >= 0 &&
parts[occupant].handle != 1) {
1441 area->
GetPos(&cell, grid.
x, grid.
y, grid.
z);
1442 position[0] = cell.
x;
1443 position[1] = 5.0f + cell.
y;
1444 position[2] = cell.
z;
1448 if (width % 2 == 1) {
1452 if (height % 2 == 1) {
1458 MGGetAmbient(ambient);
1459 MGGetPLight(light_direction, light_colour);
1460 sceVu0FVECTOR dim = {60.0f, 60.0f, 60.0f, 128.0f};
1462 MGSetPLight(mgZeroMatrix, mgZeroMatrix);
1472 MGSetAmbient(ambient);
1473 MGSetPLight(light_direction, light_colour);
1476 position[1] += 50.0f;
1478 sceVu0CopyVector(goal, position);
1479 step = goal[0] - model_pos[0];
1481 if (Magnitude(step) < 1.0f) {
1482 model_pos[0] = goal[0];
1484 model_pos[0] += step / 8.0f;
1487 step = goal[1] - model_pos[1];
1489 if (Magnitude(step) < 1.0f) {
1490 model_pos[1] = goal[1];
1492 model_pos[1] += step / 8.0f;
1495 step = goal[2] - model_pos[2];
1497 if (Magnitude(step) < 1.0f) {
1498 model_pos[2] = goal[2];
1500 model_pos[2] += step / 8.0f;
1510 model = preview->SearchFrame(
"kawa");
1512 if (model != NULL) {
1517 if (occupant >= 0) {
1523 float *angle = rotation;
1524 preview->SetPosition(model_pos);
1525 preview->SetRotation(angle[0], angle[1], angle[2]);
1528 if (model != NULL) {
1536 sceVu0FVECTOR position;
1540 for (i = 0; i < 128; i++,
object++) {
1553 object->DrawEffect(camera, time, effects);
1556 for (i = 0; i < 64; i++) {
1563 sceVu0FVECTOR position;
1570 for (
int i = 0; i < 128; i++) {
1579 int kind =
object->subtype;
1582 for (j = 0; j < 24; j++) {
1590 object->GetPosition(position);
1592 record->
rot_y =
object->rot_y;
1593 record->
pos_x = position[0];
1594 record->
pos_y = position[1];
1595 record->
pos_z = position[2];
1602 record->
pos_x = 0.0f;
1603 record->
pos_y = 0.0f;
1604 record->
pos_z = 0.0f;
1605 header->
size = (
char *) (record + 1) - buffer;
1606 WriteFile(
"host0:y:/ps2/dc_data/gdata0.edt", buffer, header->
size);
1621 if (!LoadFile2(
"gdata0.edt", file, NULL, 0)) {
1634 for (i = 0; i < header->
count; i++, record++) {
1635 int parts_id = record->
part_id;
1637 if (parts_id < 0 || parts_id >= 24) {
1642 float x = record->
pos_x + 1.0f;
1643 float z = record->
pos_z + 1.0f;
1650 for (i = 0; i < header->
count; i++, record++) {
1651 int parts_id = record->
part_id;
1653 if (parts_id < 0 || parts_id >= 24) {
1660 for (
int j = 0; j < 24; j++) {
1673 for (i = 0; i < header->
count; i++, record++) {
1674 int parts_id = record->
part_id;
1676 if (parts_id < 0 || parts_id >= 24) {
1688 for (i = 0; i < 4; i++) {
1689 if (
areas[i] != NULL) {
1697 sceVu0FVECTOR position;
1703 if (record == NULL) {
1707 for (i = 0; i < 128; i++) {
1716 int kind =
object->subtype;
1722 for (j = 0; j < 24; j++) {
1732 object->GetPosition(position);
1734 record->
rot_y =
object->rot_y;
1735 record->
pos_x = position[0];
1736 record->
pos_y = position[1];
1737 record->
pos_z = position[2];
1743 record->
pos_x = 0.0f;
1744 record->
pos_y = 0.0f;
1745 record->
pos_z = 0.0f;
1749 char buffer[0x5000];
1756 if (saved == NULL) {
1760 header->
count = count;
1763 for (
int i = 0; i < count; saved++, record++, i++) {
1779 box.
max[0] = x + 30.0f;
1780 box.
min[0] = x - 30.0f;
1781 box.
max[2] = z + 30.0f;
1782 box.
min[2] = z - 30.0f;
1783 box.
max[1] = y + 100.0f;
1784 box.
min[1] = y - 100.0f;
1791 CCPoly *polygons = out_polygons;
1796 for (i = 0; i < 128; i++,
object++) {
1797 if (object->
handle < 0) {
1805 frame =
object->GetCollisionFrame();
1807 if (frame == NULL) {
1815 found = frame->PickUpNearPoly(polygons, box);
1820 for (i = 0; i < 64; i++) {
1828 if (frame == NULL) {
1836 found = frame->PickUpNearPoly(polygons, box);
1841 for (i = 0; i < 4; i++) {
1842 if (
areas[i] != NULL) {
1865 CCPoly *polygons = out_polygons;
1869 sceVu0FVECTOR center;
1871 for (i = 0; i < 128 && (flags & 2); i++,
object++) {
1872 if (object->
handle < 0) {
1876 frame = GetCameraFrame(
object);
1878 if (frame == NULL) {
1886 found = frame->PickUpNearPoly(polygons, box);
1891 for (i = 0; i < 64 && (flags & 1); i++) {
1898 if (frame == NULL) {
1906 found = frame->PickUpNearPoly(polygons, box);
1911 for (i = 0; i < 4; i++) {
1912 if (
areas[i] != NULL) {
1913 sceVu0AddVector(center, box.
max, box.
min);
1914 sceVu0ScaleVector(center, center, 0.5f);
1915 count +=
areas[i]->
PickUpPoly(polygons, center[0], center[1], center[2]);
1925 for (i = 0; i < 128; i++) {
1929 for (i = 0; i < 4; i++) {
1930 if (
areas[i] != NULL) {
1947 if (
map_no == TOWN_MATATAKI) {
1979 for (
int area = 0; area < 4; area++) {
1986 for (i = 0; i < 64; i++) {
1990 for (i = 0; i < 1; i++) {
1994 for (i = 0; i < 4; i++) {
1998 for (i = 0; i < 128; i++) {
2009 for (
int i = 0; i < 4; i++) {
2010 if (
areas[i] != NULL) {
2032static int CheckDelete(
CEditArea *area,
CMapParts *parts,
float x,
float y,
float z) {
2035 area->
GetPos(&position, x, y, z);
2036 int column = position.
x;
2037 int row = position.
z;
2048 if (column == 5 && row == 0) {
2052 if (column == 2 && row == 7) {
2058 if (column == 3 && row == 5) {
2062 if (column == 11 && row == 3) {
2068 if (column == 4 && row == 0) {
2072 if (column == 3 && row == 7) {
2087 sceVu0FVECTOR corner;
2090 int columns = width * 2;
2091 int rows = height * 2;
2093 sceVu0CopyVector(corner, position);
2094 corner[0] -= 0.5f * (
unit_size * width);
2095 corner[2] -= 0.5f * (
unit_size * height);
2098 sceVu0CopyVector(cell, corner);
2100 for (i = 0; i < columns; i++) {
2101 cell[2] = corner[2];
2103 for (j = 0; j < rows; j++) {
2107 if (i == 0 && j == 0) {
2111 if (i > 0 && i < columns - 1 && j == 0) {
2116 if (i == columns - 1 && j == 0) {
2121 if (i == columns - 1 && j > 0 && j < rows - 1) {
2126 if (i == columns - 1 && j == rows - 1) {
2131 if (i > 0 && i < columns - 1 && j == rows - 1) {
2136 if (i == 0 && j == rows - 1) {
2141 if (i == 0 && j > 0 && j < rows - 1) {
2146 pieces[piece]->SetPosition(cell);
2147 pieces[piece]->SetRotation(0.0f, HALF_PI * turn, 0.0f);
2149 pieces[piece]->SetScale(scale, scale, scale);
2163 memset(placed, 0,
sizeof(placed));
2166 for (i = 0; i < 24; i++) {
2171 for (i = 0; i < 128; i++,
object++) {
2172 if (object->
handle >= 0) {
2173 int plot =
object->parts_no;
2175 if (plot >= 0 && plot < 24) {
2176 placed[plot][plot_count[plot]++] = object;
2191 case TOWN_MUSKA_LACKA:
2194 case TOWN_YELLOW_DROPS:
2199 for (i = 0; i < 24; i++) {
2209 if (area_no < 0 || area_no >= 4) {
2213 if (
areas[area_no] == NULL) {
2219 for (
int i = 0; i < count; i++) {
2220 if (
parts[parts_ids[i]].parts_no == parts_no) {
2229 sceVu0FVECTOR position;
2234 if (target == NULL) {
2239 int area_no =
GetAreaCode(position[0], position[1], position[2]);
2241 if (area_no < 0 || area_no >= 4) {
2245 if (
areas[area_no] == NULL) {
2249 areas[area_no]->
GetPos(&grid, position[0], position[1], position[2]);
2252 int half_width = width >> 1;
2253 rect->
x = grid.
x - half_width - margin;
2254 int half_height = height >> 1;
2255 rect->
y = grid.
z - half_height - margin;
2256 rect->
width = width + margin * 2;
2257 rect->
height = height + margin * 2;
2261 sceVu0FVECTOR position;
2271 if (target == NULL) {
2276 int area_no =
GetAreaCode(position[0], position[1], position[2]);
2278 if (area_no < 0 || area_no >= 4) {
2282 if (
areas[area_no] == NULL) {
2286 areas[area_no]->
GetPos(&grid, position[0], position[1], position[2]);
2292 column -= width >> 1;
2298 if (width % 2 == 1 && height % 2 == 0) {
2308 if (width % 2 == 0 && height % 2 == 1) {
2318 if (width % 2 == 0 && height % 2 == 0) {
2352 rect->
x = grid.
x + offset_x + adjust_x;
2353 rect->
y = grid.
z + offset_z + adjust_z;
2361static inline int SpanStart(
int ¢re,
int size) {
2362 int half = size >> 1;
2363 return centre - half;
2367 sceVu0FVECTOR position;
2372 if (target == NULL) {
2377 int area_no =
GetAreaCode(position[0], position[1], position[2]);
2379 if (area_no < 0 || area_no >= 4) {
2383 if (
areas[area_no] == NULL) {
2387 areas[area_no]->
GetPos(&grid, position[0], position[1], position[2]);
2390 direction += target->
GetRotY();
2392 if (direction > 2) {
2396 if (direction < -1) {
2400 if (direction < -1 || direction > 2) {
2404 if (direction % 2 != 0) {
2405 rect->
width = depth;
2408 if (direction == 1) {
2409 rect->
x = SpanStart(grid.
x, width) - rect->
width;
2410 rect->
y = SpanStart(grid.
z, height);
2412 rect->
x = width + SpanStart(grid.
x, width);
2413 rect->
y = SpanStart(grid.
z, height);
2416 rect->
width = width;
2419 if (direction == 0) {
2420 rect->
x = SpanStart(grid.
x, width);
2421 rect->
y = SpanStart(grid.
z, height) - rect->
height;
2423 rect->
x = SpanStart(grid.
x, width);
2424 rect->
y = height + SpanStart(grid.
z, height);
2432 if (
areas[0] == NULL) {
2436 if (placed[0][0] != NULL && placed[0][0]->GetRotY() == 1) {
2440 if (placed[1][0] != NULL) {
2446 if (placed[2][0] != NULL) {
2452 if (placed[3][0] != NULL) {
2462 if (placed[4][0] != NULL) {
2472 if (placed[5][0] != NULL) {
2482 if (placed[6][0] != NULL) {
2492 if (placed[7][0] != NULL) {
2500 for (
int i = 0; i < count; i++) {
2501 if (
parts[parts_ids[i]].parts_no < 7) {
2531 if (placed[0][0] != NULL) {
2541 if (placed[1][0] != NULL) {
2549 for (
int i = 0; i < count; i++) {
2550 if (
parts[parts_ids[i]].parts_no == 15) {
2561 if (placed[2][0] != NULL) {
2565 int area_no = placed[2][0]->area;
2580 if (placed[3][0] != NULL) {
2584 int area_no = placed[3][0]->area;
2591 if (placed[4][0] != NULL) {
2597 if (placed[5][0] != NULL) {
2598 sceVu0FVECTOR position;
2599 placed[5][0]->GetPosition(position);
2601 if (
GetAlt_i(position[0], position[1], position[2]) > 0) {
2606 if (placed[6][0] != NULL && placed[3][0] != NULL) {
2616 if (placed[7][0] != NULL) {
2617 sceVu0FVECTOR position;
2618 placed[7][0]->GetPosition(position);
2620 if (
GetAlt_i(position[0], position[1], position[2]) > 0) {
2625 if (placed[14][0] != NULL) {
2633 for (
int i = 0; i < count; i++) {
2636 if (parts_no == 16) {
2640 if (parts_no == 17) {
2644 if (parts_no == 11) {
2648 if (parts_no == 12) {
2652 if (parts_no == 13) {
2671 if (placed[0][0] != NULL) {
2681 if (placed[1][0] != NULL && placed[10][0] != NULL) {
2691 if (placed[2][0] != NULL && placed[8][0] != NULL) {
2701 if (placed[3][0] != NULL && placed[1][0] != NULL) {
2711 if (placed[4][0] != NULL) {
2712 if (placed[9][0] == NULL) {
2714 }
else if (placed[4][0]->area != placed[9][0]->area) {
2719 if (placed[5][0] != NULL && placed[5][0]->GetRotY() == 0) {
2723 if (placed[6][0] != NULL && placed[11][0] != NULL && placed[6][0]->GetRotY() == -1) {
2733 if (placed[7][0] != NULL && placed[7][0]->area == 0) {
2737 if (placed[8][0] != NULL) {
2747 if (placed[9][0] != NULL && placed[8][0] != NULL) {
2769 if (parts == NULL || other == NULL) {
2773 rotation = rotation_offset + parts->
GetRotY();
2774 other_rotation = other->
GetRotY();
2780 if (rotation < -1) {
2784 return rotation == other_rotation;
2790 if (
areas[0] == NULL) {
2794 if (placed[0][0] != NULL && placed[8][0] != NULL) {
2806 if (placed[1][0] != NULL && placed[10][0] != NULL) {
2811 if (
CheckPartsRect(10, 0, rect) && CheckRot(placed[1][0], placed[10][0], 1)) {
2816 if (placed[2][0] != NULL && placed[9][0] != NULL) {
2821 if (
CheckPartsRect(9, 0, rect) && CheckRot(placed[2][0], placed[9][0], 0)) {
2826 if (placed[3][0] != NULL && placed[9][0] != NULL) {
2833 dir_rect.
x = dir_rect.
y = dir_rect.
width = dir_rect.
height = 0;
2836 if (
CheckPartsRect(9, 0, dir_rect) && CheckRot(placed[3][0], placed[9][0], 2)) {
2842 if (placed[4][0] != NULL && placed[9][0] != NULL) {
2847 if (
CheckPartsRect(9, 0, rect) && CheckRot(placed[4][0], placed[9][0], 1)) {
2852 if (placed[5][0] != NULL && placed[10][0] != NULL) {
2857 if (
CheckPartsRect(10, 0, rect) && CheckRot(placed[5][0], placed[10][0], 0)) {
2862 if (placed[6][0] != NULL && placed[8][0] != NULL) {
2867 if (
CheckPartsRect(8, 0, rect) && CheckRot(placed[6][0], placed[8][0], 0) && placed[6][0]->GetRotY() == 1) {
2872 if (placed[7][0] != NULL && placed[8][0] != NULL) {
2877 if (
CheckPartsRect(8, 0, rect) && CheckRot(placed[7][0], placed[8][0], 2)) {
2882 if (placed[10][0] != NULL) {
2895 if (
areas[0] == NULL) {
2899 for (
int j = 0; j < 24; j++) {
2903 if (CheckRot(placed[0][0], placed[7][0], 0)) {
2916 if (CheckRot(placed[1][0], placed[5][0], 0)) {
2926 if (CheckRot(placed[2][0], placed[6][0], 0)) {
2936 if (CheckRot(placed[3][0], placed[7][0], 0)) {
2949 if (CheckRot(placed[4][0], placed[7][0], 0)) {
2962 if (CheckRot(placed[5][0], placed[3][0], 0)) {
2972 if (CheckRot(placed[6][0], placed[4][0], 0)) {
2982 if (placed[7][0] != NULL) {
2986 if (CheckRot(placed[8][0], placed[7][0], 0)) {
2999 if (CheckRot(placed[9][0], placed[8][0], 0)) {
3009 if (CheckRot(placed[10][0], placed[8][0], 0)) {
3019 if (CheckRot(placed[11][0], placed[9][0], 0)) {
3029 if (CheckRot(placed[12][0], placed[10][0], 0)) {
3039 for (i = 0; i < 24; i++) {
3043 if (placed[i][0] != NULL) {
3044 sceVu0FVECTOR position;
3045 placed[i][0]->GetPosition(position);
int SearchPartsID(float x, float y, float z)
void GetOffset(float *offset)
float GetAlt(int x, int y)
void GetPartsBox(CBoxVu0 *box)
int GetAlt_i(int x, int y)
int DeleteMapParts(int parts_no, CMapParts *parts, float x, float y, float z)
int CheckAreaRect(float x, float y, float z, int rect_width, int rect_height)
int SearchPartsExtra(float x, float y, float z)
int PickUpPoly(CCPoly *polygons, float x, float y, float z)
int CheckRiverChain(int x, int y, int target_x, int target_y)
int SetRiverParts(int x, int y)
int GetPartsID(int x, int y)
int SetMapParts(int parts_id, CMapParts *parts, float x, float y, float z, int rot_y)
int GetPartsRect(CRect_i_ &rect, int *parts_ids, int capacity)
void GetPos(CVector3_i_ *position, float x, float y, float z)
int CheckParts(CMapParts *parts, float x, float y, float z, int rotation)
int SetRoadParts(int x, int y)
int CheckPartsRect(int parts_no, int area_no, CRect_i_ &rect)
void SetBuildEffect(int parts_id)
int PickUpCameraPoly(CCPoly *out_polygons, CBoxVu0 &box, int flags)
void DrawPartsCursor(int plot, float *position, float *model_pos, int rot_y, float *rotation, int area_no)
void DrawRipple(int pass)
int SetRiverParts(float x, float y, float z, int column_step, int row_step)
int SetMapParts(int parts_no, float x, float y, float z, int rot_y)
void Draw(float time, int pass, int lowest, int highest, int fixed_lowest, int fixed_highest)
float GetAlt(float x, float y, float z)
int GetAreaCode(float x, float y, float z)
CMapParts * GetParts(float x, float y, float z)
void MuskaRequest(CMapParts *(*placed)[64])
void DrawWaterSurface(CCamera *camera)
void GetRectParts(CRect_i_ *rect, CMapParts *target, int margin)
void NornRequest(CMapParts *(*placed)[64])
void EditAreaClip(CCamera *camera, float range)
EPARTS_FUNC_DATA * people[128]
int SetFocusParts(float x, float y, float z)
void GetPartsBox(CBoxVu0 *out_box, float x, float y, float z)
int SetRoadParts(float x, float y, float z, int column_step, int row_step)
int GetAlt_i(float x, float y, float z)
int GetPartsID(float x, float y, float z)
int PickUpPoly(CCPoly *polygons, float x, float y, float z)
void YellowRequest(CMapParts *(*placed)[64])
void GetRectDirParts(CRect_i_ *rect, CMapParts *target, int direction, int depth)
CMapParts * GetPartsObject(int parts_no)
int GetRandomPlanePos(sceVu0FVECTOR out_position, sceVu0FVECTOR avoid[], int avoid_count, sceVu0FVECTOR bounds)
CGroundWater water_surfaces[4]
CEditPartsInfo * parts_info
CMapParts fixed_parts[64]
void MatatagiRequest(CMapParts *(*placed)[64])
void QueensRequest(CMapParts *(*placed)[64])
EPARTS_FUNC_DATA * GetPeoplePos(int villager, float *out_position)
void DrawEffect(CCameraFollow *camera, float time, CEffectGroup *effects)
void DrawShadow(int pass, float near_distance, float far_distance)
int GetNearParts(CMapParts **out_parts, int limit, CBoxVu0 *box, CBoxVu0 *fixed_box)
int DeleteMapParts(int *out_parts_no, int *out_rot_y, float x, float y, float z)
int PickUpEditAreaPoly(CCPoly *polygons, float x, float y, float z)
int GetCompEvent(int index)
int CheckComplete(int index)
EDITPARTS_INFO * GetPartsInfo(int index)
GROUND_WATER_RIPPLE ripples[4]
CFrame * GetCollisionFrame()
virtual void SetPosition(float *position)
void SetRotY(int direction)
int CheckBox2(CBoxVu0 *box)
int CheckBox(CBoxVu0 *box)
void DrawParts(float time, float *distance, int lowest, int highest, int *out_level)
s32 blocked_preview_frame
virtual void FrameObjectOnOff(char *name, int on)
void GetPosition(float *out_position)
void DrawEffect(CCamera *camera, float time, CEffectGroup *group)
virtual void GetRotation(float *out_rotation)
void Draw(float *position, int width, int height)
SV_GRD_PART * GetParts(int georama_no, int *out_count)
int GetGameIntFlag(int flag_no)
@ MAP_PARTS_SUBTYPE_RIVER
@ MAP_PARTS_SUBTYPE_ON_RIVER
@ MAP_PARTS_SUBTYPE_BRIDGE
sceVu0FMATRIX view_scaled