|
| 1 | +#include "zMovePoint.h" |
| 2 | +#include "zNPCSupplement.h" |
| 3 | + |
| 4 | +#include "xEvent.h" |
| 5 | + |
| 6 | +#include <types.h> |
| 7 | + |
| 8 | +// PORTED DIRECTLY FROM BFBB |
| 9 | + |
| 10 | +extern zMovePoint* g_mvpt_list; |
| 11 | +extern S32 g_mvpt_cnt; |
| 12 | +extern F32 lbl_803CDD40; |
| 13 | +extern F32 lbl_803CDD44; |
| 14 | + |
| 15 | +// Random load word at the end of the function for some reason. |
| 16 | +zMovePoint* zMovePoint_GetMemPool(S32 cnt) |
| 17 | +{ |
| 18 | + /*if (cnt != 0) |
| 19 | + { |
| 20 | + g_mvpt_list = (zMovePoint*)xMemAllocSize(cnt * sizeof(zMovePoint)); |
| 21 | + } |
| 22 | + else |
| 23 | + { |
| 24 | + g_mvpt_list = NULL; |
| 25 | + } |
| 26 | + g_mvpt_cnt = cnt; |
| 27 | + return g_mvpt_list;*/ |
| 28 | + |
| 29 | + g_mvpt_list = cnt ? (zMovePoint*)xMemAllocSize(cnt * sizeof(zMovePoint)) : NULL; |
| 30 | + g_mvpt_cnt = cnt; |
| 31 | + return g_mvpt_list; |
| 32 | +} |
| 33 | + |
| 34 | +void zMovePointInit(zMovePoint* m, xMovePointAsset* asset) |
| 35 | +{ |
| 36 | + xMovePointInit((xMovePoint*)m, asset); |
| 37 | + m->eventFunc = zMovePointEventCB; |
| 38 | + if (m->linkCount) |
| 39 | + { |
| 40 | + m->link = |
| 41 | + (xLinkAsset*)(((U32*)asset + sizeof(xMovePointAsset) / 4) + (U32)asset->numPoints); |
| 42 | + } |
| 43 | + else |
| 44 | + { |
| 45 | + m->link = NULL; |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +zMovePoint* zMovePoint_GetInst(S32 n) |
| 50 | +{ |
| 51 | + return &g_mvpt_list[n]; |
| 52 | +} |
| 53 | + |
| 54 | +void zMovePointSetup(zMovePoint* mvpt, zScene* scn) |
| 55 | +{ |
| 56 | + xMovePointSetup((xMovePoint*)mvpt, (xScene*)scn); |
| 57 | +} |
| 58 | + |
| 59 | +zMovePoint* zMovePoint_From_xAssetID(U32 aid) |
| 60 | +{ |
| 61 | + zMovePoint* pnt = g_mvpt_list; |
| 62 | + zMovePoint* ret = NULL; |
| 63 | + for (S32 i = g_mvpt_cnt; i > 0; i--) |
| 64 | + { |
| 65 | + if (pnt->asset->id == aid) |
| 66 | + { |
| 67 | + ret = pnt; |
| 68 | + break; |
| 69 | + } |
| 70 | + pnt++; |
| 71 | + } |
| 72 | + return ret; |
| 73 | +} |
| 74 | + |
| 75 | +void zMovePointSave(zMovePoint* ent, xSerial* s) |
| 76 | +{ |
| 77 | + xMovePointSave((xMovePoint*)ent, s); |
| 78 | +} |
| 79 | + |
| 80 | +void zMovePointLoad(zMovePoint* ent, xSerial* s) |
| 81 | +{ |
| 82 | + xMovePointLoad((xMovePoint*)ent, s); |
| 83 | +} |
| 84 | + |
| 85 | +void zMovePointReset(zMovePoint* m) |
| 86 | +{ |
| 87 | + xMovePointReset((xMovePoint*)m); |
| 88 | +} |
| 89 | + |
| 90 | +S32 zMovePointEventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, xBase* b3) |
| 91 | +{ |
| 92 | + switch (toEvent) |
| 93 | + { |
| 94 | + case eEventOn: |
| 95 | + ((zMovePoint*)to)->on = true; |
| 96 | + break; |
| 97 | + case eEventOff: |
| 98 | + ((zMovePoint*)to)->on = false; |
| 99 | + break; |
| 100 | + case eEventArrive: |
| 101 | + break; |
| 102 | + case eEventReset: |
| 103 | + zMovePointReset((zMovePoint*)to); |
| 104 | + break; |
| 105 | + case eEventMakeASplash: |
| 106 | + xVec3* pos = ((zMovePoint*)to)->pos; |
| 107 | + if (pos != NULL) |
| 108 | + { |
| 109 | + if (*toParam < lbl_803CDD40) |
| 110 | + { |
| 111 | + NPCC_MakeASplash(pos, lbl_803CDD44); |
| 112 | + } |
| 113 | + else |
| 114 | + { |
| 115 | + NPCC_MakeASplash(pos, *toParam); |
| 116 | + } |
| 117 | + } |
| 118 | + break; |
| 119 | + } |
| 120 | + return eEventEnable; |
| 121 | +} |
| 122 | + |
| 123 | +F32 zMovePointGetNext(const zMovePoint* current, const zMovePoint* prev, zMovePoint** next, |
| 124 | + xVec3* hdng) |
| 125 | +{ |
| 126 | + return xMovePointGetNext((xMovePoint*)current, (xMovePoint*)prev, (xMovePoint**)next, hdng); |
| 127 | +} |
| 128 | + |
| 129 | +xVec3* zMovePointGetPos(const zMovePoint* m) |
| 130 | +{ |
| 131 | + return xMovePointGetPos((xMovePoint*)m); |
| 132 | +} |
| 133 | + |
| 134 | +F32 zMovePointGetDelay(const zMovePoint* m) |
| 135 | +{ |
| 136 | + return xMovePointGetDelay((xMovePoint*)m); |
| 137 | +} |
| 138 | + |
| 139 | +F32 xMovePointGetDelay(const xMovePoint* m) |
| 140 | +{ |
| 141 | + return m->delay; |
| 142 | +} |
0 commit comments