-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
113 lines (88 loc) · 2.58 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <thread>
#include <chrono>
#include "pbdtypes.h"
#include "gamepine.h"
void SetPosWithFudge(GamePine& pine, const tVec3& vec) {
tVec3 copy = vec;
copy.x += 15.0f; // fudge
std::cout << strfmt("setting pos to (%f, %f, %f)\n", copy.x, copy.y, copy.z);
pine.SetRiderSpeedMult(0.0);
pine.SetRiderPosition(copy);
}
int main(int argc, char** argv) {
if(argc != 2) {
std::cout << strfmt("usage: \"%s\" [path to PBD file]\n", argv[0]);
std::cout << strfmt("needs PCSX2 with PINE enabled to function\n");
return 1;
}
std::ifstream ifs(argv[1], std::ifstream::binary);
if(!ifs) {
std::cout << "couldnt open\n";
return 1;
}
GamePine pine;
tPbdHeader header;
if(!ReadInto(ifs, header)) {
std::cout << "couldnt read header\n";
return 1;
}
#if 1
std::cout << strfmt("splines at offset %d\n", header.SplineOffset);
ifs.seekg(header.SplineOffset, std::ifstream::beg);
std::vector<tSpline> splines(header.NumSplines);
for(int i = 0; i < header.NumSplines; ++i) {
if(!ReadInto(ifs,splines[i])) {
std::cout << strfmt("couldnt read spline %d\n", i);
return 1;
} else {
// dump again?
}
}
// Writer loop
for(int i = 0; i < header.NumSplines; ++i) {
try {
SetPosWithFudge(pine, splines[i].points[0]);
//std::cout << strfmt("Setting to point finished. Waiting 2 secs\n");
std::this_thread::sleep_for(std::chrono::milliseconds(950));
SetPosWithFudge(pine, splines[i].points[1]);
//std::cout << strfmt("Setting to point finished. Waiting 2 secs\n");
std::this_thread::sleep_for(std::chrono::milliseconds(950));
} catch(...) {
std::cout << strfmt("Trying to set to point failed :(\n");
break;
}
}
#endif
// Spline segments
#if 1
ifs.seekg(header.SplineSegmentOffset, std::ifstream::beg);
std::vector<tSplineSegment> segments(header.NumSplineSegments);
for(int i = 0; i < header.NumSplineSegments; ++i) {
if(!ReadInto(ifs,segments[i])) {
std::cout << strfmt("couldnt read spline %d\n", i);
return 1;
} else {
//segments[i].Dump(std::cout);
}
}
// Another writer loop
for(int i = 0; i < header.NumSplineSegments; ++i) {
// all of the even ones are wildly broken for some reason
// so skip past them as a hack
if((i % 2))
continue;
try {
SetPosWithFudge(pine, segments[i].matrix.AsVec3());
//std::cout << strfmt("Setting to point finished.\n");
std::this_thread::sleep_for(std::chrono::milliseconds(1500));
} catch(...) {
std::cout << strfmt("Trying to set to point failed :(\n");
break;
}
}
#endif
}