DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
editground.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3
4#include "editground.hpp"
5
6#include <cstdlib>
7#include <cstring>
8
9#include "camera.hpp"
10#include "camerafollow.hpp"
11#include "dataread.hpp"
12#include "editarea.hpp"
13#include "editpartsinfo.hpp"
14#include "frame.hpp"
15#include "framevu1.hpp"
16#include "mapparts.hpp"
17#include "mathutil.hpp"
18#include "mglib.hpp"
19#include "objanime.hpp"
20#include "rect.hpp"
21#include "savedata.hpp"
22#include "vector3.hpp"
23
24static int CheckDelete(CEditArea *area, CMapParts *parts, float x, float y, float z);
25
26int CEditGround::SetMapParts(int parts_no, float x, float y, float z, int rot_y) {
27 CVector3_f_ grid;
28 int area_no;
29 int span[2];
30 int deleted_parts_no;
31 int deleted_rot_y;
32 int width;
33 int height;
34 int i;
35 int j;
36 CMapParts *source;
37 int parts_id;
38 CEditArea **slot;
39 CMapParts *target;
40 CEditArea *area;
41 int placeable;
42 EDITPARTS_INFO *info;
43
44 if (CheckEffect()) {
45 return -1;
46 }
47
48 if (parts_no < 0 || parts_no >= 24) {
49 return -1;
50 }
51
52 if (plot_parts == NULL) {
53 return -1;
54 }
55
56 source = &plot_parts[parts_no];
57
58 if (source->handle < 0) {
59 return -1;
60 }
61
62 area_no = GetAreaCode(x, y, z);
63
64 if (area_no < 0) {
65 return -1;
66 }
67
68 CEditArea **area_list = areas;
69 slot = &area_list[area_no];
70 area = *slot;
71
72 if (source->info == NULL) {
73 return -1;
74 }
75
76 placeable = area->CheckParts(source, x, y, z, rot_y);
77 target = parts;
78 parts_id = -1;
79
80 switch (source->subtype) {
83 // A bridge or a crossing replaces the river or road piece beneath it.
84 parts_id = (*slot)->SearchPartsID(x, y, z);
85
86 if (parts_id >= 0 && CheckDelete(area, source, x, y, z) == 0) {
87 if (parts[parts_id].subtype == MAP_PARTS_SUBTYPE_RIVER && parts[parts_id].handle == 1) {
88 target = &parts[parts_id];
89 rot_y = target->GetRotY();
90
91 if (source->subtype != MAP_PARTS_SUBTYPE_ON_RIVER) {
92 source = &river_parts[6];
93 }
94
95 parts_no = source->parts_no;
96 } else {
97 return -1;
98 }
99 } else if (source->subtype != MAP_PARTS_SUBTYPE_ROAD) {
100 return -1;
101 }
102
103 break;
104 default:
105 if (placeable == 0) {
106 return parts_id;
107 }
108
109 break;
110 }
111
112 if (parts_info != NULL) {
113 info = parts_info->GetPartsInfo(parts_no);
114
115 if (info != NULL) {
116 if (info->placed == info->stock) {
117 return -1;
118 }
119
120 info->placed++;
121 }
122 }
123
124 if (parts_id < 0) {
125 for (parts_id = 0; parts_id < 128; target++, parts_id++) {
126 if (target->handle < 0) {
127 break;
128 }
129 }
130
131 if (parts_id == 128) {
132 return -1;
133 }
134 }
135
136 if (placeable != 0 && source->subtype != MAP_PARTS_SUBTYPE_ROAD) {
137 span[0] = source->GetWidth();
138 span[1] = source->GetHeight();
139
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();
144
145 if (area->SearchPartsExtra(cell_x, y, cell_z) == 1) {
146 DeleteMapParts(&deleted_parts_no, &deleted_rot_y, cell_x, y, cell_z);
147 }
148 }
149 }
150 }
151
152 memcpy(target, source, sizeof(CMapParts));
153 target->SetRotY(rot_y);
154 (*slot)->GetGrid(&grid, x, y, z);
155 width = source->GetWidth();
156 height = source->GetHeight();
157
158 if (width % 2 == 1) {
159 grid.x += 0.5f * (*slot)->GetUnitSize();
160 }
161
162 if (height % 2 == 1) {
163 grid.z += 0.5f * (*slot)->GetUnitSize();
164 }
165
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;
172 target->SetPosition(position);
173 target->SetRotY(rot_y);
174 target->area = area_no;
175 (*slot)->SetMapParts(parts_id, parts, x, y, z, rot_y);
176
177 if (target->subtype == MAP_PARTS_SUBTYPE_RIVER && target->handle != 6) {
178 SetRiverParts(x, y, z, 0, 0);
179 SetRiverParts(x, y, z, 1, 0);
180 SetRiverParts(x, y, z, 0, 1);
181 SetRiverParts(x, y, z, -1, 0);
182 SetRiverParts(x, y, z, 0, -1);
183 }
184
185 if (target->subtype == MAP_PARTS_SUBTYPE_ROAD) {
186 SetRoadParts(x, y, z, 0, 0);
187 SetRoadParts(x, y, z, 1, 0);
188 SetRoadParts(x, y, z, 0, 1);
189 SetRoadParts(x, y, z, -1, 0);
190 SetRoadParts(x, y, z, 0, -1);
191 }
192
193 return parts_id;
194}
195
199static inline CFrame *GetShadowFrame(CMapParts *parts) {
200 return parts->shadow_frame;
201}
202
206static inline CFrame *GetShadeFrame(CMapParts *parts) {
207 return parts->shade_frame;
208}
209
213static inline CFrame *GetRippleFrame(CMapParts *parts) {
214 return parts->ripple_frame;
215}
216
220static inline CFrame *GetCameraFrame(CMapParts *parts) {
221 if (parts->camera_frame == NULL) {
222 return NULL;
223 }
224
225 parts->camera_frame->SetPosition(parts->pos[0], parts->pos[1], parts->pos[2]);
226 parts->camera_frame->SetRotation(parts->rotation.x, parts->rotation.y, parts->rotation.z);
227 return parts->camera_frame;
228}
229
230int CEditGround::SetRiverParts(float x, float y, float z, int column_step, int row_step) {
231 CVector3_i_ cell;
232 CVector3_f_ position;
233 int deleted_parts_no;
234 int deleted_rot_y;
235
236 int area_no = GetAreaCode(x, y, z);
237
238 if (area_no < 0) {
239 return 0;
240 }
241
242 CEditArea *area = areas[area_no];
243 area->GetPos(&cell, x, y, z);
244 cell.x += column_step;
245 cell.z += row_step;
246 int parts_id = area->GetPartsID(cell.x, cell.z);
247
248 if (parts_id < 0) {
249 return 0;
250 }
251
252 CMapParts *object = &parts[parts_id];
253 int subtype = object->subtype;
254
255 if ((subtype != MAP_PARTS_SUBTYPE_RIVER && subtype != MAP_PARTS_SUBTYPE_BRIDGE && subtype != MAP_PARTS_SUBTYPE_ON_RIVER) || river_parts == NULL) {
256 return 0;
257 }
258
259 if (subtype == MAP_PARTS_SUBTYPE_BRIDGE || subtype == MAP_PARTS_SUBTYPE_ON_RIVER) {
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);
262 }
263
264 int code = area->SetRiverParts(cell.x, cell.z);
265
266 if (code < 0) {
267 return 0;
268 }
269
270 int piece = (code & 0xFF0) >> 4;
271 int rot_y = code & 0xF;
272
273 if (piece - 1 < 0 || piece - 1 >= 16) {
274 return 0;
275 }
276
277 if (rot_y >= 3) {
278 rot_y = -1;
279 }
280
281 for (int i = 0; i < 4; i++) {
282 CMapParts *river = &river_parts[(u32) (piece - 1)];
283 CFrameVu1 *frame = river->frame[i];
284 object->SetFrame(frame, i);
285 }
286
287 object->collision_frame = river_parts[(u32) (piece - 1)].GetCollisionFrame();
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)]);
292 object->handle = river_parts[(u32) (piece - 1)].handle;
293 object->subtype = river_parts[(u32) (piece - 1)].subtype;
294 object->bound = river_parts[(u32) (piece - 1)].bound;
295 object->SetRotY(rot_y);
296 return 1;
297}
298
299int CEditGround::SetRoadParts(float x, float y, float z, int column_step, int row_step) {
300 CVector3_i_ cell;
301
302 int area_no = GetAreaCode(x, y, z);
303
304 if (area_no < 0) {
305 return 0;
306 }
307
308 CEditArea *area = areas[area_no];
309 area->GetPos(&cell, x, y, z);
310 cell.x += column_step;
311 cell.z += row_step;
312 int parts_id = area->GetPartsID(cell.x, cell.z);
313
314 if (parts_id < 0) {
315 return 0;
316 }
317
318 CMapParts *object = &parts[parts_id];
319
320 if (object->subtype != MAP_PARTS_SUBTYPE_ROAD || road_parts == NULL) {
321 return 0;
322 }
323
324 int code = area->SetRoadParts(cell.x, cell.z);
325
326 if (code < 0) {
327 return 0;
328 }
329
330 int piece = (code & 0xFF0) >> 4;
331 int rot_y = code & 0xF;
332
333 if (piece - 1 < 0 || piece - 1 >= 6) {
334 return 0;
335 }
336
337 if (rot_y >= 3) {
338 rot_y = -1;
339 }
340
341 for (int i = 0; i < 4; i++) {
342 CMapParts *road = &road_parts[(u32) (piece - 1)];
343 CFrameVu1 *frame = road->frame[i];
344 object->SetFrame(frame, i);
345 }
346
347 object->collision_frame = road_parts[(u32) (piece - 1)].GetCollisionFrame();
348 object->SetRotY(rot_y);
349 object->handle = road_parts[(u32) (piece - 1)].handle;
350 object->subtype = road_parts[(u32) (piece - 1)].subtype;
351 object->bound = road_parts[(u32) (piece - 1)].bound;
352 return 1;
353}
354
355int CEditGround::DeleteMapParts(int *out_parts_no, int *out_rot_y, float x, float y, float z) {
356 int area_code = GetAreaCode(x, y, z);
357
358 if (area_code < 0) {
359 return -1;
360 }
361
362 CEditArea *area = areas[area_code];
363 int parts_id = area->SearchPartsID(x, y, z);
364
365 if (parts_id < 0) {
366 return -1;
367 }
368
369 CMapParts *target = &parts[parts_id];
370
371 if (CheckDelete(area, target, x, y, z) != 0) {
372 return -1;
373 }
374
376 // A bridge or a crossing leaves the plain river piece behind.
377 sceVu0FVECTOR position;
378 int rot_y = target->GetRotY();
379 target->GetPosition(position);
380 int plot = target->parts_no;
381 *out_parts_no = plot;
382 memcpy(target, &river_parts[1], sizeof(CMapParts));
383 target->SetPosition(position);
384 target->SetRotY(rot_y);
385 area->SetMapParts(parts_id, parts, x, y, z, rot_y);
386
387 if (parts_info != NULL) {
389
390 if (info != NULL) {
391 info->placed--;
392
393 if (info->placed < 0) {
394 info->placed = false;
395 }
396 }
397 }
398
399 return parts_id;
400 }
401
402 if (parts_info != NULL) {
403 EDITPARTS_INFO *info = parts_info->GetPartsInfo(parts[parts_id].parts_no);
404
405 if (info != NULL) {
406 info->placed--;
407
408 if (info->placed < 0) {
409 info->placed = false;
410 }
411 }
412 }
413
414 sceVu0FVECTOR position;
415 parts[parts_id].GetPosition(position);
416 area->DeleteMapParts(parts_id, parts, (float) (1.0f + position[0]), position[1], (float) (1.0f + position[2]));
417
418 if (parts[parts_id].subtype == MAP_PARTS_SUBTYPE_RIVER) {
419 SetRiverParts(position[0], position[1], position[2], 1, 0);
420 SetRiverParts(position[0], position[1], position[2], 0, 1);
421 SetRiverParts(position[0], position[1], position[2], -1, 0);
422 SetRiverParts(position[0], position[1], position[2], 0, -1);
423 }
424
425 if (parts[parts_id].subtype == MAP_PARTS_SUBTYPE_ROAD) {
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);
430 }
431
432 *out_parts_no = parts[parts_id].parts_no;
433 *out_rot_y = parts[parts_id].rot_y;
434 parts[parts_id].Initialize();
435 parts[parts_id].handle = -1;
436 return parts_id;
437}
438
439int CEditGround::GetAreaCode(float x, float y, float z) {
440 for (int i = 0; i < 4; i++) {
441 if (areas[i] == NULL) {
442 break;
443 }
444
445 if (areas[i]->CheckArea(x, y, z)) {
446 return i;
447 }
448 }
449
450 return -1;
451}
452
453float CEditGround::GetAlt(float x, float y, float z) {
454 int area_no = GetAreaCode(x, y, z);
455
456 if (area_no < 0) {
457 return 0.0f;
458 }
459
460 return areas[area_no]->GetAlt(x, y, z);
461}
462
463int CEditGround::GetAlt_i(float x, float y, float z) {
464 int area_no = GetAreaCode(x, y, z);
465
466 if (area_no < 0) {
467 return 0;
468 }
469
470 return areas[area_no]->GetAlt_i(x, y, z);
471}
472
474 CMapParts *object = parts;
475
476 for (int i = 0; i < 128; i++, object++) {
477 if (object->handle >= 0 && object->parts_no == parts_no) {
478 return object;
479 }
480 }
481
482 return NULL;
483}
484
485int CEditGround::GetPartsID(float x, float y, float z) {
486 int area_no = GetAreaCode(x, y, z);
487
488 if (area_no < 0) {
489 return -1;
490 }
491
492 return areas[area_no]->SearchPartsID(x, y, z);
493}
494
495CMapParts *CEditGround::GetParts(float x, float y, float z) {
496 int parts_id = GetPartsID(x, y, z);
497
498 if (parts_id < 0) {
499 return NULL;
500 }
501
502 return &parts[parts_id];
503}
504
506 return effect_count > 0;
507}
508
509void CEditGround::SetBuildEffect(int parts_id) {
510 sceVu0FVECTOR position;
511
512 if (parts_id < 0 || parts_id >= 128) {
513 return;
514 }
515
516 if (parts[parts_id].subtype != MAP_PARTS_SUBTYPE_NONE) {
517 return;
518 }
519
520 effect_parts_id = parts_id;
521 effect_count = 15;
522 parts[parts_id].GetPosition(position);
523 effect_target_alt = position[1];
524 position[1] += 50.0f;
525 parts[parts_id].SetPosition(position);
526 effect_alt = position[1];
528}
529
531 sceVu0FVECTOR position;
532 int stop = effect_parts_id < 0 || effect_parts_id >= 128;
533 stop = (bool) stop || effect_count <= 0;
534 stop = (bool) stop || parts[effect_parts_id].handle < 0;
535
536 if (stop) {
537 effect_parts_id = -1;
538 effect_count = -1;
539 return;
540 }
541
542 effect_count--;
544 position[1] += effect_step;
546
547 if (effect_count <= 0) {
548 position[1] = effect_target_alt;
550 }
551}
552
553int CEditGround::SetFocusParts(float x, float y, float z) {
554 focus_parts_id = -1;
555 int area_no = GetAreaCode(x, y, z);
556
557 if (area_no < 0) {
558 return -1;
559 }
560
561 CEditArea *area = areas[area_no];
562 int parts_id = area->SearchPartsID(x, y, z);
563
564 if (parts_id < 0) {
565 return -1;
566 }
567
568 CMapParts *focus = &parts[parts_id];
569
570 if (CheckDelete(area, focus, x, y, z)) {
571 return -1;
572 }
573
574 focus_parts_id = GetPartsID(x, y, z);
575 return focus_parts_id;
576}
577
581static inline float Magnitude(float value) {
582 return value < 0.0f ? -value : value;
583}
584
585void CEditGround::EditAreaClip(CCamera *camera, float range) {
586 CBoxVu0 box;
587 sceVu0FVECTOR eye = {0.0f, 0.0f, 0.0f, 0.0f};
588 sceVu0FVECTOR ref;
589 sceVu0FVECTOR dir;
590 sceVu0FVECTOR forward;
591 float dists[4];
592 float dots[4];
593 sceVu0FVECTOR to_center;
594 sceVu0FVECTOR center;
595 sceVu0FVECTOR corner_a;
596 sceVu0FVECTOR corner_b;
597 sceVu0FVECTOR corner_max;
598 sceVu0FVECTOR corner_min;
599 float facing;
600 int i;
601
602 if (camera != NULL) {
603 camera->GetPos(eye);
604 camera->GetRef(ref);
605 sceVu0SubVector(dir, ref, eye);
606
607 if (GetAreaCode(eye[0], eye[1], eye[2]) < 0) {
608 sceVu0SubVector(forward, ref, eye);
609 forward[1] = 0.0f;
610 sceVu0Normalize(forward, forward);
611 sceVu0ScaleVector(forward, forward, 500.0f);
612 sceVu0AddVector(ref, eye, forward);
613 }
614 } else {
615 sceVu0CopyVector(eye, ref);
616 sceVu0CopyVector(dir, ref);
617 }
618
619 facing = 0.0f;
620
621 for (i = 0; i < 4; i++) {
622 CEditArea *area = areas[i];
623
624 if (area == NULL) {
625 break;
626 }
627
628 area->GetOffset(box.min);
629 box.min[1] -= 2.0f * area->GetUnitAlt();
630 box.min[3] = 1.0f;
631 sceVu0CopyVector(box.max, box.min);
632 box.max[0] += area->GetUnitSize() * (float) area->GetWidth();
633 box.max[1] += 32.0f * area->GetUnitAlt();
634 box.max[2] += area->GetUnitSize() * (float) area->GetHeight();
635 dists[i] = -1.0f;
636 dots[i] = -1.0f;
637
638 if (MGClipBox(&box)) {
639 area_visible[i] = 0;
640 continue;
641 }
642
643 area_visible[i] = 1;
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);
648
649 if (dots[i] > 0.0f) {
650 facing += 1.0f;
651 }
652
653 // The corners of the area on the ground, for the distance from the target to its edge.
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];
659 corner_a[1] = 0.0f;
660 corner_a[2] = box.min[2];
661 corner_b[0] = box.min[0];
662 corner_b[1] = 0.0f;
663 corner_b[2] = box.max[2];
664 int side_x = 0;
665 int side_z = 0;
666
667 if (ref[0] < box.min[0]) {
668 side_x = -1;
669 }
670
671 if (ref[0] > box.max[0]) {
672 side_x = 1;
673 }
674
675 if (ref[2] < box.min[2]) {
676 side_z = -1;
677 }
678
679 if (ref[2] > box.max[2]) {
680 side_z = 1;
681 }
682
683 float gap;
684
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) {
696 dists[i] = 0.0f;
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);
707 }
708
709 if (range > 0.0f && dists[i] > range) {
710 area_visible[i] = 0;
711 }
712 }
713
714 if (range < 0.0f) {
715 clip_plane[3] = -1.0f;
716 return;
717 }
718
719 int nearest = -1;
720 int nearest_dist = -1;
721
722 for (int j = 0; j < 4; j++) {
723 if (areas[j] == NULL) {
724 break;
725 }
726
727 if (area_visible[j] == 0) {
728 continue;
729 }
730
731 if (dists[j] < 0.0f) {
732 continue;
733 }
734
735 if (nearest < 0) {
736 nearest = j;
737 nearest_dist = dists[j];
738 } else if (nearest_dist > dists[j]) {
739 nearest = j;
740 nearest_dist = dists[j];
741 }
742 }
743
744 switch (map_no) {
745 case TOWN_MATATAKI:
746 if (dists[0] > dists[2]) {
747 if (area_visible[2]) {
748 area_visible[0] = 0;
749 area_visible[2] = 1;
750 }
751 } else {
752 if (area_visible[0]) {
753 area_visible[0] = 1;
754 area_visible[2] = 0;
755 }
756 }
757
758 if (range > 0.0f) {
759 if (clip_plane[3] < 0.0f || !(clip_plane[3] < 1200.0f)) {
760 clip_plane[0] = eye[0];
761 clip_plane[1] = eye[1];
762 clip_plane[2] = eye[2];
763 clip_plane[3] = 1200.0f;
764 }
765 } else {
766 clip_plane[3] = -1.0f;
767 }
768
769 break;
770 case TOWN_QUEENS:
771 for (int k = 0; k < 4; k++) {
772 if (areas[k] == NULL) {
773 break;
774 }
775
776 if (k == nearest) {
777 area_visible[k] = 1;
778 } else {
779 area_visible[k] = 0;
780 }
781
782 if (dists[k] > 0.0f && dists[k] < 600.0f) {
783 area_visible[k] = 1;
784 }
785 }
786
787 break;
788 }
789}
790
791int CEditGround::GetRandomPlanePos(sceVu0FVECTOR out_position, sceVu0FVECTOR avoid[], int avoid_count, sceVu0FVECTOR bounds) {
792 int cells[2048];
793 sceVu0FVECTOR position;
794 CVector3_f_ grid;
795 CVector3_f_ chosen;
796 int found = 0;
797 int area_count = 0;
798 int x;
799 int z;
800 int area_no;
801
802 for (x = 0;; x++) {
803 if (areas[x] == NULL) {
804 break;
805 }
806
807 area_count++;
808 }
809
810 if (area_count == 0) {
811 return 0;
812 }
813
814 for (area_no = 0; area_no < area_count; area_no++) {
815 int width = areas[area_no]->GetWidth();
816 int height = areas[area_no]->GetHeight();
817
818 // The outer two cells of each edge are never chosen.
819 for (x = 2; x < width - 2; x++) {
820 for (z = 2; z < height - 2; z++) {
821 if (areas[area_no]->GetPartsID(x, z) >= 0 && areas[area_no]->GetPartsExtra(x, z) != 1) {
822 continue;
823 }
824
825 int blocked = 0;
826 areas[area_no]->GetPos(&grid, x, 0, z);
827 position[0] = grid.x;
828 position[1] = areas[area_no]->GetAlt(x, z);
829 position[2] = grid.z;
830
831 if (!(bounds[3] <= 0.0f) && !(DistVector(bounds, position) <= bounds[3])) {
832 blocked = 1;
833 }
834
835 for (int i = 0; i < avoid_count; i++) {
836 float distance = DistVector(avoid[i], position);
837
838 if (distance < avoid[i][3]) {
839 blocked = 1;
840 break;
841 }
842 }
843
844 if (areas[area_no]->GetAlt_i(x, z) > 0) {
845 blocked = 1;
846 }
847
848 if (!blocked) {
849 cells[found++] = (area_no << 16) | (x | (z << 8));
850 }
851 }
852 }
853 }
854
855 if (found == 0) {
856 return 0;
857 }
858
859 int cell = cells[rand() % found];
860 int column = cell & 0xFF;
861 int row = (cell >> 8) & 0xFF;
862 area_no = (cell >> 16) & 0xFF;
863 areas[area_no]->GetPos(&chosen, column, 0, row);
864 out_position[0] = chosen.x + 0.5f * areas[area_no]->GetUnitSize();
865 out_position[1] = areas[0]->GetAlt(column, row);
866 out_position[2] = chosen.z + 0.5f * areas[area_no]->GetUnitSize();
867 return 1;
868}
869
870int CEditGround::GetNearParts(CMapParts **out_parts, int limit, CBoxVu0 *box, CBoxVu0 *fixed_box) {
871 int i;
872 int count = 0;
873 CMapParts *object = parts;
874
875 for (i = 0; i < 128; i++, object++) {
876 if (object->handle < 0) {
877 continue;
878 }
879
880 if (!object->CheckBox(box)) {
881 continue;
882 }
883
884 if (count >= limit) {
885 return count;
886 }
887
888 *out_parts++ = object;
889 count++;
890 }
891
892 if (fixed_box == NULL) {
893 fixed_box = box;
894 }
895
896 for (i = 0; i < 64; i++) {
897 if (fixed_parts[i].handle < 0) {
898 continue;
899 }
900
901 CMapParts *fixed = &fixed_parts[i];
902
903 if (!fixed->CheckBox2(fixed_box)) {
904 continue;
905 }
906
907 if (count >= limit) {
908 return count;
909 }
910
911 *out_parts++ = fixed;
912 count++;
913 }
914
915 return count;
916}
917
919 for (int i = 0; i < 4; i++) {
920 if (areas[i] != NULL) {
921 areas[i]->MakePartsBox();
922 }
923 }
924}
925
926void CEditGround::GetPartsBox(CBoxVu0 *out_box, float x, float y, float z) {
927 int area_no = GetAreaCode(x, y, z);
928
929 if (area_no < 0) {
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;
934 return;
935 }
936
937 if (areas[area_no] != NULL) {
938 areas[area_no]->GetPartsBox(out_box);
939 }
940}
941
942EPARTS_FUNC_DATA *CEditGround::GetPeoplePos(int villager, float *out_position) {
943 sceVu0FVECTOR transform;
944 sceVu0FVECTOR frame_rotation;
945
946 for (int i = 0; i < people_count; i++) {
947 EPARTS_FUNC_DATA *marker = people[i];
948
949 if (marker->kind != EPARTS_FUNC_VILLAGER || marker->link_id != villager) {
950 continue;
951 }
952
953 CMapParts *owner = marker->parts;
954
955 if (owner->parts_no >= 0) {
956 owner = GetPartsObject(owner->parts_no);
957 }
958
959 if (owner == NULL) {
960 return NULL;
961 }
962
963 sceVu0CopyVector(out_position, marker->position);
964 CFrameVu1 *frame = owner->frame[0];
965
966 if (frame == NULL) {
967 return NULL;
968 }
969
970 owner->GetPosition(transform);
971 frame->SetPosition(transform);
972 owner->GetRotation(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]);
978 return marker;
979 }
980
981 return NULL;
982}
983
985 for (int i = 0; i < 4; i++) {
986 if (areas[i] == NULL) {
987 break;
988 }
989
990 areas[i]->DrawGrid();
991 }
992}
993
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;
998 int i;
999
1000 for (i = 0; i < 64; i++) {
1001 if (fixed_parts[i].category_no == pass) {
1002 fixed_parts[i].DrawParts(time, lod_distance, fixed_lowest, fixed_highest, NULL);
1003 }
1004 }
1005
1006 CMapParts *object = parts;
1007
1008 for (i = 0; i < 128; i++, object++) {
1009 if (object->category_no != pass) {
1010 continue;
1011 }
1012
1013 if (object->handle < 0) {
1014 continue;
1015 }
1016
1017 if (object->area >= 0 && area_visible[object->area] == 0) {
1018 continue;
1019 }
1020
1021 if (!(clip_plane[3] <= 0.0f)) {
1022 object->GetPosition(position);
1023
1024 if (!(DistVector(position, clip_plane) <= clip_plane[3]) && !object->ChangeDigData()) {
1025 continue;
1026 }
1027 }
1028
1029 sceVu0FVECTOR focus_ambient = {32.0f, 32.0f, 128.0f, 128.0f};
1030 MGGetAmbient(ambient);
1031
1032 if (focus_parts_id == i) {
1033 MGSetAmbient(focus_ambient);
1034 }
1035
1036 object->DrawParts(time, lod_distance, lowest, highest, NULL);
1037 MGSetAmbient(ambient);
1038 }
1039}
1040
1042 int i;
1043 int j;
1044 CGroundWater *surface = water_surfaces;
1045
1046 for (i = 0; i < 4; i++, surface++) {
1047 if (surface->draw == 0) {
1048 continue;
1049 }
1050
1051 if (surface->water.CheckClip()) {
1052 continue;
1053 }
1054
1055 for (j = 0; j < 4; j++) {
1056 if (surface->ripples[j].power == 0.0f && surface->ripples[j].range == 0.0f) {
1057 break;
1058 }
1059
1060 int row = surface->ripples[j].row;
1061 int column = surface->ripples[j].column;
1062
1063 if (row < 0) {
1064 int rows = surface->water.rows;
1065 row = rows * (float) rand() / 2.1474836e9f;
1066 }
1067
1068 if (column < 0) {
1069 int rows = surface->water.rows;
1070 column = rows * (float) rand() / 2.1474836e9f;
1071 }
1072
1073 surface->water.Shake(row, column, surface->ripples[j].power + surface->ripples[j].range * (float) rand() / 2.1474836e9f);
1074 }
1075
1076 surface->water.Hamon();
1077 }
1078}
1079
1081 sceVu0FVECTOR eye;
1082 sceVu0FVECTOR position;
1083 sceVu0FVECTOR dir;
1084 sceVu0FVECTOR parts_position;
1085 int i;
1086 CGroundWater *surface = water_surfaces;
1087
1088 camera->GetPos(eye);
1089 camera->GetDir(dir);
1090 dir[1] = 0.0f;
1091 sceVu0Normalize(dir, dir);
1092
1093 for (i = 0; i < 4; i++, surface++) {
1094 if (surface->draw == 0) {
1095 continue;
1096 }
1097
1098 CWater *water = &surface->water;
1099 sceVu0CopyVector(position, surface->offset);
1100
1101 if (surface->parts_no >= 0) {
1102 CMapParts *owner = GetPartsObject(surface->parts_no);
1103
1104 if (owner == NULL) {
1105 continue;
1106 }
1107
1108 CFrame *frame = owner->ripple_frame;
1109
1110 if (frame != NULL && surface->name[0] != '\0') {
1111 frame = frame->SearchFrame(surface->name);
1112
1113 if (frame != NULL && !(frame->attr.draw_on & 1)) {
1114 continue;
1115 }
1116 }
1117
1118 owner->GetPosition(parts_position);
1119
1120 if (!(clip_plane[3] <= 0.0f || DistVector(parts_position, clip_plane) <= clip_plane[3] || owner->ChangeDigData())) {
1121 continue;
1122 }
1123
1124 sceVu0AddVector(position, position, parts_position);
1125 water->frame.SetPosition(position);
1126 owner->GetRotation(parts_position);
1127 water->frame.SetRotation(parts_position[0], parts_position[1], parts_position[2]);
1128 } else {
1129 if (surface->follow[0]) {
1130 position[0] = eye[0] + 50.0f * dir[0];
1131 }
1132
1133 if (surface->follow[1]) {
1134 position[1] = eye[1];
1135 }
1136
1137 if (surface->follow[2]) {
1138 position[2] = eye[2] + 50.0f * dir[2];
1139 }
1140
1141 CVector3_f_ rotation;
1142 rotation.z = rotation.y = rotation.x = 0.0f;
1143 water->frame.SetRotation(rotation.x, rotation.y, rotation.z);
1144 water->frame.SetPosition(position);
1145 }
1146
1147 DrawVu1__6CWaterFP10RenderInfoP13sceVif1PacketP1(water, &mgRenderInfo, GetVif1Packet(), NULL);
1148 }
1149}
1150
1152 sceVu0FVECTOR position;
1153 sceVu0FVECTOR corner;
1154 CMapParts *object = parts;
1155 int i;
1156
1157 for (i = 0; i < 128; i++, object++) {
1158 if (suppress_water) {
1159 break;
1160 }
1161
1162 if (object->handle < 0) {
1163 continue;
1164 }
1165
1166 if (object->area >= 0 && area_visible[object->area] == 0) {
1167 continue;
1168 }
1169
1170 CMapParts *water = &river_parts[7];
1171 object->GetPosition(position);
1172
1173 switch (object->subtype) {
1177 water->SetPosition(position);
1178 water->Draw();
1179 break;
1181 if (object->area < 0) {
1182 break;
1183 }
1184
1185 if (object->GetWidth() != 2) {
1186 break;
1187 }
1188
1189 if (object->GetHeight() != 2) {
1190 break;
1191 }
1192
1193 float size = areas[object->area]->GetUnitSize();
1194 position[0] += 0.5f * size;
1195 position[2] += 0.5f * size;
1196 water->SetPosition(position);
1197 water->Draw();
1198 sceVu0CopyVector(corner, position);
1199 corner[0] = position[0] - size;
1200 water->SetPosition(corner);
1201 water->Draw();
1202 corner[2] = position[2] - size;
1203 water->SetPosition(corner);
1204 water->Draw();
1205 corner[0] = position[0];
1206 water->SetPosition(corner);
1207 water->Draw();
1208 break;
1209 }
1210 }
1211
1212 for (int j = 0; j < 64; j++) {
1213 if (fixed_parts[j].category_no == pass) {
1214 fixed_parts[j].Draw();
1215 }
1216 }
1217}
1218
1220 sceVu0FVECTOR transform;
1221 sceVu0FVECTOR position;
1222 CMapParts *object = parts;
1223 int i;
1224
1225 for (i = 0; i < 128; i++, object++) {
1226 if (suppress_water) {
1227 break;
1228 }
1229
1230 if (object->handle < 0) {
1231 continue;
1232 }
1233
1234 if (object->ripple_frame == NULL) {
1235 continue;
1236 }
1237
1238 if (object->draw_on == 0) {
1239 continue;
1240 }
1241
1242 if (object->area >= 0 && area_visible[object->area] == 0) {
1243 continue;
1244 }
1245
1246 if (!(clip_plane[3] <= 0.0f)) {
1247 object->GetPosition(position);
1248
1249 if (!(DistVector(position, clip_plane) <= clip_plane[3]) && !object->ChangeDigData()) {
1250 continue;
1251 }
1252 }
1253
1254 if (object->ripple_frame == NULL) {
1255 continue;
1256 }
1257
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]);
1263 MGDraw(object->ripple_frame);
1264 }
1265
1266 for (int j = 0; j < 64; j++) {
1267 if (fixed_parts[j].category_no != pass) {
1268 continue;
1269 }
1270
1271 if (fixed_parts[j].ripple_frame == NULL) {
1272 continue;
1273 }
1274
1275 if (fixed_parts[j].draw_on == 0) {
1276 continue;
1277 }
1278
1279 fixed_parts[j].GetPosition(transform);
1280 fixed_parts[j].ripple_frame->SetPosition(transform);
1281 fixed_parts[j].GetRotation(transform);
1282 fixed_parts[j].ripple_frame->SetRotation(transform[0], transform[1], transform[2]);
1283 MGDraw(fixed_parts[j].ripple_frame);
1284 }
1285}
1286
1287void CEditGround::DrawShadow(int pass, float near_distance, float far_distance) {
1288 sceVu0FVECTOR position;
1289 sceVu0FVECTOR view;
1290 sceVu0FVECTOR clip_position;
1291 int i;
1292 CMapParts *object;
1293 int fast;
1294
1295 if (near_distance < 1.0f) {
1296 near_distance = -10000000;
1297 }
1298
1299 object = parts;
1300
1301 for (i = 0; i < 128; i++, object++) {
1302 if (object->category_no < 0) {
1303 continue;
1304 }
1305
1306 if (object->handle < 0) {
1307 continue;
1308 }
1309
1310 if (object->area >= 0 && area_visible[object->area] == 0) {
1311 continue;
1312 }
1313
1314 if (!(clip_plane[3] <= 0.0f)) {
1315 object->GetPosition(clip_position);
1316
1317 if (!(DistVector(clip_position, clip_plane) <= clip_plane[3]) && !object->ChangeDigData()) {
1318 continue;
1319 }
1320 }
1321
1322 object->GetPosition(position);
1323 position[3] = 1.0f;
1324 sceVu0ApplyMatrix(view, mgRenderInfo.view_scaled, position);
1325
1326 if (!(object->draw_distance <= 0.0f) && pass == 0 && object->draw_distance < DistVector(view)) {
1327 continue;
1328 }
1329
1330 if (view[2] > near_distance && view[2] < far_distance) {
1331 object->DrawShade();
1332
1333 if (object->shadow_frame != NULL) {
1334 fast = pass != 0;
1335
1336 if (view[2] > 300.0f) {
1337 fast = 1;
1338 }
1339
1340 object->DrawShadow(fast);
1341 }
1342 }
1343 }
1344
1345 for (int j = 0; j < 64; j++) {
1346 CMapParts *fixed = &fixed_parts[j];
1347
1348 if (fixed->category_no < 0) {
1349 continue;
1350 }
1351
1352 if (fixed->handle < 0) {
1353 continue;
1354 }
1355
1356 sceVu0CopyVector(position, fixed->pos);
1357 position[3] = 1.0f;
1358 sceVu0ApplyMatrix(view, mgRenderInfo.view_scaled, position);
1359
1360 if (view[2] > near_distance && view[2] < far_distance) {
1361 fixed->DrawShade();
1362
1363 if (fixed->shadow_frame != NULL) {
1364 fast = pass != 0;
1365
1366 if (view[2] > 300.0f) {
1367 fast = 1;
1368 }
1369
1370 fixed->DrawShadow(fast);
1371 }
1372 }
1373 }
1374}
1375
1376void CEditGround::DrawPartsCursor(int plot, float *position, float *model_pos, int rot_y, float *rotation, int area_no) {
1377 static int old_parts = -1;
1378 CVector3_f_ cell;
1379 CVector3_i_ grid;
1380 sceVu0FMATRIX light_direction;
1381 sceVu0FMATRIX light_colour;
1382 sceVu0FVECTOR ambient;
1383 int area_code;
1384 CEditArea *area;
1385 CMapParts *source;
1386 int width;
1387 int height;
1388 int fits;
1389 int occupant;
1390 EDITPARTS_INFO *info;
1391 CFrame *preview;
1392 CFrame *model;
1393 int saved_draw;
1394 int subtype;
1395 float step;
1396
1397 if (plot < 0 || plot >= 24) {
1398 sceVu0CopyVector(model_pos, position);
1399 return;
1400 }
1401
1402 area_code = GetAreaCode(position[0], position[1], position[2]);
1403
1404 if (area_code < 0) {
1405 sceVu0CopyVector(model_pos, position);
1406 return;
1407 }
1408
1409 area = areas[area_code];
1410 source = &plot_parts[plot];
1411 width = source->GetWidth();
1412 height = source->GetHeight();
1413
1414 if (area->CheckAreaRect(position[0], position[1], position[2], width, height) == 0) {
1415 sceVu0CopyVector(model_pos, position);
1416 return;
1417 }
1418
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]);
1422
1423 if (source->subtype == MAP_PARTS_SUBTYPE_ON_RIVER) {
1424 if (CheckDelete(area, source, position[0], position[1], position[2]) != 0) {
1425 fits = 0;
1426 }
1427
1428 if (occupant >= 0 && parts[occupant].handle != 1) {
1429 fits = 0;
1430 }
1431 }
1432
1433 if (parts_info != NULL) {
1434 info = parts_info->GetPartsInfo(plot);
1435
1436 if (info != NULL) {
1437 fits &= info->placed < info->stock;
1438 }
1439 }
1440
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;
1445 position[3] = 0.0f;
1446 preview = fits != 0 ? (CFrame *) source->preview_frame : (CFrame *) source->blocked_preview_frame;
1447
1448 if (width % 2 == 1) {
1449 position[0] += 0.5f * area->GetUnitSize();
1450 }
1451
1452 if (height % 2 == 1) {
1453 position[2] += 0.5f * area->GetUnitSize();
1454 }
1455
1456 if (fits == 0) {
1457 // Draw the cursor dim and without point lights where the part cannot go.
1458 MGGetAmbient(ambient);
1459 MGGetPLight(light_direction, light_colour);
1460 sceVu0FVECTOR dim = {60.0f, 60.0f, 60.0f, 128.0f};
1461 MGSetAmbient(dim);
1462 MGSetPLight(mgZeroMatrix, mgZeroMatrix);
1463 }
1464
1465 cursor.unit_size = area->GetUnitSize();
1466
1467 if (cursor.area == area_no) {
1468 cursor.Draw(position, width, height);
1469 }
1470
1471 if (fits == 0) {
1472 MGSetAmbient(ambient);
1473 MGSetPLight(light_direction, light_colour);
1474 }
1475
1476 position[1] += 50.0f;
1477 sceVu0FVECTOR goal;
1478 sceVu0CopyVector(goal, position);
1479 step = goal[0] - model_pos[0];
1480
1481 if (Magnitude(step) < 1.0f) {
1482 model_pos[0] = goal[0];
1483 } else {
1484 model_pos[0] += step / 8.0f;
1485 }
1486
1487 step = goal[1] - model_pos[1];
1488
1489 if (Magnitude(step) < 1.0f) {
1490 model_pos[1] = goal[1];
1491 } else {
1492 model_pos[1] += step / 8.0f;
1493 }
1494
1495 step = goal[2] - model_pos[2];
1496
1497 if (Magnitude(step) < 1.0f) {
1498 model_pos[2] = goal[2];
1499 } else {
1500 model_pos[2] += step / 8.0f;
1501 }
1502
1503 if (source->category_no == area_no) {
1504 subtype = source->subtype;
1505
1506 if (preview != NULL && subtype != MAP_PARTS_SUBTYPE_RIVER && subtype != MAP_PARTS_SUBTYPE_BRIDGE) {
1507 model = NULL;
1508
1509 if (subtype == MAP_PARTS_SUBTYPE_ON_RIVER) {
1510 model = preview->SearchFrame("kawa");
1511
1512 if (model != NULL) {
1513 saved_draw = model->attr.draw_on;
1514 model->attr.draw_on = 2;
1515 }
1516
1517 if (occupant >= 0) {
1518 CMapParts *target = &parts[occupant];
1519 target->GetRotation(rotation);
1520 }
1521 }
1522
1523 float *angle = rotation;
1524 preview->SetPosition(model_pos);
1525 preview->SetRotation(angle[0], angle[1], angle[2]);
1526 MGDraw(preview);
1527
1528 if (model != NULL) {
1529 model->attr.draw_on = saved_draw;
1530 }
1531 }
1532 }
1533}
1534
1535void CEditGround::DrawEffect(CCameraFollow *camera, float time, CEffectGroup *effects) {
1536 sceVu0FVECTOR position;
1537 int i;
1538 CMapParts *object = parts;
1539
1540 for (i = 0; i < 128; i++, object++) {
1541 if (object->area >= 0 && area_visible[object->area] == 0) {
1542 continue;
1543 }
1544
1545 if (!(clip_plane[3] <= 0.0f)) {
1546 object->GetPosition(position);
1547
1548 if (!(DistVector(position, clip_plane) <= clip_plane[3])) {
1549 continue;
1550 }
1551 }
1552
1553 object->DrawEffect(camera, time, effects);
1554 }
1555
1556 for (i = 0; i < 64; i++) {
1557 fixed_parts[i].DrawEffect(camera, time, effects);
1558 }
1559}
1560
1561void CEditGround::Save(char *path) {
1562 char buffer[4000];
1563 sceVu0FVECTOR position;
1564 GROUND_SAVE_HEADER *header = (GROUND_SAVE_HEADER *) buffer;
1565 SV_GRD_PART *record = (SV_GRD_PART *) (header + 1);
1566
1567 header->offset = sizeof(GROUND_SAVE_HEADER);
1568 header->count = 0;
1569
1570 for (int i = 0; i < 128; i++) {
1571 CMapParts *object = &parts[i];
1572 int parts_id = parts[i].handle;
1573
1574 if (parts_id < 0) {
1575 continue;
1576 }
1577
1578 int j;
1579 int kind = object->subtype;
1580
1581 if (kind > 0) {
1582 for (j = 0; j < 24; j++) {
1583 if (kind == plot_parts[j].subtype) {
1584 parts_id = plot_parts[j].handle;
1585 break;
1586 }
1587 }
1588 }
1589
1590 object->GetPosition(position);
1591 record->part_id = parts_id;
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];
1596 record++;
1597 header->count++;
1598 }
1599
1600 record->part_id = -1;
1601 record->rot_y = -1;
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);
1607}
1608
1609void CEditGround::Load(char *data) {
1610 char buffer[4000];
1611 GROUND_SAVE_HEADER *header;
1612 char *file;
1613 SV_GRD_PART *record;
1614 SV_GRD_PART *records;
1615 int i;
1616
1617 Clear();
1618 file = buffer;
1619
1620 if (data == NULL) {
1621 if (!LoadFile2("gdata0.edt", file, NULL, 0)) {
1622 return;
1623 }
1624 } else {
1625 file = data;
1626 }
1627
1628 header = (GROUND_SAVE_HEADER *) file;
1629 records = (SV_GRD_PART *) (file + header->offset);
1630 // Parts that follow the ground's height go down first, then the rest, then the
1631 // parts that stand on others.
1632 record = records;
1633
1634 for (i = 0; i < header->count; i++, record++) {
1635 int parts_id = record->part_id;
1636
1637 if (parts_id < 0 || parts_id >= 24) {
1638 break;
1639 }
1640
1641 if (plot_parts[parts_id].ChangeAltData()) {
1642 float x = record->pos_x + 1.0f;
1643 float z = record->pos_z + 1.0f;
1644 SetMapParts(record->part_id, x, record->pos_y, z, record->rot_y);
1645 }
1646 }
1647
1648 record = records;
1649
1650 for (i = 0; i < header->count; i++, record++) {
1651 int parts_id = record->part_id;
1652
1653 if (parts_id < 0 || parts_id >= 24) {
1654 break;
1655 }
1656
1657 int kind = plot_parts[parts_id].subtype;
1658
1660 for (int j = 0; j < 24; j++) {
1661 if (plot_parts[j].subtype == MAP_PARTS_SUBTYPE_RIVER) {
1662 SetMapParts(j, record->pos_x + 1.0f, record->pos_y, record->pos_z + 1.0f, record->rot_y);
1663 break;
1664 }
1665 }
1666 } else {
1667 SetMapParts(parts_id, record->pos_x + 1.0f, record->pos_y, record->pos_z + 1.0f, record->rot_y);
1668 }
1669 }
1670
1671 record = records;
1672
1673 for (i = 0; i < header->count; i++, record++) {
1674 int parts_id = record->part_id;
1675
1676 if (parts_id < 0 || parts_id >= 24) {
1677 break;
1678 }
1679
1680 switch (plot_parts[parts_id].subtype) {
1683 SetMapParts(parts_id, record->pos_x + 1.0f, record->pos_y, record->pos_z + 1.0f, record->rot_y);
1684 break;
1685 }
1686 }
1687
1688 for (i = 0; i < 4; i++) {
1689 if (areas[i] != NULL) {
1690 areas[i]->RemakeGrid();
1691 areas[i]->RemakeGrid();
1692 }
1693 }
1694}
1695
1696void CEditGround::Save(int town, CSaveData *save) {
1697 sceVu0FVECTOR position;
1698 int count;
1699 int i;
1700
1701 SV_GRD_PART *record = save->GetParts(town, &count);
1702
1703 if (record == NULL) {
1704 return;
1705 }
1706
1707 for (i = 0; i < 128; i++) {
1708 CMapParts *object = &parts[i];
1709 int parts_id = parts[i].handle;
1710
1711 if (parts_id < 0) {
1712 continue;
1713 }
1714
1715 int j;
1716 int kind = object->subtype;
1717
1718 switch (kind) {
1722 for (j = 0; j < 24; j++) {
1723 if (kind == plot_parts[j].subtype) {
1724 parts_id = plot_parts[j].handle;
1725 break;
1726 }
1727 }
1728
1729 break;
1730 }
1731
1732 object->GetPosition(position);
1733 record->part_id = parts_id;
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];
1738 record++;
1739 }
1740
1741 record->part_id = -1;
1742 record->rot_y = -1;
1743 record->pos_x = 0.0f;
1744 record->pos_y = 0.0f;
1745 record->pos_z = 0.0f;
1746}
1747
1748void CEditGround::Load(int town, CSaveData *save) {
1749 char buffer[0x5000];
1750 int count;
1751 GROUND_SAVE_HEADER *header = (GROUND_SAVE_HEADER *) buffer;
1752 SV_GRD_PART *record = (SV_GRD_PART *) &buffer[sizeof(GROUND_SAVE_HEADER)];
1753
1754 SV_GRD_PART *saved = save->GetParts(town, &count);
1755
1756 if (saved == NULL) {
1757 return;
1758 }
1759
1760 header->count = count;
1761 header->offset = sizeof(GROUND_SAVE_HEADER);
1762
1763 for (int i = 0; i < count; saved++, record++, i++) {
1764 record->part_id = saved->part_id;
1765 record->rot_y = saved->rot_y;
1766 record->pos_x = saved->pos_x;
1767 record->pos_y = saved->pos_y;
1768 record->pos_z = saved->pos_z;
1769 }
1770
1771 record->part_id = -1;
1772 record->rot_y = -1;
1773 Load(buffer);
1774}
1775
1776int CEditGround::PickUpPoly(CCPoly *polygons, float x, float y, float z) {
1777 CBoxVu0 box;
1778
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;
1785 return PickUpPoly(polygons, box, 0);
1786}
1787
1788int CEditGround::PickUpPoly(CCPoly *out_polygons, CBoxVu0 box, int flags) {
1789 int i;
1790 int count = 0;
1791 CCPoly *polygons = out_polygons;
1792 CMapParts *object = parts;
1793 int found;
1794 CFrame *frame;
1795
1796 for (i = 0; i < 128; i++, object++) {
1797 if (object->handle < 0) {
1798 continue;
1799 }
1800
1801 if (flags != 0 && object->subtype == MAP_PARTS_SUBTYPE_NONE) {
1802 continue;
1803 }
1804
1805 frame = object->GetCollisionFrame();
1806
1807 if (frame == NULL) {
1808 continue;
1809 }
1810
1811 if (!object->CheckBox(&box)) {
1812 continue;
1813 }
1814
1815 found = frame->PickUpNearPoly(polygons, box);
1816 polygons += found;
1817 count += found;
1818 }
1819
1820 for (i = 0; i < 64; i++) {
1821 if (fixed_parts[i].handle < 0) {
1822 continue;
1823 }
1824
1825 CMapParts *fixed = &fixed_parts[i];
1826 frame = fixed->GetCollisionFrame();
1827
1828 if (frame == NULL) {
1829 continue;
1830 }
1831
1832 if (!fixed->CheckBox2(&box)) {
1833 continue;
1834 }
1835
1836 found = frame->PickUpNearPoly(polygons, box);
1837 polygons += found;
1838 count += found;
1839 }
1840
1841 for (i = 0; i < 4; i++) {
1842 if (areas[i] != NULL) {
1843 found = areas[i]->PickUpPoly(polygons, box);
1844 polygons += found;
1845 count += found;
1846 }
1847 }
1848
1849 return count;
1850}
1851
1852int CEditGround::PickUpEditAreaPoly(CCPoly *polygons, float x, float y, float z) {
1853 int area_no = GetAreaCode(x, y, z);
1854
1855 if (area_no < 0) {
1856 return 0;
1857 }
1858
1859 return areas[area_no]->PickUpPoly(polygons, x, y, z);
1860}
1861
1862int CEditGround::PickUpCameraPoly(CCPoly *out_polygons, CBoxVu0 &box, int flags) {
1863 int i;
1864 int count = 0;
1865 CCPoly *polygons = out_polygons;
1866 CMapParts *object = parts;
1867 CFrame *frame;
1868 int found;
1869 sceVu0FVECTOR center;
1870
1871 for (i = 0; i < 128 && (flags & 2); i++, object++) {
1872 if (object->handle < 0) {
1873 continue;
1874 }
1875
1876 frame = GetCameraFrame(object);
1877
1878 if (frame == NULL) {
1879 continue;
1880 }
1881
1882 if (!object->CheckBox(&box)) {
1883 continue;
1884 }
1885
1886 found = frame->PickUpNearPoly(polygons, box);
1887 polygons += found;
1888 count += found;
1889 }
1890
1891 for (i = 0; i < 64 && (flags & 1); i++) {
1892 if (fixed_parts[i].handle < 0) {
1893 continue;
1894 }
1895
1896 frame = GetCameraFrame(&fixed_parts[i]);
1897
1898 if (frame == NULL) {
1899 continue;
1900 }
1901
1902 if (!fixed_parts[i].CheckBox(&box)) {
1903 continue;
1904 }
1905
1906 found = frame->PickUpNearPoly(polygons, box);
1907 polygons += found;
1908 count += found;
1909 }
1910
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]);
1916 }
1917 }
1918
1919 return count;
1920}
1921
1923 int i;
1924
1925 for (i = 0; i < 128; i++) {
1926 parts[i].Initialize();
1927 }
1928
1929 for (i = 0; i < 4; i++) {
1930 if (areas[i] != NULL) {
1931 areas[i]->Clear();
1932 }
1933
1934 area_visible[i] = 1;
1935 }
1936
1937 effect_count = -1;
1938 effect_parts_id = -1;
1939 effect_alt = 0.0f;
1940 effect_target_alt = 0.0f;
1941 effect_step = 0.0f;
1942
1943 if (parts_info != NULL) {
1944 parts_info->Clear();
1945 }
1946
1947 if (map_no == TOWN_MATATAKI) {
1948 CVector3_f_ position;
1950 int saved = info->obtained;
1951
1952 info->stock += 6;
1953 info->obtained = 0;
1954 areas[0]->GetPos(&position, 5, 0, 0);
1955 SetMapParts(16, position.x, position.y, position.z, 0);
1956 areas[0]->GetPos(&position, 2, 0, 7);
1957 SetMapParts(16, position.x, position.y, position.z, 0);
1958 areas[1]->GetPos(&position, 3, 0, 5);
1959 SetMapParts(16, position.x, position.y, position.z, 0);
1960 areas[1]->GetPos(&position, 11, 0, 3);
1961 SetMapParts(16, position.x, position.y, position.z, 0);
1962 areas[2]->GetPos(&position, 4, 0, 0);
1963 SetMapParts(16, position.x, position.y, position.z, 0);
1964 areas[2]->GetPos(&position, 3, 0, 7);
1965 SetMapParts(16, position.x, position.y, position.z, 0);
1966 info->placed = false;
1967 info->stock -= 6;
1968 info->obtained = saved;
1969 }
1970}
1971
1973 map_no = TOWN_NORUNE;
1974 plot_parts = NULL;
1975 river_parts = NULL;
1976 road_parts = NULL;
1977 parts_info = NULL;
1978
1979 for (int area = 0; area < 4; area++) {
1980 areas[area] = NULL;
1981 area_visible[area] = 1;
1982 }
1983
1984 int i;
1985
1986 for (i = 0; i < 64; i++) {
1988 }
1989
1990 for (i = 0; i < 1; i++) {
1991 spare_words[i] = 0;
1992 }
1993
1994 for (i = 0; i < 4; i++) {
1995 water_surfaces[i].draw = false;
1996 }
1997
1998 for (i = 0; i < 128; i++) {
1999 people[i] = NULL;
2000 }
2001
2002 people_count = 0;
2003 suppress_water = false;
2004 Clear();
2005 clip_plane[3] = -1.0f;
2006}
2007
2009 for (int i = 0; i < 4; i++) {
2010 if (areas[i] != NULL) {
2011 areas[i]->grid_redraw = 1;
2012 }
2013 }
2014}
2015
2017 cursor.area = 0;
2018 people[0] = NULL;
2019 cursor.pieces[1] = NULL;
2020 cursor.pieces[0] = NULL;
2021 cursor.unit_size = 1.0f;
2022 Initialize();
2023}
2024
2032static int CheckDelete(CEditArea *area, CMapParts *parts, float x, float y, float z) {
2033 CVector3_i_ position;
2034
2035 area->GetPos(&position, x, y, z);
2036 int column = position.x;
2037 int row = position.z;
2038 int kind = parts->subtype;
2039
2040 switch (area->GetMapNo()) {
2041 case TOWN_MATATAKI:
2042 if (kind == MAP_PARTS_SUBTYPE_BRIDGE) {
2043 break;
2044 }
2045
2046 switch (area->GetAreaID()) {
2047 case 0:
2048 if (column == 5 && row == 0) {
2049 return 1;
2050 }
2051
2052 if (column == 2 && row == 7) {
2053 return 1;
2054 }
2055
2056 break;
2057 case 1:
2058 if (column == 3 && row == 5) {
2059 return 1;
2060 }
2061
2062 if (column == 11 && row == 3) {
2063 return 1;
2064 }
2065
2066 break;
2067 case 2:
2068 if (column == 4 && row == 0) {
2069 return 1;
2070 }
2071
2072 if (column == 3 && row == 7) {
2073 return 1;
2074 }
2075
2076 break;
2077 }
2078
2079 break;
2080 }
2081
2082 return 0;
2083}
2084
2085void CPartsCursor::Draw(float *position, int width, int height) {
2086 sceVu0FVECTOR cell;
2087 sceVu0FVECTOR corner;
2088 int i;
2089 int j;
2090 int columns = width * 2;
2091 int rows = height * 2;
2092
2093 sceVu0CopyVector(corner, position);
2094 corner[0] -= 0.5f * (unit_size * width);
2095 corner[2] -= 0.5f * (unit_size * height);
2096 corner[0] += 0.25f * unit_size;
2097 corner[2] += 0.25f * unit_size;
2098 sceVu0CopyVector(cell, corner);
2099
2100 for (i = 0; i < columns; i++) {
2101 cell[2] = corner[2];
2102
2103 for (j = 0; j < rows; j++) {
2104 int piece = 2;
2105 int turn = 0;
2106
2107 if (i == 0 && j == 0) {
2108 piece = 0;
2109 }
2110
2111 if (i > 0 && i < columns - 1 && j == 0) {
2112 piece = 1;
2113 turn = 2;
2114 }
2115
2116 if (i == columns - 1 && j == 0) {
2117 piece = 0;
2118 turn = -1;
2119 }
2120
2121 if (i == columns - 1 && j > 0 && j < rows - 1) {
2122 piece = 1;
2123 turn = 1;
2124 }
2125
2126 if (i == columns - 1 && j == rows - 1) {
2127 piece = 0;
2128 turn = 2;
2129 }
2130
2131 if (i > 0 && i < columns - 1 && j == rows - 1) {
2132 piece = 1;
2133 turn = 0;
2134 }
2135
2136 if (i == 0 && j == rows - 1) {
2137 piece = 0;
2138 turn = 1;
2139 }
2140
2141 if (i == 0 && j > 0 && j < rows - 1) {
2142 piece = 1;
2143 turn = -1;
2144 }
2145
2146 pieces[piece]->SetPosition(cell);
2147 pieces[piece]->SetRotation(0.0f, HALF_PI * turn, 0.0f);
2148 float scale = unit_size / 100.0f;
2149 pieces[piece]->SetScale(scale, scale, scale);
2150 MGDraw(pieces[piece]);
2151 cell[2] += 0.5f * unit_size;
2152 }
2153
2154 cell[0] += 0.5f * unit_size;
2155 }
2156}
2157
2159 CMapParts *placed[24][64];
2160 int plot_count[24];
2161 int i;
2162
2163 memset(placed, 0, sizeof(placed));
2164 CMapParts *object = parts;
2165
2166 for (i = 0; i < 24; i++) {
2167 plot_count[i] = 0;
2168 parts_info->request[i] = 0;
2169 }
2170
2171 for (i = 0; i < 128; i++, object++) {
2172 if (object->handle >= 0) {
2173 int plot = object->parts_no;
2174
2175 if (plot >= 0 && plot < 24) {
2176 placed[plot][plot_count[plot]++] = object;
2177 }
2178 }
2179 }
2180
2181 switch (map_no) {
2182 case TOWN_NORUNE:
2183 NornRequest(placed);
2184 break;
2185 case TOWN_MATATAKI:
2186 MatatagiRequest(placed);
2187 break;
2188 case TOWN_QUEENS:
2189 QueensRequest(placed);
2190 break;
2191 case TOWN_MUSKA_LACKA:
2192 MuskaRequest(placed);
2193 break;
2194 case TOWN_YELLOW_DROPS:
2195 YellowRequest(placed);
2196 break;
2197 }
2198
2199 for (i = 0; i < 24; i++) {
2200 if (!parts_info->CheckComplete(i)) {
2201 parts_info->request[i] = 0;
2202 }
2203 }
2204}
2205
2206int CEditGround::CheckPartsRect(int parts_no, int area_no, CRect_i_ &rect) {
2207 int parts_ids[256];
2208
2209 if (area_no < 0 || area_no >= 4) {
2210 return 0;
2211 }
2212
2213 if (areas[area_no] == NULL) {
2214 return 0;
2215 }
2216
2217 int count = areas[area_no]->GetPartsRect(rect, parts_ids, 256);
2218
2219 for (int i = 0; i < count; i++) {
2220 if (parts[parts_ids[i]].parts_no == parts_no) {
2221 return 1;
2222 }
2223 }
2224
2225 return 0;
2226}
2227
2228void CEditGround::GetRectParts(CRect_i_ *rect, CMapParts *target, int margin) {
2229 sceVu0FVECTOR position;
2230 CVector3_i_ grid;
2231
2232 *rect = CRect_i_(0, 0, 0, 0);
2233
2234 if (target == NULL) {
2235 return;
2236 }
2237
2238 target->GetPosition(position);
2239 int area_no = GetAreaCode(position[0], position[1], position[2]);
2240
2241 if (area_no < 0 || area_no >= 4) {
2242 return;
2243 }
2244
2245 if (areas[area_no] == NULL) {
2246 return;
2247 }
2248
2249 areas[area_no]->GetPos(&grid, position[0], position[1], position[2]);
2250 int width = target->GetWidth();
2251 int height = target->GetHeight();
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;
2258}
2259
2260void CEditGround::GetRectParts(CRect_i_ *rect, CMapParts *target, int column, int row) {
2261 sceVu0FVECTOR position;
2262 CVector3_i_ grid;
2263 int width;
2264 int height;
2265 int rot_y;
2266 int offset_x;
2267 int offset_z;
2268
2269 *rect = CRect_i_(0, 0, 0, 0);
2270
2271 if (target == NULL) {
2272 return;
2273 }
2274
2275 target->GetPosition(position);
2276 int area_no = GetAreaCode(position[0], position[1], position[2]);
2277
2278 if (area_no < 0 || area_no >= 4) {
2279 return;
2280 }
2281
2282 if (areas[area_no] == NULL) {
2283 return;
2284 }
2285
2286 areas[area_no]->GetPos(&grid, position[0], position[1], position[2]);
2287 rot_y = target->GetRotY();
2288 target->SetRotY(0);
2289 width = target->GetWidth();
2290 height = target->GetHeight();
2291 target->SetRotY(rot_y);
2292 column -= width >> 1;
2293 row -= height >> 1;
2294 int adjust_x = 0;
2295 int adjust_z = 0;
2296
2297 // A part with an even side has no centre cell, so turning it shifts the cells by one.
2298 if (width % 2 == 1 && height % 2 == 0) {
2299 if (rot_y == -1) {
2300 adjust_x = -1;
2301 }
2302
2303 if (rot_y == 2) {
2304 adjust_z = -1;
2305 }
2306 }
2307
2308 if (width % 2 == 0 && height % 2 == 1) {
2309 if (rot_y == 1) {
2310 adjust_z = -1;
2311 }
2312
2313 if (rot_y == 2) {
2314 adjust_x = -1;
2315 }
2316 }
2317
2318 if (width % 2 == 0 && height % 2 == 0) {
2319 if (rot_y == -1) {
2320 adjust_x = -1;
2321 }
2322
2323 if (rot_y == 1) {
2324 adjust_z = -1;
2325 }
2326
2327 if (rot_y == 2) {
2328 adjust_x = -1;
2329 adjust_z = -1;
2330 }
2331 }
2332
2333 switch (target->GetRotY()) {
2334 case 0:
2335 offset_x = column;
2336 offset_z = row;
2337 break;
2338 case 1:
2339 offset_x = row;
2340 offset_z = -column;
2341 break;
2342 case 2:
2343 offset_x = -column;
2344 offset_z = -row;
2345 break;
2346 case -1:
2347 offset_x = -row;
2348 offset_z = column;
2349 break;
2350 }
2351
2352 rect->x = grid.x + offset_x + adjust_x;
2353 rect->y = grid.z + offset_z + adjust_z;
2354 rect->width = 1;
2355 rect->height = 1;
2356}
2357
2361static inline int SpanStart(int &centre, int size) {
2362 int half = size >> 1;
2363 return centre - half;
2364}
2365
2366void CEditGround::GetRectDirParts(CRect_i_ *rect, CMapParts *target, int direction, int depth) {
2367 sceVu0FVECTOR position;
2368 CVector3_i_ grid;
2369
2370 *rect = CRect_i_(0, 0, 0, 0);
2371
2372 if (target == NULL) {
2373 return;
2374 }
2375
2376 target->GetPosition(position);
2377 int area_no = GetAreaCode(position[0], position[1], position[2]);
2378
2379 if (area_no < 0 || area_no >= 4) {
2380 return;
2381 }
2382
2383 if (areas[area_no] == NULL) {
2384 return;
2385 }
2386
2387 areas[area_no]->GetPos(&grid, position[0], position[1], position[2]);
2388 int width = target->GetWidth();
2389 int height = target->GetHeight();
2390 direction += target->GetRotY();
2391
2392 if (direction > 2) {
2393 direction -= 4;
2394 }
2395
2396 if (direction < -1) {
2397 direction += 4;
2398 }
2399
2400 if (direction < -1 || direction > 2) {
2401 return;
2402 }
2403
2404 if (direction % 2 != 0) {
2405 rect->width = depth;
2406 rect->height = height;
2407
2408 if (direction == 1) {
2409 rect->x = SpanStart(grid.x, width) - rect->width;
2410 rect->y = SpanStart(grid.z, height);
2411 } else {
2412 rect->x = width + SpanStart(grid.x, width);
2413 rect->y = SpanStart(grid.z, height);
2414 }
2415 } else {
2416 rect->width = width;
2417 rect->height = depth;
2418
2419 if (direction == 0) {
2420 rect->x = SpanStart(grid.x, width);
2421 rect->y = SpanStart(grid.z, height) - rect->height;
2422 } else {
2423 rect->x = SpanStart(grid.x, width);
2424 rect->y = height + SpanStart(grid.z, height);
2425 }
2426 }
2427}
2428
2430 parts_info->parts_max = 8;
2431
2432 if (areas[0] == NULL) {
2433 return;
2434 }
2435
2436 if (placed[0][0] != NULL && placed[0][0]->GetRotY() == 1) {
2437 parts_info->request[0] = 1;
2438 }
2439
2440 if (placed[1][0] != NULL) {
2441 if (CheckPartsRect(1, 0, CRect_i_(10, 0, 4, 5))) {
2442 parts_info->request[1] = 1;
2443 }
2444 }
2445
2446 if (placed[2][0] != NULL) {
2447 if (!CheckPartsRect(2, 0, CRect_i_(2, 8, 9, 4))) {
2448 parts_info->request[2] = 1;
2449 }
2450 }
2451
2452 if (placed[3][0] != NULL) {
2453 CRect_i_ rect;
2454 rect.x = rect.y = rect.width = rect.height = 0;
2455 GetRectParts(&rect, placed[12][0], 2);
2456
2457 if (CheckPartsRect(3, 0, rect)) {
2458 parts_info->request[3] = 1;
2459 }
2460 }
2461
2462 if (placed[4][0] != NULL) {
2463 CRect_i_ rect;
2464 rect.x = rect.y = rect.width = rect.height = 0;
2465 GetRectParts(&rect, placed[6][0], 4);
2466
2467 if (CheckPartsRect(4, 0, rect)) {
2468 parts_info->request[4] = 1;
2469 }
2470 }
2471
2472 if (placed[5][0] != NULL) {
2473 CRect_i_ rect;
2474 rect.x = rect.y = rect.width = rect.height = 0;
2475 GetRectDirParts(&rect, placed[8][0], 2, 4);
2476
2477 if (CheckPartsRect(5, 0, rect) && SaveData->GetGameIntFlag(0) >= 100) {
2478 parts_info->request[5] = 1;
2479 }
2480 }
2481
2482 if (placed[6][0] != NULL) {
2483 CRect_i_ rect;
2484 rect.x = rect.y = rect.width = rect.height = 0;
2485 GetRectParts(&rect, placed[1][0], 4);
2486
2487 if (!CheckPartsRect(6, 0, rect)) {
2488 parts_info->request[6] = 1;
2489 }
2490 }
2491
2492 if (placed[7][0] != NULL) {
2493 int parts_ids[256];
2494 CRect_i_ rect;
2495 rect.x = rect.y = rect.width = rect.height = 0;
2496 GetRectParts(&rect, placed[7][0], 4);
2497 int count = areas[0]->GetPartsRect(rect, parts_ids, 256);
2498 int houses = 0;
2499
2500 for (int i = 0; i < count; i++) {
2501 if (parts[parts_ids[i]].parts_no < 7) {
2502 houses++;
2503 }
2504
2505 if (houses >= 2) {
2506 parts_info->request[7] = 1;
2507 break;
2508 }
2509 }
2510 }
2511}
2512
2514 parts_info->parts_max = 10;
2515
2516 if (areas[0] == NULL || areas[1] == NULL || areas[2] == NULL) {
2517 return;
2518 }
2519
2520 areas[0]->ChainWorkClear();
2521 int chained = areas[0]->CheckRiverChain(5, 0, 2, 7);
2522 areas[1]->ChainWorkClear();
2523 chained &= areas[1]->CheckRiverChain(3, 5, 11, 3);
2524 areas[2]->ChainWorkClear();
2525 chained &= areas[2]->CheckRiverChain(4, 0, 3, 7);
2526
2527 if (chained) {
2528 parts_info->request[16] = 1;
2529 }
2530
2531 if (placed[0][0] != NULL) {
2532 if (CheckPartsRect(0, 0, CRect_i_(0, 0, 4, 1))) {
2533 parts_info->request[0] = 1;
2534 }
2535
2536 if (CheckPartsRect(0, 1, CRect_i_(0, 5, 1, 1))) {
2537 parts_info->request[0] = 1;
2538 }
2539 }
2540
2541 if (placed[1][0] != NULL) {
2542 int parts_ids[256];
2543 CRect_i_ rect;
2544 rect.x = rect.y = rect.width = rect.height = 0;
2545 GetRectParts(&rect, placed[1][0], 1);
2546 int count = areas[placed[1][0]->area]->GetPartsRect(rect, parts_ids, 256);
2547 int found = 0;
2548
2549 for (int i = 0; i < count; i++) {
2550 if (parts[parts_ids[i]].parts_no == 15) {
2551 found++;
2552 }
2553
2554 if (found >= 4) {
2555 parts_info->request[1] = 1;
2556 break;
2557 }
2558 }
2559 }
2560
2561 if (placed[2][0] != NULL) {
2562 CRect_i_ rect;
2563 rect.x = rect.y = rect.width = rect.height = 0;
2564 GetRectParts(&rect, placed[2][0], 3);
2565 int area_no = placed[2][0]->area;
2566
2567 if (CheckPartsRect(11, area_no, rect)) {
2568 parts_info->request[2] = 1;
2569 }
2570
2571 if (CheckPartsRect(12, area_no, rect)) {
2572 parts_info->request[2] = 1;
2573 }
2574
2575 if (CheckPartsRect(13, area_no, rect)) {
2576 parts_info->request[2] = 1;
2577 }
2578 }
2579
2580 if (placed[3][0] != NULL) {
2581 CRect_i_ rect;
2582 rect.x = rect.y = rect.width = rect.height = 0;
2583 GetRectParts(&rect, placed[3][0], 4);
2584 int area_no = placed[3][0]->area;
2585
2586 if (CheckPartsRect(14, area_no, rect)) {
2587 parts_info->request[3] = 1;
2588 }
2589 }
2590
2591 if (placed[4][0] != NULL) {
2592 if (CheckPartsRect(4, 2, CRect_i_(0, 5, 7, 3))) {
2593 parts_info->request[4] = 1;
2594 }
2595 }
2596
2597 if (placed[5][0] != NULL) {
2598 sceVu0FVECTOR position;
2599 placed[5][0]->GetPosition(position);
2600
2601 if (GetAlt_i(position[0], position[1], position[2]) > 0) {
2602 parts_info->request[5] = 1;
2603 }
2604 }
2605
2606 if (placed[6][0] != NULL && placed[3][0] != NULL) {
2607 CRect_i_ rect;
2608 rect.x = rect.y = rect.width = rect.height = 0;
2609 GetRectParts(&rect, placed[3][0], 3);
2610
2611 if (CheckPartsRect(6, placed[3][0]->area, rect)) {
2612 parts_info->request[6] = 1;
2613 }
2614 }
2615
2616 if (placed[7][0] != NULL) {
2617 sceVu0FVECTOR position;
2618 placed[7][0]->GetPosition(position);
2619
2620 if (GetAlt_i(position[0], position[1], position[2]) > 0) {
2621 parts_info->request[7] = 1;
2622 }
2623 }
2624
2625 if (placed[14][0] != NULL) {
2626 int parts_ids[256];
2627 CRect_i_ rect;
2628 rect.x = rect.y = rect.width = rect.height = 0;
2629 GetRectParts(&rect, placed[14][0], 1);
2630 int count = areas[placed[14][0]->area]->GetPartsRect(rect, parts_ids, 256);
2631 int found = 0;
2632
2633 for (int i = 0; i < count; i++) {
2634 int parts_no = parts[parts_ids[i]].parts_no;
2635
2636 if (parts_no == 16) {
2637 found++;
2638 }
2639
2640 if (parts_no == 17) {
2641 found++;
2642 }
2643
2644 if (parts_no == 11) {
2645 found++;
2646 }
2647
2648 if (parts_no == 12) {
2649 found++;
2650 }
2651
2652 if (parts_no == 13) {
2653 found++;
2654 }
2655
2656 if (found >= 14) {
2657 parts_info->request[14] = 1;
2658 break;
2659 }
2660 }
2661 }
2662}
2663
2665 parts_info->parts_max = 10;
2666
2667 if (areas[0] == NULL || areas[1] == NULL || areas[2] == NULL) {
2668 return;
2669 }
2670
2671 if (placed[0][0] != NULL) {
2672 if (CheckPartsRect(0, 1, CRect_i_(0, 0, 1, 7))) {
2673 parts_info->request[0] = 1;
2674 }
2675
2676 if (CheckPartsRect(0, 2, CRect_i_(0, 0, 1, 8))) {
2677 parts_info->request[0] = 1;
2678 }
2679 }
2680
2681 if (placed[1][0] != NULL && placed[10][0] != NULL) {
2682 CRect_i_ rect;
2683 rect.x = rect.y = rect.width = rect.height = 0;
2684 GetRectParts(&rect, placed[10][0], 3);
2685
2686 if (CheckPartsRect(1, placed[10][0]->area, rect)) {
2687 parts_info->request[1] = 1;
2688 }
2689 }
2690
2691 if (placed[2][0] != NULL && placed[8][0] != NULL) {
2692 CRect_i_ rect;
2693 rect.x = rect.y = rect.width = rect.height = 0;
2694 GetRectParts(&rect, placed[8][0], 2);
2695
2696 if (CheckPartsRect(2, placed[8][0]->area, rect)) {
2697 parts_info->request[2] = 1;
2698 }
2699 }
2700
2701 if (placed[3][0] != NULL && placed[1][0] != NULL) {
2702 CRect_i_ rect;
2703 rect.x = rect.y = rect.width = rect.height = 0;
2704 GetRectParts(&rect, placed[1][0], 2);
2705
2706 if (CheckPartsRect(3, placed[1][0]->area, rect)) {
2707 parts_info->request[3] = 1;
2708 }
2709 }
2710
2711 if (placed[4][0] != NULL) {
2712 if (placed[9][0] == NULL) {
2713 parts_info->request[4] = 1;
2714 } else if (placed[4][0]->area != placed[9][0]->area) {
2715 parts_info->request[4] = 1;
2716 }
2717 }
2718
2719 if (placed[5][0] != NULL && placed[5][0]->GetRotY() == 0) {
2720 parts_info->request[5] = 1;
2721 }
2722
2723 if (placed[6][0] != NULL && placed[11][0] != NULL && placed[6][0]->GetRotY() == -1) {
2724 CRect_i_ rect;
2725 rect.x = rect.y = rect.width = rect.height = 0;
2726 GetRectParts(&rect, placed[11][0], 3);
2727
2728 if (CheckPartsRect(6, placed[11][0]->area, rect)) {
2729 parts_info->request[6] = 1;
2730 }
2731 }
2732
2733 if (placed[7][0] != NULL && placed[7][0]->area == 0) {
2734 parts_info->request[7] = 1;
2735 }
2736
2737 if (placed[8][0] != NULL) {
2738 CRect_i_ rect;
2739 rect.x = rect.y = rect.width = rect.height = 0;
2740 GetRectParts(&rect, placed[8][0], 0, 3);
2741
2742 if (CheckPartsRect(13, placed[8][0]->area, rect)) {
2743 parts_info->request[8] = 1;
2744 }
2745 }
2746
2747 if (placed[9][0] != NULL && placed[8][0] != NULL) {
2748 CRect_i_ rect;
2749 rect.x = rect.y = rect.width = rect.height = 0;
2750 GetRectParts(&rect, placed[8][0], 1);
2751
2752 if (CheckPartsRect(9, placed[8][0]->area, rect)) {
2753 parts_info->request[9] = 1;
2754 }
2755 }
2756}
2757
2765static int CheckRot(CMapParts *parts, CMapParts *other, int rotation_offset) {
2766 int other_rotation;
2767 int rotation;
2768
2769 if (parts == NULL || other == NULL) {
2770 return 0;
2771 }
2772
2773 rotation = rotation_offset + parts->GetRotY();
2774 other_rotation = other->GetRotY();
2775
2776 if (rotation > 2) {
2777 rotation -= 4;
2778 }
2779
2780 if (rotation < -1) {
2781 rotation += 4;
2782 }
2783
2784 return rotation == other_rotation;
2785}
2786
2788 parts_info->parts_max = 9;
2789
2790 if (areas[0] == NULL) {
2791 return;
2792 }
2793
2794 if (placed[0][0] != NULL && placed[8][0] != NULL) {
2795 if (CheckPartsRect(0, 0, CRect_i_(1, 0, 6, 3))) {
2796 CRect_i_ rect;
2797 rect.x = rect.y = rect.width = rect.height = 0;
2798 GetRectDirParts(&rect, placed[0][0], 2, 14);
2799
2800 if (CheckPartsRect(8, 0, rect) && CheckRot(placed[0][0], placed[8][0], 1) && parts_info->GetCompEvent(0)) {
2801 parts_info->request[0] = 1;
2802 }
2803 }
2804 }
2805
2806 if (placed[1][0] != NULL && placed[10][0] != NULL) {
2807 CRect_i_ rect;
2808 rect.x = rect.y = rect.width = rect.height = 0;
2809 GetRectDirParts(&rect, placed[1][0], 2, 14);
2810
2811 if (CheckPartsRect(10, 0, rect) && CheckRot(placed[1][0], placed[10][0], 1)) {
2812 parts_info->request[1] = 1;
2813 }
2814 }
2815
2816 if (placed[2][0] != NULL && placed[9][0] != NULL) {
2817 CRect_i_ rect;
2818 rect.x = rect.y = rect.width = rect.height = 0;
2819 GetRectDirParts(&rect, placed[2][0], 2, 14);
2820
2821 if (CheckPartsRect(9, 0, rect) && CheckRot(placed[2][0], placed[9][0], 0)) {
2822 parts_info->request[2] = 1;
2823 }
2824 }
2825
2826 if (placed[3][0] != NULL && placed[9][0] != NULL) {
2827 CRect_i_ rect;
2828 rect.x = rect.y = rect.width = rect.height = 0;
2829 GetRectParts(&rect, placed[11][0], 2);
2830
2831 if (CheckPartsRect(3, 0, rect)) {
2832 CRect_i_ dir_rect;
2833 dir_rect.x = dir_rect.y = dir_rect.width = dir_rect.height = 0;
2834 GetRectDirParts(&dir_rect, placed[3][0], 2, 14);
2835
2836 if (CheckPartsRect(9, 0, dir_rect) && CheckRot(placed[3][0], placed[9][0], 2)) {
2837 parts_info->request[3] = 1;
2838 }
2839 }
2840 }
2841
2842 if (placed[4][0] != NULL && placed[9][0] != NULL) {
2843 CRect_i_ rect;
2844 rect.x = rect.y = rect.width = rect.height = 0;
2845 GetRectDirParts(&rect, placed[4][0], 2, 14);
2846
2847 if (CheckPartsRect(9, 0, rect) && CheckRot(placed[4][0], placed[9][0], 1)) {
2848 parts_info->request[4] = 1;
2849 }
2850 }
2851
2852 if (placed[5][0] != NULL && placed[10][0] != NULL) {
2853 CRect_i_ rect;
2854 rect.x = rect.y = rect.width = rect.height = 0;
2855 GetRectDirParts(&rect, placed[5][0], 2, 14);
2856
2857 if (CheckPartsRect(10, 0, rect) && CheckRot(placed[5][0], placed[10][0], 0)) {
2858 parts_info->request[5] = 1;
2859 }
2860 }
2861
2862 if (placed[6][0] != NULL && placed[8][0] != NULL) {
2863 CRect_i_ rect;
2864 rect.x = rect.y = rect.width = rect.height = 0;
2865 GetRectDirParts(&rect, placed[6][0], 2, 14);
2866
2867 if (CheckPartsRect(8, 0, rect) && CheckRot(placed[6][0], placed[8][0], 0) && placed[6][0]->GetRotY() == 1) {
2868 parts_info->request[6] = 1;
2869 }
2870 }
2871
2872 if (placed[7][0] != NULL && placed[8][0] != NULL) {
2873 CRect_i_ rect;
2874 rect.x = rect.y = rect.width = rect.height = 0;
2875 GetRectDirParts(&rect, placed[7][0], 2, 14);
2876
2877 if (CheckPartsRect(8, 0, rect) && CheckRot(placed[7][0], placed[8][0], 2)) {
2878 parts_info->request[7] = 1;
2879 }
2880 }
2881
2882 if (placed[10][0] != NULL) {
2883 if (CheckPartsRect(10, 0, CRect_i_(2, 0, 3, 14)) && placed[10][0]->GetRotY() == 0) {
2884 parts_info->request[10] = 1;
2885 }
2886 }
2887}
2888
2890 int unused[24];
2891 int i;
2892
2893 parts_info->parts_max = 13;
2894
2895 if (areas[0] == NULL) {
2896 return;
2897 }
2898
2899 for (int j = 0; j < 24; j++) {
2900 unused[j] = 0;
2901 }
2902
2903 if (CheckRot(placed[0][0], placed[7][0], 0)) {
2904 CRect_i_ rect;
2905 CRect_i_ other;
2906 rect.x = rect.y = rect.width = rect.height = 0;
2907 other.x = other.y = other.width = other.height = 0;
2908 GetRectParts(&rect, placed[0][0], 0, 2);
2909 GetRectParts(&other, placed[0][0], 1, 2);
2910
2911 if (CheckPartsRect(7, 0, rect) && CheckPartsRect(7, 0, other)) {
2912 parts_info->request[0] = 1;
2913 }
2914 }
2915
2916 if (CheckRot(placed[1][0], placed[5][0], 0)) {
2917 CRect_i_ rect;
2918 rect.x = rect.y = rect.width = rect.height = 0;
2919 GetRectParts(&rect, placed[1][0], 0, -1);
2920
2921 if (CheckPartsRect(5, 0, rect)) {
2922 parts_info->request[1] = 1;
2923 }
2924 }
2925
2926 if (CheckRot(placed[2][0], placed[6][0], 0)) {
2927 CRect_i_ rect;
2928 rect.x = rect.y = rect.width = rect.height = 0;
2929 GetRectParts(&rect, placed[2][0], 0, -1);
2930
2931 if (CheckPartsRect(6, 0, rect)) {
2932 parts_info->request[2] = 1;
2933 }
2934 }
2935
2936 if (CheckRot(placed[3][0], placed[7][0], 0)) {
2937 CRect_i_ rect;
2938 CRect_i_ other;
2939 rect.x = rect.y = rect.width = rect.height = 0;
2940 other.x = other.y = other.width = other.height = 0;
2941 GetRectParts(&rect, placed[3][0], 2, 1);
2942 GetRectParts(&other, placed[3][0], 2, 0);
2943
2944 if (CheckPartsRect(7, 0, rect) && !CheckPartsRect(7, 0, other)) {
2945 parts_info->request[3] = 1;
2946 }
2947 }
2948
2949 if (CheckRot(placed[4][0], placed[7][0], 0)) {
2950 CRect_i_ rect;
2951 CRect_i_ other;
2952 rect.x = rect.y = rect.width = rect.height = 0;
2953 other.x = other.y = other.width = other.height = 0;
2954 GetRectParts(&rect, placed[4][0], -1, 1);
2955 GetRectParts(&other, placed[4][0], -1, 0);
2956
2957 if (CheckPartsRect(7, 0, rect) && !CheckPartsRect(7, 0, other)) {
2958 parts_info->request[4] = 1;
2959 }
2960 }
2961
2962 if (CheckRot(placed[5][0], placed[3][0], 0)) {
2963 CRect_i_ rect;
2964 rect.x = rect.y = rect.width = rect.height = 0;
2965 GetRectParts(&rect, placed[3][0], 1, 2);
2966
2967 if (CheckPartsRect(5, 0, rect)) {
2968 parts_info->request[5] = 1;
2969 }
2970 }
2971
2972 if (CheckRot(placed[6][0], placed[4][0], 0)) {
2973 CRect_i_ rect;
2974 rect.x = rect.y = rect.width = rect.height = 0;
2975 GetRectParts(&rect, placed[4][0], 0, 2);
2976
2977 if (CheckPartsRect(6, 0, rect)) {
2978 parts_info->request[6] = 1;
2979 }
2980 }
2981
2982 if (placed[7][0] != NULL) {
2983 parts_info->request[7] = 1;
2984 }
2985
2986 if (CheckRot(placed[8][0], placed[7][0], 0)) {
2987 CRect_i_ rect;
2988 CRect_i_ other;
2989 rect.x = rect.y = rect.width = rect.height = 0;
2990 other.x = other.y = other.width = other.height = 0;
2991 GetRectParts(&rect, placed[8][0], 0, -1);
2992 GetRectParts(&other, placed[8][0], 1, -1);
2993
2994 if (CheckPartsRect(7, 0, rect) && CheckPartsRect(7, 0, other)) {
2995 parts_info->request[8] = 1;
2996 }
2997 }
2998
2999 if (CheckRot(placed[9][0], placed[8][0], 0)) {
3000 CRect_i_ rect;
3001 rect.x = rect.y = rect.width = rect.height = 0;
3002 GetRectParts(&rect, placed[8][0], 0, 1);
3003
3004 if (CheckPartsRect(9, 0, rect)) {
3005 parts_info->request[9] = 1;
3006 }
3007 }
3008
3009 if (CheckRot(placed[10][0], placed[8][0], 0)) {
3010 CRect_i_ rect;
3011 rect.x = rect.y = rect.width = rect.height = 0;
3012 GetRectParts(&rect, placed[8][0], 1, 1);
3013
3014 if (CheckPartsRect(10, 0, rect)) {
3015 parts_info->request[10] = 1;
3016 }
3017 }
3018
3019 if (CheckRot(placed[11][0], placed[9][0], 0)) {
3020 CRect_i_ rect;
3021 rect.x = rect.y = rect.width = rect.height = 0;
3022 GetRectParts(&rect, placed[11][0], 0, -1);
3023
3024 if (CheckPartsRect(9, 0, rect)) {
3025 parts_info->request[11] = 1;
3026 }
3027 }
3028
3029 if (CheckRot(placed[12][0], placed[10][0], 0)) {
3030 CRect_i_ rect;
3031 rect.x = rect.y = rect.width = rect.height = 0;
3032 GetRectParts(&rect, placed[12][0], 0, -1);
3033
3034 if (CheckPartsRect(10, 0, rect)) {
3035 parts_info->request[12] = 1;
3036 }
3037 }
3038
3039 for (i = 0; i < 24; i++) {
3040 int on = 2;
3041 this->plot_parts[i].FrameObjectOnOff("setuzoku", on);
3042
3043 if (placed[i][0] != NULL) {
3044 sceVu0FVECTOR position;
3045 placed[i][0]->GetPosition(position);
3046
3047 if (parts_info->request[i] && position[1] < 1.0f) {
3048 on = 1;
3049 }
3050
3051 this->plot_parts[i].FrameObjectOnOff("setuzoku", on);
3052 }
3053 }
3054}
sceVu0FVECTOR min
Definition collision.hpp:29
sceVu0FVECTOR max
Definition collision.hpp:28
void GetRef(float *ref)
Definition camera.cpp:234
void GetPos(float *pos)
Definition camera.cpp:230
void GetDir(float *dir)
Definition camera.cpp:147
int GetMapNo()
int SearchPartsID(float x, float y, float z)
Definition editarea.cpp:586
void GetOffset(float *offset)
void Clear()
float GetAlt(int x, int y)
Definition editarea.cpp:182
void GetPartsBox(CBoxVu0 *box)
Definition editarea.cpp:648
void DrawGrid()
void ChainWorkClear()
Definition editarea.cpp:962
int GetAlt_i(int x, int y)
Definition editarea.cpp:170
int DeleteMapParts(int parts_no, CMapParts *parts, float x, float y, float z)
Definition editarea.cpp:290
void RemakeGrid()
Definition editarea.cpp:604
void MakePartsBox()
Definition editarea.cpp:652
int GetHeight()
int CheckAreaRect(float x, float y, float z, int rect_width, int rect_height)
Definition editarea.cpp:713
int GetWidth()
int SearchPartsExtra(float x, float y, float z)
Definition editarea.cpp:592
int grid_redraw
Definition editarea.hpp:52
int PickUpPoly(CCPoly *polygons, float x, float y, float z)
Definition editarea.cpp:849
float GetUnitAlt()
int CheckRiverChain(int x, int y, int target_x, int target_y)
Definition editarea.cpp:970
int SetRiverParts(int x, int y)
Definition editarea.cpp:336
float GetUnitSize()
int GetPartsID(int x, int y)
Definition editarea.cpp:126
int SetMapParts(int parts_id, CMapParts *parts, float x, float y, float z, int rot_y)
Definition editarea.cpp:254
int GetPartsRect(CRect_i_ &rect, int *parts_ids, int capacity)
Definition editarea.cpp:927
int GetAreaID()
void GetPos(CVector3_i_ *position, float x, float y, float z)
Definition editarea.cpp:61
int CheckParts(CMapParts *parts, float x, float y, float z, int rotation)
Definition editarea.cpp:738
int SetRoadParts(int x, int y)
Definition editarea.cpp:466
s32 spare_words[1]
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)
CMapParts * river_parts
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)
void RequestCheck()
float GetAlt(float x, float y, float z)
CMapParts * road_parts
CEditArea * areas[4]
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)
void DrawBaseGround()
int CheckEffect()
void EffectTask()
EPARTS_FUNC_DATA * people[128]
void Initialize()
int SetFocusParts(float x, float y, float z)
void Save(char *path)
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)
CMapParts * plot_parts
int GetAlt_i(float x, float y, float z)
int GetPartsID(float x, float y, float z)
s32 area_visible[4]
sceVu0FVECTOR clip_plane
int PickUpPoly(CCPoly *polygons, float x, float y, float z)
void YellowRequest(CMapParts *(*placed)[64])
void Load(char *data)
void GetRectDirParts(CRect_i_ *rect, CMapParts *target, int direction, int depth)
void DrawWater(int pass)
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])
float effect_target_alt
float effect_step
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)
CPartsCursor cursor
CMapParts parts[128]
void MakePartsBox()
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)
void RemakeGrid()
int GetCompEvent(int index)
int CheckComplete(int index)
EDITPARTS_INFO * GetPartsInfo(int index)
short draw_on
Definition frame.hpp:27
CFrameAttr attr
Definition frame.hpp:65
char name[32]
GROUND_WATER_RIPPLE ripples[4]
sceVu0FVECTOR offset
int handle
Definition op_b.cpp:96
CFrameVu1 * shadow_frame
Definition op_b.cpp:91
int category_no
Definition title.cpp:134
CFrameVu1 * shade_frame
Definition op_b.cpp:92
CFrame * GetCollisionFrame()
Definition mapobject.cpp:12
CFrameVu1 * camera_frame
Definition op_b.cpp:93
void DrawShade()
s32 parts_no
Definition mapparts.hpp:51
virtual void SetPosition(float *position)
Definition mapparts.cpp:20
int ChangeDigData()
Definition mapparts.cpp:183
int GetHeight()
Definition mapparts.cpp:111
void SetRotY(int direction)
Definition mapparts.cpp:36
CFrame * ripple_frame
Definition mapparts.hpp:56
s32 subtype
Definition mapparts.hpp:61
void Initialize()
Definition mapparts.cpp:50
int CheckBox2(CBoxVu0 *box)
Definition mapparts.cpp:241
int GetWidth()
Definition mapparts.cpp:94
float unit_size
Definition mapparts.hpp:69
CBoxVu0 bound
Definition mapparts.hpp:67
int CheckBox(CBoxVu0 *box)
Definition mapparts.cpp:206
s32 preview_frame
Definition mapparts.hpp:54
void DrawParts(float time, float *distance, int lowest, int highest, int *out_level)
Definition mapparts.cpp:335
s32 blocked_preview_frame
Definition mapparts.hpp:55
virtual void FrameObjectOnOff(char *name, int on)
Definition mapparts.cpp:80
int GetRotY()
Definition mapparts.cpp:46
void GetPosition(float *out_position)
Definition mapparts.cpp:16
float draw_distance
Definition mapparts.hpp:63
void DrawEffect(CCamera *camera, float time, CEffectGroup *group)
Definition mapparts.cpp:446
EDITPARTS_INFO * info
Definition mapparts.hpp:57
CFrameVu1 * frame[4]
Definition op_b.cpp:76
s32 draw_on
Definition op_b.cpp:78
virtual void GetRotation(float *out_rotation)
Definition object.cpp:116
CVector3_f_ rotation
Definition object.hpp:23
float pos[4]
Definition object.hpp:18
void Draw(float *position, int width, int height)
CFrame * pieces[3]
s32 x
Definition rect.hpp:18
s32 width
Definition rect.hpp:20
s32 height
Definition rect.hpp:21
s32 y
Definition rect.hpp:19
SV_GRD_PART * GetParts(int georama_no, int *out_count)
Definition savedata.cpp:195
int GetGameIntFlag(int flag_no)
Definition savedata.cpp:310
int CheckClip()
Definition water.cpp:303
s32 rows
Definition op_c.cpp:137
CFrameVu1 frame
Definition op_c.cpp:151
@ MAP_PARTS_SUBTYPE_RIVER
Definition mapparts.hpp:20
@ MAP_PARTS_SUBTYPE_NONE
Definition mapparts.hpp:18
@ MAP_PARTS_SUBTYPE_LAKE
Definition mapparts.hpp:22
@ MAP_PARTS_SUBTYPE_ROAD
Definition mapparts.hpp:19
@ MAP_PARTS_SUBTYPE_ON_RIVER
Definition mapparts.hpp:23
@ MAP_PARTS_SUBTYPE_BRIDGE
Definition mapparts.hpp:21
CMapParts * parts
Definition objanime.hpp:100
sceVu0FVECTOR position
Definition objanime.hpp:107
sceVu0FVECTOR rotation
Definition objanime.hpp:108
sceVu0FMATRIX view_scaled
float pos_x
Definition savedata.hpp:78
float pos_y
Definition savedata.hpp:79
float pos_z
Definition savedata.hpp:80