Commit MetaInfo

Revisiona538245bbf7628654b3de833d4eacd5ca3691c1e (tree)
Time2014-05-14 21:30:39
AuthorFace
CommiterFace

Log Message

Initial commit with first release version

Change Summary

Incremental Difference

diff -r 000000000000 -r a538245bbf76 Config/Hyperspace.cfg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Config/Hyperspace.cfg Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,15 @@
1+; === Configuration file for vessel class dummy ===
2+ClassName = Hyperspace
3+MeshName = Hyperspace
4+Size = 1000
5+
6+Mass = 1e-3 ; empty mass [kg]
7+Inertia = 0.1 0.1 0.1
8+CrossSections = 0.1 0.1 0.1
9+PropellantResource1 = 1
10+Isp = 1e5
11+
12+MaxAttitudeThrust = 0
13+MaxAttitudeRotAccel = 0
14+RotResistance = 0.1 0.1 0.1
15+
diff -r 000000000000 -r a538245bbf76 Doc/JumpDriveMFD.pdf
Binary file Doc/JumpDriveMFD.pdf has changed
diff -r 000000000000 -r a538245bbf76 JumpDriveMFDReadme.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/JumpDriveMFDReadme.txt Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,82 @@
1+=========================================================
2+ JumpDriveMFD
3+=========================================================
4+(C) Friedrich Kastner-Masilko, M.Sc. - August, 5th 2006
5+ face@snoopie.at - http://www.snoopie.at/face/omp
6+---------------------------------------------------------
7+History:
8+
9+V1.0 - Oct, 14th 2006:
10+ First public release
11+---------------------------------------------------------
12+Description:
13+
14+This Orbiter module provides hyper-jump capabilities for
15+every vessel in your scenario. To make travelling with a
16+jump-drive more challenging, the jumping distance is
17+fixed (although adjustable via INI file).
18+Therefore, to get near your target, you have to think
19+about the course of the jump. The integrated navigation
20+computer helps you with this task.
21+---------------------------------------------------------
22+Content:
23+
24+\
25+ JumpDriveMFDReadme.txt - This file
26+\Doc
27+ JumpDriveMFD.pdf - MFD manual
28+\Config
29+ Hyperspace.cfg - Configuration file for the
30+ hyperspace fake vessel
31+\Meshes
32+ Hyperspace.msh - Mesh for the hyperspace
33+ fake vessel
34+\Scenarios
35+ JumpDriveShow.scn - Demonstration scenario
36+\Modules\Plugin
37+ JumpDriveMFD.dll - Jump drive MFD plugin
38+\Sound\JumpDriveMFD
39+ bang.wav - The jump bang sound
40+ woosh1.wav - Acceleration sound
41+ woosh2.wav - Deceleration sound
42+ engage.wav - Click sound
43+ cancel.wav - Cancel/Error sound
44+ load.wav - Cell charging sound
45+\Orbitersdk\samples\JumpDriveMFD
46+ JumpDriveMFD.dsw - Visual C++ 6.0 workspace file
47+ JumpDriveMFD.dsp - Visual C++ 6.0 project file
48+ JumpDriveMFD.cpp - C++ source file MFD
49+ JumpDriveMFD.h - C++ header file MFD
50+ JumpDrive.cpp - C++ source file Drive
51+ JumpDrive.h - C++ header file Drive
52+ HashTable.cpp - C++ source file Hashtable
53+ HashTable.h - C++ header file Hashtable
54+ HashData.cpp - C++ source file Hashdata
55+ HashData.h - C++ header file Hashdata
56+ copyright - Copyright notice (MIT)
57+---------------------------------------------------------
58+Installation:
59+
60+Extract the archive with your Orbiter folder as base
61+folder and be sure to enable the "use path information"
62+feature of your favorite extraction tool.
63+
64+Be sure to read the copyright before you start using the
65+source code!
66+---------------------------------------------------------
67+Usage:
68+
69+Activate the plugin in the 'Modules' tab. The new MFD
70+mode is called "JumpDrive" and is persistent w.r.t MFDs
71+and vessels.
72+
73+Refer to the manual for details on usage and navigation.
74+---------------------------------------------------------
75+Known Bugs:
76+
77+Due to limitations in OrbiterSound3, the MFD and jump
78+drive sounds only work, if the MFD mode is selected right
79+from start of the scenario. Please check out the scenario
80+"JumpDriveShow" which comes with this distribution.
81+You can still use the MFD mode, if you didn't have such
82+a scenario, but you will not hear anything.
\ No newline at end of file
diff -r 000000000000 -r a538245bbf76 Meshes/Hyperspace.msh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Meshes/Hyperspace.msh Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,30 @@
1+MSHX1
2+GROUPS 1
3+MATERIAL 0
4+TEXTURE 0
5+GEOM 12 4
6+0 0.005 0.005
7+0 -0.005 -0.005
8+0.005 0.005 -0.005
9+0 0.005 0.005
10+0.005 0.005 -0.005
11+-0.005 0.005 -0.005
12+-0.005 0.005 -0.005
13+0 -0.005 -0.005
14+0 0.005 0.005
15+-0.005 0.005 -0.005
16+0.005 0.005 -0.005
17+0 -0.005 -0.005
18+0 1 2
19+3 4 5
20+6 7 8
21+9 10 11
22+MATERIALS 1
23+mat1
24+MATERIAL mat1
25+0 0 0 0
26+0 0 0 0
27+0 0 0 0
28+0 0 0 0
29+TEXTURES 1
30+0
diff -r 000000000000 -r a538245bbf76 Modules/Plugin/JumpDriveMFD.dll
Binary file Modules/Plugin/JumpDriveMFD.dll has changed
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/HashData.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/HashData.cpp Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,23 @@
1+/**************************************************************************
2+ * OMPServer - HashData class implementation
3+ * created: Jun., 8th 2004
4+ * last update: Sep., 17th 2005
5+ * Copyright (c) 2005 Friedrich Kastner-Masilko, M.Sc.
6+ **************************************************************************/
7+
8+#include "HashData.h"
9+
10+//////////////////////////////////////////////////////////////////////
11+// Construction/Destruction
12+//////////////////////////////////////////////////////////////////////
13+
14+CHashData::CHashData()
15+{
16+ data=0;
17+ next=0;
18+ key=0;
19+}
20+
21+CHashData::~CHashData()
22+{
23+}
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/HashData.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/HashData.h Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,16 @@
1+/**************************************************************************
2+ * OMPServer - HashData class declaration
3+ * created: Jun., 8th 2004
4+ * last update: Sep., 17th 2005
5+ * Copyright (c) 2005 Friedrich Kastner-Masilko, M.Sc.
6+ **************************************************************************/
7+
8+class CHashData
9+{
10+public:
11+ void *data;
12+ CHashData *next;
13+ char *key;
14+ CHashData();
15+ virtual ~CHashData();
16+};
\ No newline at end of file
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/HashTable.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/HashTable.cpp Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,325 @@
1+/**************************************************************************
2+ * OMPServer - HashTable class implementation
3+ * created: Jun., 8th 2004
4+ * last update: Sep., 17th 2005
5+ * Copyright (c) 2005 Friedrich Kastner-Masilko, M.Sc.
6+ **************************************************************************/
7+
8+#include "HashTable.h"
9+#include "HashData.h"
10+#include <string.h>
11+
12+//////////////////////////////////////////////////////////////////////
13+// Construction/Destruction
14+//////////////////////////////////////////////////////////////////////
15+
16+CHashTable::CHashTable(unsigned short int power_of_2)
17+{
18+ HashTable=new CHashData[HashSize= HASHSIZE(power_of_2)];
19+ empty=true;
20+ count=0;
21+ count_inner=0;
22+}
23+
24+CHashTable::~CHashTable()
25+{
26+ delete [] HashTable;
27+}
28+
29+//////////////////////////////////////////////////////////////////////
30+// HashTable functions
31+//////////////////////////////////////////////////////////////////////
32+
33+void *CHashTable::put(char *putkey, void *newentry)
34+{
35+ if (putkey==0) return 0;
36+ unsigned long int position=hash((unsigned char *) putkey, strlen(putkey), 0);
37+ position&=HashSize-1;
38+ CHashData *entry=&HashTable[position];
39+ empty=false;
40+ if (entry->key!=0)
41+ {
42+ int res;
43+ while ((res=strcmp(putkey, entry->key))!=0 && entry->next!=0) entry=entry->next;
44+ if (res==0)
45+ {
46+ void *oldentry=entry->data;
47+ entry->data=newentry;
48+ return oldentry;
49+ }
50+ else
51+ {
52+ CHashData *addentry=new CHashData();
53+ addentry->key=new char[strlen(putkey)+1];
54+ strcpy(addentry->key,putkey);
55+ addentry->data=newentry;
56+ addentry->next=0;
57+ entry->next=addentry;
58+ count+=1;
59+ return 0;
60+ }
61+ }
62+ else
63+ {
64+ entry->key=new char[strlen(putkey)+1];
65+ strcpy(entry->key,putkey);
66+ entry->data=newentry;
67+ entry->next=0;
68+ count+=1;
69+ count_inner+=1;
70+ return 0;
71+ }
72+}
73+
74+void *CHashTable::get(char *getkey)
75+{
76+ if (getkey==0) return 0;
77+ unsigned long int position=hash((unsigned char *) getkey, strlen(getkey), 0);
78+ position&=HashSize-1;
79+ CHashData *entry=&HashTable[position];
80+ int res=1;
81+ if (entry->key!=0) while ((res=strcmp(getkey, entry->key))!=0 && entry->next!=0) entry=entry->next;
82+ if (res==0) return entry->data; else return 0;
83+}
84+
85+void *CHashTable::del(char *getkey)
86+{
87+ if (getkey==0) return 0;
88+ unsigned long int position=hash((unsigned char *) getkey, strlen(getkey), 0);
89+ position&=HashSize-1;
90+ CHashData *entry=&HashTable[position];
91+ CHashData *nextentry=entry->next;
92+ void *oldentry;
93+ if (entry->key!=0)
94+ {
95+ if (strcmp(getkey, entry->key)==0)
96+ {
97+ oldentry=entry->data;
98+ delete [] entry->key;
99+ if (nextentry!=0)
100+ {
101+ entry->data=nextentry->data;
102+ entry->key=nextentry->key;
103+ entry->next=nextentry->next;
104+ delete nextentry;
105+ }
106+ else
107+ {
108+ entry->data=0;
109+ entry->key=0;
110+ count_inner-=1;
111+ }
112+ count-=1;
113+ if (count==0) empty=true;
114+ return oldentry;
115+ }
116+ else if (nextentry!=0)
117+ {
118+ int res;
119+ while ((res=strcmp(getkey, nextentry->key))!=0 && nextentry->next!=0)
120+ {
121+ entry=nextentry;
122+ nextentry=nextentry->next;
123+ }
124+ if (res==0)
125+ {
126+ oldentry=nextentry->data;
127+ delete [] nextentry->key;
128+ entry->next=nextentry->next;
129+ delete nextentry;
130+ count-=1;
131+ if (count==0) empty=true;
132+ return oldentry;
133+ }
134+ }
135+ }
136+ return 0;
137+}
138+
139+void *CHashTable::clear(bool startover)
140+{
141+ if (startover || last_clear_point<0 || last_clear_point>=HashSize) last_clear_point=0;
142+ CHashData *entry=&HashTable[last_clear_point];
143+ CHashData *nextentry=entry->next;
144+ void *oldentry=entry->data;
145+ unsigned long int loop_entry_point=last_clear_point;
146+ while (entry->key==0 && nextentry==0)
147+ {
148+ last_clear_point+=1;
149+ if (last_clear_point>=HashSize) last_clear_point=0;
150+ if (last_clear_point==loop_entry_point) return 0;
151+ entry=&HashTable[last_clear_point];
152+ nextentry=entry->next;
153+ oldentry=entry->data;
154+ }
155+ delete [] entry->key;
156+ if (nextentry!=0)
157+ {
158+ entry->data=nextentry->data;
159+ entry->key=nextentry->key;
160+ entry->next=nextentry->next;
161+ delete nextentry;
162+ }
163+ else
164+ {
165+ entry->data=0;
166+ entry->key=0;
167+ last_clear_point+=1;
168+ count_inner-=1;
169+ }
170+ count-=1;
171+ if (count==0) empty=true;
172+ return oldentry;
173+}
174+
175+CHashData *CHashTable::content(unsigned long int bucket)
176+{
177+
178+ if (bucket<0 || bucket>=HashSize) return 0;
179+ return &HashTable[bucket];
180+}
181+
182+unsigned long int CHashTable::get_size()
183+{
184+ return HashSize;
185+}
186+
187+float CHashTable::get_ratio()
188+{
189+ if (count==0) return 1.0;
190+ unsigned long int longest_run=1, current_run;
191+ CHashData *entry;
192+ for(int i=0;i<(int)HashSize;i++)
193+ {
194+ current_run=1;
195+ entry=&HashTable[i];
196+ while (entry->next!=0)
197+ {
198+ current_run+=1;
199+ entry=entry->next;
200+ }
201+ if (current_run>longest_run) longest_run=current_run;
202+ }
203+ return ((float)HashSize)/((float)longest_run)*((float)count_inner)/((float)count);
204+}
205+
206+unsigned long int CHashTable::get_count()
207+{
208+ return count;
209+}
210+
211+//////////////////////////////////////////////////////////////////////
212+// Hash function
213+//////////////////////////////////////////////////////////////////////
214+
215+/*
216+--------------------------------------------------------------------
217+mix -- mix 3 32-bit values reversibly.
218+For every delta with one or two bits set, and the deltas of all three
219+ high bits or all three low bits, whether the original value of a,b,c
220+ is almost all zero or is uniformly distributed,
221+* If mix() is run forward or backward, at least 32 bits in a,b,c
222+ have at least 1/4 probability of changing.
223+* If mix() is run forward, every bit of c will change between 1/3 and
224+ 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
225+mix() was built out of 36 single-cycle latency instructions in a
226+ structure that could supported 2x parallelism, like so:
227+ a -= b;
228+ a -= c; x = (c>>13);
229+ b -= c; a ^= x;
230+ b -= a; x = (a<<8);
231+ c -= a; b ^= x;
232+ c -= b; x = (b>>13);
233+ ...
234+ Unfortunately, superscalar Pentiums and Sparcs can't take advantage
235+ of that parallelism. They've also turned some of those single-cycle
236+ latency instructions into multi-cycle latency instructions. Still,
237+ this is the fastest good hash I could find. There were about 2^^68
238+ to choose from. I only looked at a billion or so.
239+--------------------------------------------------------------------
240+*/
241+#define mix(a,b,c) \
242+{ \
243+ a -= b; a -= c; a ^= (c>>13); \
244+ b -= c; b -= a; b ^= (a<<8); \
245+ c -= a; c -= b; c ^= (b>>13); \
246+ a -= b; a -= c; a ^= (c>>12); \
247+ b -= c; b -= a; b ^= (a<<16); \
248+ c -= a; c -= b; c ^= (b>>5); \
249+ a -= b; a -= c; a ^= (c>>3); \
250+ b -= c; b -= a; b ^= (a<<10); \
251+ c -= a; c -= b; c ^= (b>>15); \
252+}
253+
254+/*
255+--------------------------------------------------------------------
256+hash() -- hash a variable-length key into a 32-bit value
257+ k : the key (the unaligned variable-length array of bytes)
258+ len : the length of the key, counting by bytes
259+ initval : can be any 4-byte value
260+Returns a 32-bit value. Every bit of the key affects every bit of
261+the return value. Every 1-bit and 2-bit delta achieves avalanche.
262+About 6*len+35 instructions.
263+
264+The best hash table sizes are powers of 2. There is no need to do
265+mod a prime (mod is sooo slow!). If you need less than 32 bits,
266+use a bitmask. For example, if you need only 10 bits, do
267+ h = (h & hashmask(10));
268+In which case, the hash table should have hashsize(10) elements.
269+
270+If you are hashing n strings (unsigned char **)k, do it like this:
271+ for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
272+
273+By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
274+code any way you wish, private, educational, or commercial. It's free.
275+
276+See http://burtleburtle.net/bob/hash/evahash.html
277+Use for hash table lookup, or anything where one collision in 2^^32 is
278+acceptable. Do NOT use for cryptographic purposes.
279+--------------------------------------------------------------------
280+*/
281+
282+unsigned long int CHashTable::hash(register unsigned char *k, register unsigned long int length, register unsigned long int initval)
283+//register unsigned char *k; /* the key */
284+//register unsigned long int length; /* the length of the key */
285+//register unsigned long int initval; /* the previous hash, or an arbitrary value */
286+{
287+ register unsigned long int a,b,c,len;
288+
289+ /* Set up the internal state */
290+ len = length;
291+ a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
292+ c = initval; /* the previous hash value */
293+
294+ /*---------------------------------------- handle most of the key */
295+ while (len >= 12)
296+ {
297+ a += (k[0] +((unsigned long int)k[1]<<8) +((unsigned long int)k[2]<<16) +((unsigned long int)k[3]<<24));
298+ b += (k[4] +((unsigned long int)k[5]<<8) +((unsigned long int)k[6]<<16) +((unsigned long int)k[7]<<24));
299+ c += (k[8] +((unsigned long int)k[9]<<8) +((unsigned long int)k[10]<<16)+((unsigned long int)k[11]<<24));
300+ mix(a,b,c);
301+ k += 12; len -= 12;
302+ }
303+
304+ /*------------------------------------- handle the last 11 bytes */
305+ c += length;
306+ switch(len) /* all the case statements fall through */
307+ {
308+ case 11: c+=((unsigned long int)k[10]<<24);
309+ case 10: c+=((unsigned long int)k[9]<<16);
310+ case 9 : c+=((unsigned long int)k[8]<<8);
311+ /* the first byte of c is reserved for the length */
312+ case 8 : b+=((unsigned long int)k[7]<<24);
313+ case 7 : b+=((unsigned long int)k[6]<<16);
314+ case 6 : b+=((unsigned long int)k[5]<<8);
315+ case 5 : b+=k[4];
316+ case 4 : a+=((unsigned long int)k[3]<<24);
317+ case 3 : a+=((unsigned long int)k[2]<<16);
318+ case 2 : a+=((unsigned long int)k[1]<<8);
319+ case 1 : a+=k[0];
320+ /* case 0: nothing left to add */
321+ }
322+ mix(a,b,c);
323+ /*-------------------------------------------- report the result */
324+ return c;
325+}
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/HashTable.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/HashTable.h Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,34 @@
1+/**************************************************************************
2+ * OMPServer - HashTable class declaration
3+ * created: Jun., 8th 2004
4+ * last update: Sep., 17th 2005
5+ * Copyright (c) 2005 Friedrich Kastner-Masilko, M.Sc.
6+ **************************************************************************/
7+
8+#define HASHSIZE(n) ((unsigned long int)1<<(n))
9+
10+class CHashData;
11+class CHashTable
12+{
13+public:
14+ CHashTable(unsigned short int power_of_2);
15+ void *put(char *putkey, void *newentry);
16+ void *get(char *getkey);
17+ void *del(char *getkey);
18+ void *clear(bool startover);
19+ CHashData *content(unsigned long int bucket);
20+ unsigned long int get_size();
21+ float get_ratio();
22+ unsigned long int get_count();
23+ virtual ~CHashTable();
24+ bool empty;
25+
26+private:
27+ CHashData *HashTable;
28+ unsigned long int HashSize;
29+ unsigned long int count_inner;
30+ unsigned long int count;
31+ unsigned long int last_clear_point;
32+ unsigned long int hash(register unsigned char *k, register unsigned long int length, register unsigned long int initval);
33+
34+};
\ No newline at end of file
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/JumpDrive.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDrive.cpp Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,371 @@
1+/**************************************************************************
2+ * JumpDriveMFD V1.0 - FTL travel in a difficult fashion for O2K6
3+ * created: July, 6th 2006
4+ * last update: September, 10th 2006
5+ * Copyright (c) 2006 Friedrich Kastner-Masilko, M.Sc.
6+ *
7+ * JumpDrive class header
8+ **************************************************************************/
9+
10+// Trigonimetric definitions
11+#define TAN70 2.747477419
12+#define RAD90 1.570796327
13+#define RAD70 1.221730476
14+
15+// Time definitions
16+#define ACCTIME 3.6
17+#define FLYTIME 2.1
18+#define JMPTIME 1.6
19+#define DECTIME 7.3
20+
21+// Drive states
22+#define S_IDLE 0
23+#define S_LOAD 1
24+#define S_ACCELERATE 2
25+#define S_CRUISE 3
26+#define S_JUMP 4
27+#define S_DECELERATE 5
28+
29+// Includes
30+#include "windows.h"
31+#include "orbitersdk.h"
32+#include "orbitersoundsdk3.h"
33+#include "JumpDrive.h"
34+#include <stdio.h>
35+
36+// Constructor - Creates a drive with the given data
37+JumpDrive::JumpDrive(JumpDriveData data)
38+{
39+ this->vessel=data.vessel;
40+ this->sound=data.sound;
41+ this->env=data.env;
42+ this->loadtime=data.loadtime;
43+ this->capacity=data.capacity;
44+ this->offset=data.offset;
45+ this->jump=data.jump;
46+ this->speed=data.speed;
47+ this->cells=data.cells;
48+ filledCells=0;
49+ object=vessel->GetHandle();
50+ addvec=_V(0,1,0);
51+ engaged=0;
52+ oldRVEL=_V(0,0,0);
53+ target=_V(0,0,0);
54+ state=S_IDLE;
55+ beacon.shape=BEACONSHAPE_STAR;
56+ beacon.pos=&beaconpos;
57+ beacon.col=&beaconcol;
58+ beacon.size=1.0;
59+ beacon.falloff=1;
60+ beacon.period=0;
61+ beacon.duration=0;
62+ beacon.tofs=0;
63+ beacon.active=true;
64+ beaconcol=_V(1,1,1);
65+ reference=oapiGetGbodyByIndex(0);
66+ snd_load =data.soundSlot[0];
67+ snd_wooshout=data.soundSlot[1];
68+ snd_bang =data.soundSlot[2];
69+ snd_wooshin =data.soundSlot[3];
70+ fuel=0;
71+ fuelSource=0;
72+}
73+
74+// Destructor - removes the internal jump range table
75+JumpDrive::~JumpDrive()
76+{
77+ delete [] jump;
78+}
79+
80+//Sets the current fuel source index
81+void JumpDrive::SetFuelSource(int index)
82+{
83+ fuelSource=index;
84+}
85+
86+//Returns the current fuel source index
87+int JumpDrive::GetFuelSource()
88+{
89+ return fuelSource;
90+}
91+
92+//Returns amount of available fuel cells
93+int JumpDrive::GetFuelCells()
94+{
95+ return cells;
96+}
97+
98+//Returns amount of filled fuel cells
99+int JumpDrive::GetFilledCells()
100+{
101+ return filledCells;
102+}
103+
104+//Returns internal fuel level (0-1)
105+double JumpDrive::GetFuel()
106+{
107+ return fuel;
108+}
109+
110+//Returns current jump range in meters
111+double JumpDrive::GetJumpRange(int cells)
112+{
113+ return jump[cells];
114+}
115+
116+//Returns the sound handle
117+int JumpDrive::GetSoundHandle()
118+{
119+ return sound;
120+}
121+
122+//Starts a jump procedure if jump is possible.
123+bool JumpDrive::Start()
124+{
125+ if (isJumpPossible())
126+ {
127+ VECTOR3 vec;
128+ vessel->GlobalRot(_V(0,0,speed), addvec);
129+ vessel->GlobalRot(_V(0,0,jump[filledCells]), target);
130+ engaged=oapiGetSimTime();
131+ if (oapiCameraTarget()==object)
132+ {
133+ env->FOV=oapiCameraAperture();
134+ env->Reset=false;
135+ }
136+ vessel->GetRelativeVel(reference, oldRVEL);
137+ vessel->GetRelativePos(reference, vec);
138+ target+=vec;
139+ state=S_ACCELERATE;
140+ PlayVesselWave3(sound,snd_wooshout,NOLOOP,255);
141+ fuel=0.99;
142+ filledCells=0;
143+ return true;
144+ }
145+ return false;
146+}
147+
148+//Starts a loading procedure
149+bool JumpDrive::Load()
150+{
151+ PROPELLANT_HANDLE propellant=vessel->GetPropellantHandleByIndex(fuelSource);
152+ if (propellant!=NULL)
153+ {
154+ double mass=vessel->GetPropellantMass(propellant);
155+ if (mass>0.0 && (fuel<=0.0 || (fuel>=1.0 && filledCells+1<cells)))
156+ {
157+ if (fuel>=1.0) filledCells++;
158+ fuel=0.0;
159+ state=S_LOAD;
160+ return true;
161+ }
162+ }
163+ return false;
164+}
165+
166+//Engages a fleet command to the current drive's owner with the commanding
167+//vessel in parameter 1 and the command range in meters in parameter 2
168+void JumpDrive::FleetCommand(VESSEL *vessel, double treshold)
169+{
170+ if (isJumpPossible())
171+ {
172+ VECTOR3 d;
173+ oapiGetRelativePos (this->object, vessel->GetHandle(), &d);
174+ if (length(d)<treshold)
175+ {
176+ vessel->GetGlobalOrientation(d);
177+ this->vessel->SetGlobalOrientation(d);
178+ Start();
179+ }
180+ }
181+}
182+
183+//Returns wether or not the vessel is currently jumping
184+bool JumpDrive::Jumping()
185+{
186+ return state>S_LOAD;
187+}
188+
189+//Returns wether or not a jump is possible
190+bool JumpDrive::isJumpPossible()
191+{
192+ if (fuel<1.0) return false;
193+ return (vessel->GetFlightStatus() & 0x02)==0;/*Alternative implementation:
194+ int i=0;
195+ DOCKHANDLE dock;
196+ while(true)
197+ {
198+ dock=vessel->GetDockHandle(i++);
199+ if (dock==NULL) return true;
200+ if (vessel->GetDockStatus(dock)!=NULL) return false;
201+ }*/
202+}
203+
204+//Delete all docked vessels from the parent recursively
205+void JumpDrive::deleteVessels(VESSEL *vessel, OBJHANDLE parent)
206+{
207+ int i=0;
208+ DOCKHANDLE dock;
209+ OBJHANDLE dockHandle;
210+ VESSEL *child;
211+ while(true)
212+ {
213+ dock=vessel->GetDockHandle(i++);
214+ if (dock==NULL) break;
215+ if ((dockHandle=vessel->GetDockStatus(dock))!=NULL)
216+ {
217+ if (dockHandle!=parent)
218+ {
219+ deleteVessels((child=new VESSEL(dockHandle, 1)), vessel->GetHandle());
220+ delete child;
221+ oapiDeleteVessel(dockHandle);
222+ }
223+ }
224+ }
225+}
226+
227+//Processing jump drive progress - should be called periodically
228+void JumpDrive::Process(double SimT,double SimDT)
229+{
230+ OBJHANDLE cam=oapiCameraTarget();
231+ double diff;
232+ //Loading a cell
233+ if (state==S_LOAD)
234+ {
235+ PROPELLANT_HANDLE propellant=vessel->GetPropellantHandleByIndex(fuelSource);
236+ if (propellant!=NULL)
237+ {
238+ double mass=vessel->GetPropellantMass(propellant);
239+ if (mass>0)
240+ {
241+ diff=SimDT/loadtime;
242+ if (diff>(1.0-fuel))
243+ {
244+ diff=1.0-fuel;
245+ state=S_IDLE;
246+ }
247+ if (diff>mass/capacity) diff=mass/capacity;
248+ fuel+=diff;
249+ mass-=diff*capacity;
250+ vessel->SetPropellantMass(propellant, mass);
251+ if (state!=S_LOAD) StopVesselWave3(sound, snd_load);
252+ else PlayVesselWave3(sound,snd_load,LOOP,255);
253+ }
254+ else StopVesselWave3(sound, snd_load);
255+ }
256+ else StopVesselWave3(sound, snd_load);
257+ }
258+ if (state>S_LOAD)
259+ {
260+ diff=SimT-engaged;
261+ VESSELSTATUS2 status;
262+ status.version=2;
263+ status.flag=0;
264+ double temp=(RAD90+RAD70)/2;
265+ switch(state)
266+ {
267+ //Accelerating to jump speed
268+ case S_ACCELERATE:
269+ if (diff>ACCTIME)
270+ {
271+ engaged=SimT;
272+ state=S_CRUISE;
273+ }
274+ else
275+ {
276+ vessel->GetStatusEx(&status);
277+ temp=diff/ACCTIME;
278+ status.rvel+=addvec*SimDT*temp;
279+ vessel->DefSetStateEx(&status);
280+ fuel=0.99-temp*0.2;
281+ temp=(RAD90+temp*RAD70)/2;
282+ }
283+ break;
284+ //Cruise at jump speed
285+ case S_CRUISE:
286+ if (diff>FLYTIME)
287+ {
288+ vessel->GetStatusEx(&status);
289+ hyperobjectIn=oapiCreateVesselEx("Hyperspace","Hyperspace",&status);
290+ vessel->GetRelativeVel(reference, status.rvel);
291+ status.rpos=target;
292+ status.rbody=reference;
293+ vessel->DefSetStateEx(&status);
294+ PlayVesselWave3(sound,snd_bang,NOLOOP,255);
295+ engaged=SimT;
296+ state=S_JUMP;
297+ hyperobjectOut=oapiCreateVesselEx("Hyperspace","Hyperspace",&status);
298+ hyperspaceIn=oapiGetVesselInterface(hyperobjectIn);
299+ hyperspaceOut=oapiGetVesselInterface(hyperobjectOut);
300+ hyperspaceIn->SetVisibilityLimit(1e-12);
301+ hyperspaceOut->SetVisibilityLimit(1e-12);
302+ vessel->GetCameraOffset(beaconpos);
303+ beaconpos.z+=offset;
304+ hyperspaceIn->AddBeacon(&beacon);
305+ hyperspaceOut->AddBeacon(&beacon);
306+ //Delete all docked vessels (hyperspace physics are dangerous, you know...)
307+ deleteVessels(vessel, NULL);
308+ }
309+ else
310+ {
311+
312+ }
313+ break;
314+ //Explosion effect
315+ case S_JUMP:
316+ if (diff>JMPTIME)
317+ {
318+ PlayVesselWave3(sound,snd_wooshin,NOLOOP,255);
319+ engaged=SimT;
320+ state=S_DECELERATE;
321+ oapiDeleteVessel(hyperobjectIn);
322+ oapiDeleteVessel(hyperobjectOut);
323+ fuel=0.2;
324+ }
325+ else
326+ {
327+ if (diff>0.3) diff=0;
328+ else diff/=0.3;
329+ if (diff!=0) diff=1/diff/diff;
330+ beacon.size=diff*10;
331+ }
332+ break;
333+ //Decelerating from jump speed
334+ case S_DECELERATE:
335+ if (diff>DECTIME)
336+ {
337+ vessel->GetStatusEx(&status);
338+ vessel->GetRelativeVel(reference, status.rvel);
339+ vessel->GetRelativePos(reference, status.rpos);
340+ status.rbody=reference;
341+ status.rvel=oldRVEL;
342+ vessel->DefSetStateEx(&status);
343+ temp=env->FOV;
344+ state=S_IDLE;
345+ fuel=0;
346+ }
347+ else
348+ {
349+ vessel->GetStatusEx(&status);
350+ temp=(DECTIME-diff)/DECTIME/2;
351+ status.rvel-=addvec*SimDT*temp;
352+ vessel->DefSetStateEx(&status);
353+ fuel=temp*0.4;
354+ temp=(RAD90+temp*RAD70*2)/2;
355+ }
356+ break;
357+ }
358+ //Setting FOV if jumping vessel has focus
359+ if (cam==object)
360+ {
361+ oapiCameraSetAperture(temp);
362+ env->Reset=false;
363+ }
364+ }
365+ else if (cam==object && !env->Reset)
366+ {
367+ //Reseting FOV to environment setting if no jumping vessel has focus
368+ oapiCameraSetAperture(env->FOV);
369+ env->Reset=true;
370+ }
371+}
\ No newline at end of file
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/JumpDrive.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDrive.h Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,148 @@
1+/**************************************************************************
2+ * JumpDriveMFD V1.0 - FTL travel in a difficult fashion for O2K6
3+ * created: July, 6th 2006
4+ * last update: September, 10th 2006
5+ * Copyright (c) 2006 Friedrich Kastner-Masilko, M.Sc.
6+ *
7+ * JumpDrive class header
8+ **************************************************************************/
9+
10+#if !defined(AFX_JUMPDRIVE_H__ABA580C1_0C57_11DB_BD29_0002442A51E7__INCLUDED_)
11+#define AFX_JUMPDRIVE_H__ABA580C1_0C57_11DB_BD29_0002442A51E7__INCLUDED_
12+
13+#if _MSC_VER > 1000
14+#pragma once
15+#endif // _MSC_VER > 1000
16+
17+//The variables for the FOV effect are stored here
18+struct Environment
19+{
20+ //The currently used (unaffected) FOV
21+ double FOV;
22+ //Flag for reseting the FOV
23+ bool Reset;
24+};
25+
26+//Data for drive construction
27+struct JumpDriveData
28+{
29+ //Link to vessel instance
30+ VESSEL *vessel;
31+ //Link to environment
32+ Environment *env;
33+ //Available cells
34+ int cells;
35+ //Sound handle
36+ int sound;
37+ //Sound slot definition
38+ int *soundSlot;
39+ //Jump speed used
40+ double speed;
41+ //Jump length
42+ double *jump;
43+ //Explosion effect view point offset
44+ double offset;
45+ //Time to load one cell
46+ double loadtime;
47+ //Capacity of one cell
48+ double capacity;
49+};
50+
51+//The JumpDrive class
52+class JumpDrive
53+{
54+public:
55+ //Constructor
56+ JumpDrive(JumpDriveData data);
57+ //Destructor
58+ ~JumpDrive();
59+ //Processing jump drive progress - should be called periodically
60+ void Process (double SimT,double SimDT);
61+ //Starts a jump procedure
62+ bool Start ();
63+ //Starts a loading procedure
64+ bool Load ();
65+ //Sets the current fuel source index
66+ void SetFuelSource(int index);
67+ //Returns the current fuel source index
68+ int GetFuelSource();
69+ //Returns amount of available fuel cells
70+ int GetFuelCells();
71+ //Returns amount of filled fuel cells
72+ int GetFilledCells();
73+ //Returns internal fuel level (0-1)
74+ double GetFuel();
75+ //Returns current jump range in meters
76+ double GetJumpRange(int cells);
77+ //Returns the sound handle
78+ int GetSoundHandle();
79+ //Engages a fleet command to the current drive's owner with the commanding
80+ //vessel in parameter 1 and the command range in meters in parameter 2
81+ void FleetCommand(VESSEL *vessel, double treshold);
82+ //Returns wether or not the vessel is currently jumping
83+ bool Jumping();
84+private:
85+ //Returns wether or not a jump is possible
86+ bool isJumpPossible();
87+ //Delete all docked vessels from the parent recursively
88+ void deleteVessels(VESSEL *vessel, OBJHANDLE parent);
89+ //The linked vessel
90+ VESSEL *vessel;
91+ //The fake vessel for hyperspace entry
92+ VESSEL *hyperspaceIn;
93+ //The fake vessel for hyperspace leaving
94+ VESSEL *hyperspaceOut;
95+ //The linked vessel object
96+ OBJHANDLE object;
97+ //The object handle of the fake entry vessel
98+ OBJHANDLE hyperobjectIn;
99+ //The object handle of the fake leaving vessel
100+ OBJHANDLE hyperobjectOut;
101+ //The reference Gbody of the vessel
102+ OBJHANDLE reference;
103+ //Jump acceleration vector
104+ VECTOR3 addvec;
105+ //Memory for conserving relative velocity vector
106+ VECTOR3 oldRVEL;
107+ //Jump target position
108+ VECTOR3 target;
109+ //Position of beacon for explosion effect
110+ VECTOR3 beaconpos;
111+ //Color of beacon for explosion effect
112+ VECTOR3 beaconcol;
113+ //Sound slots
114+ int snd_load;
115+ int snd_wooshout;
116+ int snd_bang;
117+ int snd_wooshin;
118+ //Current selected fuel source index
119+ int fuelSource;
120+ //Sound handle
121+ int sound;
122+ //Amount of available cells
123+ int cells;
124+ //Amount of filled cells
125+ int filledCells;
126+ //Drive state
127+ unsigned char state;
128+ //Time stamp of jump start
129+ double engaged;
130+ //Acceleration speed
131+ double speed;
132+ //Jump length
133+ double *jump;
134+ //Explosion effect view point offset
135+ double offset;
136+ //Time to load one cell
137+ double loadtime;
138+ //Capacity of one cell
139+ double capacity;
140+ //Internal fuel level
141+ double fuel;
142+ //Link to environment
143+ Environment *env;
144+ //Beacon for explosion effect
145+ BEACONLIGHTSPEC beacon;
146+};
147+
148+#endif // !defined(AFX_JUMPDRIVE_H__ABA580C1_0C57_11DB_BD29_0002442A51E7__INCLUDED_)
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.cpp Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,774 @@
1+/**************************************************************************
2+ * JumpDriveMFD V1.0 - FTL travel in a difficult fashion for O2K6
3+ * created: July, 6th 2006
4+ * last update: September, 10th 2006
5+ * Copyright (c) 2006 Friedrich Kastner-Masilko, M.Sc.
6+ *
7+ * JumpDriveMFD class
8+ **************************************************************************/
9+
10+// Standard module defines
11+#define STRICT
12+#define ORBITER_MODULE
13+
14+// Plugin additional files
15+#define LOADWAV "Sound\\JumpDriveMFD\\load.wav"
16+#define ENGAGEWAV "Sound\\JumpDriveMFD\\engage.wav"
17+#define WOOSHOUTWAV "Sound\\JumpDriveMFD\\woosh1.wav"
18+#define BANGWAV "Sound\\JumpDriveMFD\\bang.wav"
19+#define WOOSHINWAV "Sound\\JumpDriveMFD\\woosh2.wav"
20+#define CANCELWAV "Sound\\JumpDriveMFD\\cancel.wav"
21+#define INIFILE "Modules\\Plugin\\JumpDriveMFD.ini"
22+
23+// Plugin defines
24+#define LOAD 50
25+#define ENGAGE 51
26+#define WOOSHOUT 52
27+#define BANG 53
28+#define WOOSHIN 54
29+#define CHARGE 55
30+#define ASTROUNIT 1.49598E11
31+#define MODES 10
32+#define MAXCHARS 255
33+
34+// Includes
35+#include "windows.h"
36+#include "orbitersdk.h"
37+#include "orbitersoundsdk3.h"
38+#include "HashTable.h"
39+#include "HashData.h"
40+#include "JumpDrive.h"
41+#include "JumpDriveMFD.h"
42+#include <stdio.h>
43+
44+// Global variables
45+int g_MFDmode; // identifier for new MFD mode
46+CHashTable *g_JumpDrives; // static hash table for drive instances
47+CHashTable *g_JumpDriveMFDs; // static hash table for MFD instances
48+unsigned long g_bucket, g_index, g_size;// used for drive hash table iteration
49+Environment g_Environment; // static environment structure
50+HBRUSH g_Bar; // used for drawing
51+COLORREF g_MiddleGreen; // used for drawing
52+
53+// Configurable settings
54+ int JUMPDRIVES = 4;
55+ int JUMPDRIVEMFDS = 4;
56+double JUMPVEL = 5E4;
57+double FLASHOFFSET = 1E1;
58+double JUMPPOS = 7.5E8;
59+double JUMPSCALE = 1E1;
60+double RELOADTIME = 1E1;
61+double CAPACITY = 6E3;
62+ int CELLS = 5;
63+double FLEETRANGE = 1E5;
64+ char g_JumpDriveName[MAXCHARS];
65+
66+// API interface
67+
68+//This is the module start callback. After the module loaded, the INI file will be loaded
69+//(if available) and all global variables are set. It then registers the MFD mode.
70+DLLCLBK void InitModule (HINSTANCE hDLL)
71+{
72+ strcpy(g_JumpDriveName, "S C O U T");
73+ char value[MAXCHARS];
74+ value[0]=0;
75+ GetPrivateProfileString("Sizes", "Drives", 0, value, MAXCHARS, INIFILE);
76+ if (value[0]!=0) JUMPDRIVES=atoi(value);
77+ value[0]=0;
78+ GetPrivateProfileString("Sizes", "MDFs", 0, value, MAXCHARS, INIFILE);
79+ if (value[0]!=0) JUMPDRIVEMFDS=atoi(value);
80+ value[0]=0;
81+ GetPrivateProfileString("Effects", "JumpVelocity", 0, value, MAXCHARS, INIFILE);
82+ if (value[0]!=0) JUMPVEL=atof(value);
83+ value[0]=0;
84+ GetPrivateProfileString("Effects", "FlashOffset", 0, value, MAXCHARS, INIFILE);
85+ if (value[0]!=0) FLASHOFFSET=atof(value);
86+ value[0]=0;
87+ GetPrivateProfileString("Settings", "ClassName", 0, value, MAXCHARS, INIFILE);
88+ if (value[0]!=0) strcpy(g_JumpDriveName, value);
89+ value[0]=0;
90+ GetPrivateProfileString("Settings", "Capacitors", 0, value, MAXCHARS, INIFILE);
91+ if (value[0]!=0) CELLS=atoi(value);
92+ value[0]=0;
93+ GetPrivateProfileString("Settings", "CellCapacity", 0, value, MAXCHARS, INIFILE);
94+ if (value[0]!=0) CAPACITY=atof(value);
95+ value[0]=0;
96+ GetPrivateProfileString("Settings", "CellReloadTime", 0, value, MAXCHARS, INIFILE);
97+ if (value[0]!=0) RELOADTIME=atof(value);
98+ value[0]=0;
99+ GetPrivateProfileString("Settings", "JumpRange", 0, value, MAXCHARS, INIFILE);
100+ if (value[0]!=0) JUMPPOS=atof(value);
101+ value[0]=0;
102+ GetPrivateProfileString("Settings", "JumpRangeScaling", 0, value, MAXCHARS, INIFILE);
103+ if (value[0]!=0) JUMPSCALE=atof(value);
104+ value[0]=0;
105+ GetPrivateProfileString("Features", "FleetRange", 0, value, MAXCHARS, INIFILE);
106+ if (value[0]!=0) FLEETRANGE=atof(value);
107+ g_JumpDrives=new CHashTable(JUMPDRIVES);
108+ g_JumpDriveMFDs=new CHashTable(JUMPDRIVEMFDS);
109+ g_bucket=0;
110+ g_index=0;
111+ g_size=g_JumpDrives->get_size();
112+ g_Bar=0;
113+ // Register the new MFD mode with Orbiter
114+ static char *name = "JumpDrive";
115+ MFDMODESPEC spec;
116+ spec.name = name;
117+ spec.key = OAPI_KEY_J;
118+ spec.msgproc = JumpDriveMFD::MsgProc;
119+ g_MFDmode = oapiRegisterMFDMode (spec);
120+}
121+
122+//This is the module stop callback. The mode will be unregistered and static instances deleted.
123+//If there is no INI-FILE yet, it will be created from scratch.
124+DLLCLBK void ExitModule (HINSTANCE hDLL)
125+{
126+ // Unregister the custom MFD mode when the module is unloaded
127+ oapiUnregisterMFDMode (g_MFDmode);
128+
129+ delete g_JumpDrives;
130+ delete g_JumpDriveMFDs;
131+ if (g_Bar!=0) DeleteObject(g_Bar);
132+ if (fopen(INIFILE, "r")==0)
133+ {
134+ char value[MAXCHARS];
135+ sprintf(value, "%d", JUMPDRIVES);
136+ WritePrivateProfileString("Sizes", "Drives", value, INIFILE);
137+ sprintf(value, "%d", JUMPDRIVEMFDS);
138+ WritePrivateProfileString("Sizes", "MDFs", value, INIFILE);
139+ sprintf(value, "%e", JUMPVEL);
140+ WritePrivateProfileString("Effects", "JumpVelocity", value, INIFILE);
141+ sprintf(value, "%e", FLASHOFFSET);
142+ WritePrivateProfileString("Effects", "FlashOffset", value, INIFILE);
143+ sprintf(value, g_JumpDriveName);
144+ WritePrivateProfileString("Settings", "ClassName", value, INIFILE);
145+ sprintf(value, "%d", CELLS);
146+ WritePrivateProfileString("Settings", "Capacitors", value, INIFILE);
147+ sprintf(value, "%e", CAPACITY);
148+ WritePrivateProfileString("Settings", "CellCapacity", value, INIFILE);
149+ sprintf(value, "%e", RELOADTIME);
150+ WritePrivateProfileString("Settings", "CellReloadTime", value, INIFILE);
151+ sprintf(value, "%e", JUMPPOS);
152+ WritePrivateProfileString("Settings", "JumpRange", value, INIFILE);
153+ sprintf(value, "%e", JUMPSCALE);
154+ WritePrivateProfileString("Settings", "JumpRangeScaling", value, INIFILE);
155+ sprintf(value, "%e", FLEETRANGE);
156+ WritePrivateProfileString("Features", "FleetRange", value, INIFILE);
157+ }
158+}
159+
160+//This is the pre-step callback. In every step, one available drive instance will be
161+//proceeded further on. This way you can have more than one vessel jumping simultaneously.
162+DLLCLBK void opcPreStep (double SimT,double SimDT,double mjd)
163+{
164+ CHashData *data=0;
165+ int i;
166+ unsigned long oldbucket=g_bucket;
167+ do
168+ {
169+ data=g_JumpDrives->content(g_bucket++);
170+ if (g_bucket>=g_size) g_bucket=0;
171+ if (data->key!=0)
172+ {
173+ for(i=g_index++;i>0;i--)
174+ {
175+ data=data->next;
176+ if (data==0)
177+ {
178+ g_index=0;
179+ break;
180+ }
181+ }
182+ }
183+ else data=0;
184+ }
185+ while (oldbucket!=g_bucket && data==0);
186+ if (data!=0)
187+ {
188+ JumpDrive *entry=(JumpDrive *)data->data;
189+ if (entry!=0) entry->Process(SimT,SimDT);
190+ if (data->next==0) g_index=0;
191+ else g_bucket=oldbucket;
192+ }
193+}
194+
195+//This is the opening callback. It sets the environment variables.
196+DLLCLBK void opcOpenRenderViewport (HWND renderWnd, DWORD width, DWORD height, BOOL fullscreen)
197+{
198+ g_Environment.FOV=oapiCameraAperture();
199+ g_Environment.Reset=true;
200+}
201+
202+//This is the closing callback. All drive and MFD instances will be deleted.
203+DLLCLBK void opcCloseRenderViewport ()
204+{
205+ JumpDrive *entry;
206+ JumpDriveMFDData *entry2;
207+ while(!g_JumpDrives->empty)
208+ {
209+ entry=(JumpDrive *)g_JumpDrives->clear(false);
210+ delete entry;
211+ }
212+ while(!g_JumpDriveMFDs->empty)
213+ {
214+ entry2=(JumpDriveMFDData *)g_JumpDriveMFDs->clear(false);
215+ delete entry2;
216+ }
217+ g_bucket=0;
218+ g_index=0;
219+}
220+
221+// MFD class implementation
222+
223+// Constructor - Creates the MFD mode and links it with the appropriate drive and MFD
224+// instances if available. If the drive or MFD instance is not available, it will be
225+// created.
226+JumpDriveMFD::JumpDriveMFD (DWORD w, DWORD h, VESSEL *vessel, UINT mfd)
227+: MFD (w, h, vessel)
228+{
229+ int soundSlot[4]={LOAD,WOOSHOUT,BANG,WOOSHIN};
230+ char key[30];
231+ DWORD i;
232+
233+ this->vessel=vessel;
234+ width=(int)w/35;
235+ heigth=(int)h/28;
236+
237+ sprintf(key, "%p", vessel);
238+ Drive=(JumpDrive *)g_JumpDrives->get(key);
239+ if (Drive==0)
240+ {
241+ sound=ConnectToOrbiterSoundDLL3(vessel->GetHandle());
242+ RequestLoadVesselWave3(sound, LOAD, LOADWAV, DEFAULT);
243+ RequestLoadVesselWave3(sound, ENGAGE, ENGAGEWAV, DEFAULT);
244+ RequestLoadVesselWave3(sound, WOOSHOUT, WOOSHOUTWAV, DEFAULT);
245+ RequestLoadVesselWave3(sound, BANG, BANGWAV, DEFAULT);
246+ RequestLoadVesselWave3(sound, WOOSHIN, WOOSHINWAV, DEFAULT);
247+ RequestLoadVesselWave3(sound, CHARGE, CANCELWAV, DEFAULT);
248+ JumpDriveData data;
249+ data.vessel=vessel;
250+ data.sound=sound;
251+ data.soundSlot=soundSlot;
252+ data.env=&g_Environment;
253+ data.jump=new double[CELLS];
254+ data.jump[0]=JUMPPOS;
255+ for(i=1;(int)i<CELLS;i++) data.jump[i]=data.jump[i-1]*JUMPSCALE;
256+ data.speed=JUMPVEL;
257+ data.offset=FLASHOFFSET;
258+ data.loadtime=RELOADTIME;
259+ data.capacity=CAPACITY;
260+ data.cells=CELLS;
261+ Drive=new JumpDrive(data);
262+ g_JumpDrives->put(key, Drive);
263+ }
264+ else
265+ {
266+ sound=Drive->GetSoundHandle();
267+ }
268+
269+ sprintf(key, "%p:%d", vessel, mfd);
270+ Data=(JumpDriveMFDData *)g_JumpDriveMFDs->get(key);
271+ if (Data==0)
272+ {
273+ Data=new JumpDriveMFDData;
274+ g_JumpDriveMFDs->put(key, Data);
275+ DWORD j=oapiGetObjectCount();
276+ OBJHANDLE obj=vessel->GetHandle();
277+ for(i=0; i<j; i++) if (oapiGetObjectByIndex(i)==obj) break;
278+ Data->target=i;
279+ Data->distance=0;
280+ Data->mode=0;
281+ Data->j2cells=1;
282+ }
283+}
284+
285+// Destructor - empty body.
286+JumpDriveMFD::~JumpDriveMFD ()
287+{
288+ // Add MFD cleanup code here
289+}
290+
291+// Return button labels
292+char *JumpDriveMFD::ButtonLabel (int bt)
293+{
294+ // The labels for the two buttons used by our MFD mode
295+ static char *label[12] = {"JMP", "FUE", "CHG", "TGT", "MOD", "<>", "ALL", "INC", "DEC", "PRV", "NXT", "SET"};
296+ return (bt < 12 ? label[bt] : 0);
297+}
298+
299+// Return button menus
300+int JumpDriveMFD::ButtonMenu (const MFDBUTTONMENU **menu) const
301+{
302+ // The menu descriptions for the two buttons
303+ static const MFDBUTTONMENU mnu[12] = {
304+ {"Engage jump", 0, 'J'},
305+ {"Select fuel index", 0, 'F'},
306+ {"Charge up cell", 0, 'C'},
307+ {"Select target", 0, 'T'},
308+ {"Change display mode", 0, 'M'},
309+ {"Set to current", 0, 'U'},
310+ {"Fleet jump command", 0, 'A'},
311+ {"Increase index", 0, 'I'},
312+ {"Decrease index", 0, 'D'},
313+ {"Previous target", 0, 'P'},
314+ {"Next target", 0, 'N'},
315+ {"Select distance", 0, 'S'}
316+ };
317+ if (menu) *menu = mnu;
318+ return 12; // return the number of buttons used
319+}
320+
321+
322+// Repaint the MFD - contains display and navcomp routines
323+void JumpDriveMFD::Update (HDC hDC)
324+{
325+ // Label strings
326+ static char *label[12] = {"Drive class","Jump range","Capacity","Charge rate","Fuel source", "Fuel mass",
327+ "Capacitors","Target name", "Distance set", "Display mode", "Mode value", "Miscellaneous"};
328+ // Label positions
329+ static unsigned char labelpos[12] = {2,6,8,10,15,17,24,34,50,42,46,52};
330+ // Mode labels
331+ static char *modeLabel[MODES] = {
332+ "Target size",
333+ "Target mass",
334+ "Target distance",
335+ "Course offset",
336+ "Course deviation",
337+ "Deviation needed",
338+ "Deviation offset",
339+ "Relative velocity",
340+ "Velocity elevation",
341+ "X-Y(pitch)alignment"
342+ };
343+
344+ char buffer[80];
345+ int l=0;
346+ PROPELLANT_HANDLE propellant;
347+
348+ //Creating the pen for drawing the progress bar
349+ if (g_Bar==0)
350+ {
351+ LOGPEN pen;
352+ SelectDefaultPen(hDC, 2);
353+ GetObject(GetCurrentObject(hDC, OBJ_PEN), sizeof(LOGPEN), &pen);
354+ g_MiddleGreen=pen.lopnColor;
355+ g_Bar=CreateSolidBrush(g_MiddleGreen);
356+ }
357+
358+ //Get information from drive instance
359+ int cells=Drive->GetFilledCells();
360+ double jump=Drive->GetJumpRange(cells);
361+
362+ //Descriptions (normal, light green)
363+ SelectDefaultFont (hDC, 0);
364+ //Jump drive class
365+ sprintf(buffer, g_JumpDriveName);
366+ l=strlen(buffer);
367+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[0]*heigth) >> 1, buffer, l);
368+ //Jump drive range
369+ sprintf(buffer, "%5.2em(%5.3fAU)", jump, jump/ASTROUNIT);
370+ l=strlen(buffer);
371+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[1]*heigth) >> 1, buffer, l);
372+ //Jump drive capacity
373+ sprintf(buffer, "%4.1fkg x %d", CAPACITY, CELLS);
374+ l=strlen(buffer);
375+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[2]*heigth) >> 1, buffer, l);
376+ //Jump drive charge rate
377+ sprintf(buffer, "%4.1fkg/s(%4.1fs)", CAPACITY/RELOADTIME, RELOADTIME);
378+ l=strlen(buffer);
379+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[3]*heigth) >> 1, buffer, l);
380+ //Navigation computer mode setting
381+ l=strlen(modeLabel[Data->mode]);
382+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[9]*heigth) >> 1, modeLabel[Data->mode], l);
383+
384+ //Settings (normal, white)
385+ SetTextColor(hDC, RGB(255,255,255));
386+ //Fuel source info
387+ l=Drive->GetFuelSource();
388+ propellant=vessel->GetPropellantHandleByIndex(l);
389+ if (propellant!=NULL) sprintf(buffer, "%d of %d", l+1, vessel->GetPropellantCount());
390+ else sprintf(buffer, "OFF");
391+ l=strlen(buffer);
392+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[4]*heigth) >> 1, buffer, l);
393+ if (propellant!=NULL) sprintf(buffer, "%4.1fkg", vessel->GetPropellantMass(propellant));
394+ else sprintf(buffer, "n/a");
395+ l=strlen(buffer);
396+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[5]*heigth) >> 1, buffer, l);
397+ //Target information
398+ if (Data->target>=oapiGetObjectCount()) Data->target=oapiGetObjectCount()-1;
399+ OBJHANDLE obj=oapiGetObjectByIndex(Data->target);
400+ oapiGetObjectName(obj, buffer, 80);
401+ l=strlen(buffer);
402+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[7]*heigth) >> 1, buffer, l);
403+ //Navigation computer mode value
404+ VECTOR3 v1, v2, v3;
405+ double d1, d2;
406+ switch(Data->mode)
407+ {
408+ case 0: sprintf(buffer, "%7.6em", oapiGetSize(obj));
409+ break;
410+ case 1: sprintf(buffer, "%7.6ekg", oapiGetMass(obj));
411+ break;
412+ case 2:
413+ case 3:
414+ case 4:
415+ case 5:
416+ case 6:// Trigonometrics:
417+ //
418+ // +
419+ // / \
420+ // /gamma\ j1^2+distance^2-j2^2
421+ // j1 j2 cos(beta)=(--------------------)
422+ // /beta alpha\ 2*j1*distance
423+ // +-- distance --+
424+ //
425+ // -1<=cos(beta)<=1 j1=j*s^x j2=j*s^y
426+ //
427+ // j1+distance
428+ // ln(-----------)
429+ // j
430+ // y<=---------------
431+ // ln(s)
432+ //
433+ //
434+ // |j1-distance|
435+ // ln(-------------)
436+ // j
437+ // y>=-----------------
438+ // ln(s)
439+ //
440+
441+ oapiGetRelativePos(obj, vessel->GetHandle(), &v1);
442+ d1=length(v1);
443+ if (Data->setToCurrent)
444+ {
445+ Data->setToCurrent=false;
446+ Data->distance=d1;
447+ }
448+ if (Data->mode==2)
449+ {
450+ sprintf(buffer, "%7.6em", d1);
451+ break;
452+ }
453+ vessel->GlobalRot(_V(0,0,1), v2);
454+ if (d1!=0.0) v1/=d1;
455+ d1=dist(v1, v2);
456+ if (Data->mode==3)
457+ {
458+ sprintf(buffer, "%7.6em", d1*jump);
459+ break;
460+ }
461+ d1=360*asin(d1/2)/PI;
462+ if (Data->mode==4)
463+ {
464+ sprintf(buffer, "%9.6f°", d1);
465+ break;
466+ }
467+ d2=Drive->GetJumpRange(Data->j2cells-1);
468+ if (jump!=0.0 && Data->distance!=0.0) d2=(jump*jump + Data->distance*Data->distance - d2*d2)/2/jump/Data->distance;
469+ else
470+ {
471+ sprintf(buffer, "n/a");
472+ break;
473+ }
474+ if (d2<-1 || d2>1)
475+ {
476+ d2=log(JUMPSCALE);
477+ d1=jump-Data->distance;
478+ if (d1<0) d1=-d1;
479+ d1=log(d1/JUMPPOS)/d2;
480+ unsigned long l=(unsigned long)d1;
481+ if (d1>l) l++;
482+ unsigned long k=(unsigned long)(log((jump+Data->distance)/JUMPPOS)/d2);
483+ if (k<l || l<0 || k>=(unsigned long)CELLS) sprintf(buffer, "n/a");
484+ else sprintf(buffer, "2nd jump:%d-%d cells", l+1, k+1);
485+ break;
486+ }
487+ d2=180*acos(d2)/PI;
488+ if (Data->mode==5)
489+ {
490+ sprintf(buffer, "%9.6f°", d2);
491+ break;
492+ }
493+ sprintf(buffer, "%9.6f°", d2-d1);
494+ break;
495+ case 7:
496+ case 8:
497+ oapiGetRelativeVel(vessel->GetHandle(), obj, &v1);
498+ d1=length(v1);
499+ if (Data->mode==7)
500+ {
501+ sprintf(buffer, "%7.6em/s", d1);
502+ break;
503+ }
504+ oapiGetRelativePos(obj, vessel->GetHandle(), &v2);
505+ if ((d2=length(v2))!=0.0) v2/=d2;
506+ if (d1!=0.0) v1/=d1;
507+ d1=(360*asin(dist(v1,v2)/2)/PI)-90;
508+ sprintf(buffer, "%9.6f°", d1);
509+ break;
510+ case 9:
511+ oapiGetRelativeVel(vessel->GetHandle(), obj, &v1);
512+ oapiGetRelativePos(obj, vessel->GetHandle(), &v2);
513+ v1=crossp(v1, v2);
514+ if ((d1=length(v1))!=0.0) v1/=d1;
515+ vessel->GlobalRot(_V(0,0,1), v3);
516+ v3=crossp(v3, v2);
517+ if ((d1=length(v3))!=0.0) v3/=d1;
518+ d1=(360*asin(dist(v1,v3)/2)/PI);
519+ vessel->GlobalRot(_V(0,1,0), v3);
520+ v3=crossp(v3, v2);
521+ if ((d2=length(v3))!=0.0) v3/=d2;
522+ d2=(360*asin(dist(v1,v3)/2)/PI);
523+ sprintf(buffer, "%4.1f° (%4.1f°)", d2, d1);
524+ break;
525+ default: sprintf(buffer, "n/a");
526+ break;
527+ }
528+ l=strlen(buffer);
529+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[10]*heigth) >> 1, buffer, l);
530+ //Distance parameter
531+ sprintf(buffer, "%7.6em", Data->distance);
532+ l=strlen(buffer);
533+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[8]*heigth) >> 1, buffer, l);
534+ //Additional navigation parameter
535+ sprintf(buffer, "2nd jump with %d cells", Data->j2cells);
536+ l=strlen(buffer);
537+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[11]*heigth) >> 1, buffer, l);
538+
539+ //Capacitor status (small font, light green)
540+ SetTextColor(hDC, RGB(255,255,0));
541+ int i,j,k,s,w;
542+ s=7*width;
543+ w=25*width;
544+ SelectObject(hDC, g_Bar);
545+ j=Drive->GetFuelCells();
546+ if (Drive->Jumping())
547+ {
548+ l=(int)(Drive->GetFuel()*100);
549+ Rectangle(hDC, s, (((labelpos[6]-2)*heigth) >> 1)+2,
550+ w*l/100+s+1, (((labelpos[6]+4)*heigth) >> 1)+2);
551+ if (l==0) sprintf(buffer, "00%%");
552+ else if (l==100) sprintf(buffer, "GO");
553+ else sprintf(buffer, "%d%%", l);
554+ l=strlen(buffer);
555+ TextOut(hDC, (1+(37-l)/2)*width, (labelpos[6]*heigth) >> 1, buffer, l);
556+ SelectObject(hDC, GetStockObject(NULL_BRUSH));
557+ Rectangle(hDC, s, (((labelpos[6]-2)*heigth) >> 1)+2,
558+ w+s+1, (((labelpos[6]+4)*heigth) >> 1)+2);
559+ }
560+ else
561+ {
562+ SelectDefaultFont (hDC, 1);
563+ for(i=0;i<cells;i++)
564+ Rectangle(hDC, w*i/j+s, (((labelpos[6]-2)*heigth) >> 1)+2,
565+ w*(i+1)/j+s+1, (((labelpos[6]+4)*heigth) >> 1)+2);
566+ l=(int)(Drive->GetFuel()*100);
567+ Rectangle(hDC, w*i/j+s, (((labelpos[6]-2)*heigth) >> 1)+2,
568+ w*i/j+w*l/100/j+s+1, (((labelpos[6]+4)*heigth) >> 1)+2);
569+ if (l==0) sprintf(buffer, "00%%");
570+ else if (l==100) sprintf(buffer, "GO");
571+ else sprintf(buffer, "%d%%", l);
572+ l=strlen(buffer);
573+ k=w*i/j+w/j/2+s-(l/2)*(width-2);
574+ if (k<s+2) k=s+2;
575+ TextOut(hDC, k, (labelpos[6]*heigth) >> 1, buffer, l);
576+ SelectObject(hDC, GetStockObject(NULL_BRUSH));
577+ for(;i<j;i++)
578+ Rectangle(hDC, w*i/j+s, (((labelpos[6]-2)*heigth) >> 1)+2,
579+ w*(i+1)/j+s+1, (((labelpos[6]+4)*heigth) >> 1)+2);
580+ }
581+ //MFD mode labels (small font, dark green)
582+ SelectDefaultFont (hDC, 1);
583+ SetTextColor(hDC, g_MiddleGreen);
584+ for (l=0; l<12; l++) TextOut(hDC, width, (labelpos[l]*heigth) >> 1, label[l], strlen(label[l]));
585+}
586+
587+// MFD message parser - returns a new MFD mode instance
588+int JumpDriveMFD::MsgProc (UINT msg, UINT mfd, WPARAM wparam, LPARAM lparam)
589+{
590+ switch (msg) {
591+ case OAPI_MSG_MFD_OPENED:
592+ return (int)(new JumpDriveMFD (LOWORD(wparam), HIWORD(wparam), (VESSEL*)lparam, mfd));
593+ }
594+ return 0;
595+}
596+
597+// Callback for target selection dialog
598+bool TargetSelected (void *id, char *str, void *usrdata)
599+{
600+ JumpDriveMFD *mfd=(JumpDriveMFD *)usrdata;
601+ if (strlen(str)==0) return false;
602+ OBJHANDLE obj=oapiGetObjectByName(str);
603+ if (obj==NULL) return false;
604+ DWORD i, j=oapiGetObjectCount();
605+ for(i=0; i<j; i++) if (oapiGetObjectByIndex(i)==obj) break;
606+ mfd->Data->target=i;
607+ mfd->InvalidateDisplay();
608+ return true;
609+}
610+
611+// Callback for fuel source selection dialog
612+bool FuelSelected (void *id, char *str, void *usrdata)
613+{
614+ JumpDriveMFD *mfd=(JumpDriveMFD *)usrdata;
615+ if (strlen(str)==0) return false;
616+ int index=atoi(str);
617+ if (index<0) return false;
618+ mfd->Drive->SetFuelSource(index-1);
619+ return true;
620+}
621+
622+// Callback for parameter dialog
623+bool ParameterSet (void *id, char *str, void *usrdata)
624+{
625+ int i, j;
626+ JumpDriveMFD *mfd=(JumpDriveMFD *)usrdata;
627+ if ((j=strlen(str))==0) return false;
628+ for (i=0;i<j;i++)
629+ if (str[i]==',')
630+ {
631+ j=atoi(str+i+1);
632+ if (j>0 && j<=CELLS) mfd->Data->j2cells=j;
633+ else return false;
634+ str[i]=0;
635+ break;
636+ }
637+ if (strlen(str)>0)
638+ {
639+ double distance=atof(str);
640+ if (distance<0) return false;
641+ mfd->Data->distance=distance;
642+ }
643+ mfd->InvalidateDisplay();
644+ return true;
645+}
646+
647+// Handling shortcut keys
648+bool JumpDriveMFD::ConsumeKeyBuffered(DWORD key)
649+{
650+ static char *fuelSelect = "Enter fuel source index (0=off):";
651+ static char *targetSelect = "Enter target name:";
652+ static char *parameterSet = "Enter Distance[m](,Cell count):";
653+ int fuelSource;
654+ bool result=true;
655+ switch(key)
656+ {
657+ case OAPI_KEY_J://Jump
658+ if (Drive->Start()) PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
659+ else PlayVesselWave3(sound,CHARGE,NOLOOP,255);
660+ break;
661+ case OAPI_KEY_C://Charge
662+ if (Drive->Load()) PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
663+ else PlayVesselWave3(sound,CHARGE,NOLOOP,255);
664+ break;
665+ case OAPI_KEY_I://Increase fuel source index
666+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
667+ fuelSource=Drive->GetFuelSource();
668+ if ((DWORD)++fuelSource>vessel->GetPropellantCount()) fuelSource=0;
669+ Drive->SetFuelSource(fuelSource);
670+ break;
671+ case OAPI_KEY_D://Decrease fuel source index
672+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
673+ fuelSource=Drive->GetFuelSource();
674+ if (--fuelSource<0) fuelSource=vessel->GetPropellantCount();
675+ Drive->SetFuelSource(fuelSource);
676+ break;
677+ case OAPI_KEY_T://Open target selection dialog
678+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
679+ oapiOpenInputBox (targetSelect, TargetSelected, 0, 20, this);
680+ break;
681+ case OAPI_KEY_P://Select previous target
682+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
683+ if (Data->target==0) Data->target=oapiGetObjectCount()-1;
684+ else Data->target--;
685+ break;
686+ case OAPI_KEY_N://Select next target
687+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
688+ if (++(Data->target)>=oapiGetObjectCount()) Data->target=0;
689+ break;
690+ case OAPI_KEY_M://Switch navcomp mode
691+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
692+ if (++(Data->mode)>=MODES) Data->mode=0;
693+ break;
694+ case OAPI_KEY_S://Open parameter dialog
695+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
696+ oapiOpenInputBox (parameterSet, ParameterSet, 0, 20, this);
697+ break;
698+ case OAPI_KEY_U://Set distance parameter to current target's distance
699+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
700+ Data->setToCurrent=true;
701+ Data->mode=2;
702+ break;
703+ case OAPI_KEY_F://Open fuel source selection dialog
704+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
705+ oapiOpenInputBox (fuelSelect, FuelSelected, 0, 20, this);
706+ break;
707+ case OAPI_KEY_A://Fleet command - jump all vessels into same direction
708+ if (Drive->Start())
709+ {
710+ PlayVesselWave3(sound,ENGAGE,NOLOOP,255);
711+ CHashData *data=0;
712+ unsigned long i, j=g_JumpDrives->get_size();
713+ JumpDrive *entry=0;
714+ for (i=0; i<j; i++)
715+ {
716+ data=g_JumpDrives->content(i);
717+ if (data->key!=0)
718+ {
719+ do
720+ {
721+ entry=(JumpDrive *)data->data;
722+ entry->FleetCommand(vessel, FLEETRANGE);
723+ data=data->next;
724+ }
725+ while(data!=0);
726+ }
727+ }
728+ }
729+ else PlayVesselWave3(sound,CHARGE,NOLOOP,255);
730+ break;
731+ default:
732+ result=false;
733+ }
734+ if (!result) return false;
735+ InvalidateDisplay();
736+ return true;
737+}
738+
739+// Handling button presses by forwarding shortcuts
740+bool JumpDriveMFD::ConsumeButton(int bt, int event)
741+{
742+ if (event & PANEL_MOUSE_LBDOWN)
743+ {
744+ switch(bt)
745+ {
746+ case 0:
747+ return ConsumeKeyBuffered(OAPI_KEY_J);
748+ case 1:
749+ return ConsumeKeyBuffered(OAPI_KEY_F);
750+ case 2:
751+ return ConsumeKeyBuffered(OAPI_KEY_C);
752+ case 3:
753+ return ConsumeKeyBuffered(OAPI_KEY_T);
754+ case 4:
755+ return ConsumeKeyBuffered(OAPI_KEY_M);
756+ case 5:
757+ return ConsumeKeyBuffered(OAPI_KEY_U);
758+ case 6:
759+ return ConsumeKeyBuffered(OAPI_KEY_A);
760+ case 7:
761+ return ConsumeKeyBuffered(OAPI_KEY_I);
762+ case 8:
763+ return ConsumeKeyBuffered(OAPI_KEY_D);
764+ case 9:
765+ return ConsumeKeyBuffered(OAPI_KEY_P);
766+ case 10:
767+ return ConsumeKeyBuffered(OAPI_KEY_N);
768+ case 11:
769+ return ConsumeKeyBuffered(OAPI_KEY_S);
770+ }
771+ }
772+ return false;
773+}
774+
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.dsp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.dsp Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,154 @@
1+# Microsoft Developer Studio Project File - Name="JumpDriveMFD" - Package Owner=<4>
2+# Microsoft Developer Studio Generated Build File, Format Version 6.00
3+# ** DO NOT EDIT **
4+
5+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6+
7+CFG=JumpDriveMFD - Win32 Release
8+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9+!MESSAGE use the Export Makefile command and run
10+!MESSAGE
11+!MESSAGE NMAKE /f "JumpDriveMFD.mak".
12+!MESSAGE
13+!MESSAGE You can specify a configuration when running NMAKE
14+!MESSAGE by defining the macro CFG on the command line. For example:
15+!MESSAGE
16+!MESSAGE NMAKE /f "JumpDriveMFD.mak" CFG="JumpDriveMFD - Win32 Release"
17+!MESSAGE
18+!MESSAGE Possible choices for configuration are:
19+!MESSAGE
20+!MESSAGE "JumpDriveMFD - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21+!MESSAGE "JumpDriveMFD - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22+!MESSAGE
23+
24+# Begin Project
25+# PROP AllowPerConfigDependencies 0
26+# PROP Scc_ProjName ""
27+# PROP Scc_LocalPath ""
28+CPP=cl.exe
29+MTL=midl.exe
30+RSC=rc.exe
31+
32+!IF "$(CFG)" == "JumpDriveMFD - Win32 Release"
33+
34+# PROP BASE Use_MFC 0
35+# PROP BASE Use_Debug_Libraries 0
36+# PROP BASE Output_Dir "Release"
37+# PROP BASE Intermediate_Dir "Release"
38+# PROP BASE Target_Dir ""
39+# PROP Use_MFC 0
40+# PROP Use_Debug_Libraries 0
41+# PROP Output_Dir "Release"
42+# PROP Intermediate_Dir "Release"
43+# PROP Ignore_Export_Lib 0
44+# PROP Target_Dir ""
45+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
46+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "..\..\..\Sound\OrbiterSound_SDK\ShuttlePB_project" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /FD /c
47+# SUBTRACT CPP /YX
48+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
49+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
50+# ADD BASE RSC /l 0x809 /d "NDEBUG"
51+# ADD RSC /l 0x809 /d "NDEBUG"
52+BSC32=bscmake.exe
53+# ADD BASE BSC32 /nologo
54+# ADD BSC32 /nologo
55+LINK32=link.exe
56+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
57+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /nodefaultlib:"LIBC"
58+# Begin Special Build Tool
59+SOURCE="$(InputPath)"
60+PostBuild_Desc=Installing binaries
61+PostBuild_Cmds=move Release\*.dll ..\..\..\Modules\Plugin
62+# End Special Build Tool
63+
64+!ELSEIF "$(CFG)" == "JumpDriveMFD - Win32 Debug"
65+
66+# PROP BASE Use_MFC 0
67+# PROP BASE Use_Debug_Libraries 1
68+# PROP BASE Output_Dir "Debug"
69+# PROP BASE Intermediate_Dir "Debug"
70+# PROP BASE Target_Dir ""
71+# PROP Use_MFC 0
72+# PROP Use_Debug_Libraries 1
73+# PROP Output_Dir "Debug"
74+# PROP Intermediate_Dir "Debug"
75+# PROP Ignore_Export_Lib 0
76+# PROP Target_Dir ""
77+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
78+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\..\Sound\OrbiterSound_SDK\ShuttlePB_project" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
79+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
80+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
81+# ADD BASE RSC /l 0x809 /d "_DEBUG"
82+# ADD RSC /l 0x809 /d "_DEBUG"
83+BSC32=bscmake.exe
84+# ADD BASE BSC32 /nologo
85+# ADD BSC32 /nologo
86+LINK32=link.exe
87+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
88+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"MSVCRT" /nodefaultlib:"LIBC" /out:"../../../Modules/Plugin/JumpDriveMFD.dll" /pdbtype:sept
89+# SUBTRACT LINK32 /pdb:none
90+
91+!ENDIF
92+
93+# Begin Target
94+
95+# Name "JumpDriveMFD - Win32 Release"
96+# Name "JumpDriveMFD - Win32 Debug"
97+# Begin Group "SDK"
98+
99+# PROP Default_Filter ""
100+# Begin Source File
101+
102+SOURCE=..\..\include\Orbitersdk.h
103+# End Source File
104+# Begin Source File
105+
106+SOURCE=..\..\..\Sound\OrbiterSound_SDK\ShuttlePB_project\OrbiterSoundSDK3.h
107+# End Source File
108+# Begin Source File
109+
110+SOURCE=..\..\lib\orbiter.lib
111+# End Source File
112+# Begin Source File
113+
114+SOURCE=..\..\lib\Orbitersdk.lib
115+# End Source File
116+# Begin Source File
117+
118+SOURCE=..\..\..\Sound\OrbiterSound_SDK\ShuttlePB_project\OrbiterSoundSDK3.lib
119+# End Source File
120+# End Group
121+# Begin Source File
122+
123+SOURCE=.\HashData.cpp
124+# End Source File
125+# Begin Source File
126+
127+SOURCE=.\HashData.h
128+# End Source File
129+# Begin Source File
130+
131+SOURCE=.\HashTable.cpp
132+# End Source File
133+# Begin Source File
134+
135+SOURCE=.\HashTable.h
136+# End Source File
137+# Begin Source File
138+
139+SOURCE=.\JumpDrive.cpp
140+# End Source File
141+# Begin Source File
142+
143+SOURCE=.\JumpDrive.h
144+# End Source File
145+# Begin Source File
146+
147+SOURCE=.\JumpDriveMFD.cpp
148+# End Source File
149+# Begin Source File
150+
151+SOURCE=.\JumpDriveMFD.h
152+# End Source File
153+# End Target
154+# End Project
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.dsw
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.dsw Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,29 @@
1+Microsoft Developer Studio Workspace File, Format Version 6.00
2+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3+
4+###############################################################################
5+
6+Project: "JumpDriveMFD"=.\JumpDriveMFD.dsp - Package Owner=<4>
7+
8+Package=<5>
9+{{{
10+}}}
11+
12+Package=<4>
13+{{{
14+}}}
15+
16+###############################################################################
17+
18+Global:
19+
20+Package=<5>
21+{{{
22+}}}
23+
24+Package=<3>
25+{{{
26+}}}
27+
28+###############################################################################
29+
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.h Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,54 @@
1+/**************************************************************************
2+ * JumpDriveMFD V1.0 - FTL travel in a difficult fashion for O2K6
3+ * created: July, 6th 2006
4+ * last update: September, 10th 2006
5+ * Copyright (c) 2006 Friedrich Kastner-Masilko, M.Sc.
6+ *
7+ * JumpDriveMFD class header
8+ **************************************************************************/
9+#ifndef __JUMPDRIVEMFD_H
10+#define __JUMPDRIVEMFD_H
11+
12+//Each MFD instance has it's own data memory for the JumpDrive mode.
13+//Even if you switch to another mode, the settings will be saved.
14+struct JumpDriveMFDData
15+{
16+ //target index
17+ DWORD target;
18+ //set distance for Z2 calculation
19+ double distance;
20+ //set navcomp mode
21+ int mode;
22+ //set information about second FLJ's filled cells
23+ int j2cells;
24+ //internal flag
25+ bool setToCurrent;
26+};
27+
28+//The JumpDrive MFD mode class.
29+class JumpDriveMFD: public MFD {
30+public:
31+ //Default implementations
32+ JumpDriveMFD (DWORD w, DWORD h, VESSEL *vessel, UINT mfd);
33+ ~JumpDriveMFD ();
34+ char *ButtonLabel (int bt);
35+ int ButtonMenu (const MFDBUTTONMENU **menu) const;
36+ bool ConsumeKeyBuffered (DWORD key);
37+ bool ConsumeButton (int bt, int event);
38+ void Update (HDC hDC);
39+ static int MsgProc (UINT msg, UINT mfd, WPARAM wparam, LPARAM lparam);
40+ //The drive instance the mode is linked to
41+ JumpDrive *Drive;
42+ //The data instance the mode is linked to
43+ JumpDriveMFDData *Data;
44+private:
45+ //The vessel the mode is linked to
46+ VESSEL *vessel;
47+ //Width and height of the MFD for text positions
48+ int width;
49+ int heigth;
50+ //The sound handle
51+ int sound;
52+};
53+
54+#endif // !__JUMPDRIVEMFD_H
\ No newline at end of file
diff -r 000000000000 -r a538245bbf76 Orbitersdk/samples/JumpDriveMFD/copyright
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Orbitersdk/samples/JumpDriveMFD/copyright Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,7 @@
1+Copyright (c) 2006 Friedrich Kastner-Masilko, M.Sc.
2+
3+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff -r 000000000000 -r a538245bbf76 Scenarios/JumpDriveShow.scn
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Scenarios/JumpDriveShow.scn Wed May 14 14:30:39 2014 +0200
@@ -0,0 +1,69 @@
1+BEGIN_DESC
2+Contains the latest simulation state.
3+END_DESC
4+
5+BEGIN_ENVIRONMENT
6+ System Sol
7+ Date MJD 51982.0414136573
8+END_ENVIRONMENT
9+
10+BEGIN_FOCUS
11+ Ship SH-1
12+END_FOCUS
13+
14+BEGIN_CAMERA
15+ TARGET SH-3
16+ MODE Cockpit
17+ FOV 60.00
18+END_CAMERA
19+
20+BEGIN_HUD
21+ TYPE Orbit
22+ REF AUTO
23+END_HUD
24+
25+BEGIN_MFD Left
26+ TYPE OSync
27+ TARGET SH-2
28+ MODE Intersect 1
29+ LISTLEN 5
30+END_MFD
31+
32+BEGIN_MFD Right
33+ TYPE User
34+ MODE JumpDrive
35+END_MFD
36+
37+
38+BEGIN_SHIPS
39+ISS:ProjectAlpha_ISS
40+ STATUS Orbiting Earth
41+ RPOS 6486393.25 941689.10 -1522622.68
42+ RVEL 1484.880 -7341.844 1784.230
43+ AROT 29.96 0.04 49.75
44+ IDS 0:1 100 1:2 100 2:3 100 3:4 100 4:5 100
45+ NAVFREQ 0 0
46+ XPDR 466
47+END
48+Jumper-1:Atlantis
49+ STATUS Orbiting Earth
50+ RPOS 6486248.82 941637.49 -1522638.15
51+ RVEL 1484.716 -7342.171 1783.922
52+ AROT 178.42 -83.56 125.10
53+ PRPLEVEL 0:1 1:1
54+END
55+Jumper-2:ShuttleA
56+ STATUS Orbiting Sun
57+ RPOS -73264713691.43 398717248.39 8223883777.89
58+ RVEL -3410.207 -7419.870 -27693.753
59+ AROT 176.69 0 126.82
60+ PRPLEVEL 0:1.000 1:1.000
61+END
62+Jumper-3:Deltaglider
63+ STATUS Orbiting Sun
64+ RPOS -73264713791.43 398717248.39 8223883777.89
65+ RVEL -3410.207 -7419.870 -27693.753
66+ AROT 176.69 0 126.82
67+ PRPLEVEL 0:1.000 1:1.000
68+END
69+END_SHIPS
diff -r 000000000000 -r a538245bbf76 Sound/JumpDriveMFD/bang.wav
Binary file Sound/JumpDriveMFD/bang.wav has changed
diff -r 000000000000 -r a538245bbf76 Sound/JumpDriveMFD/cancel.wav
Binary file Sound/JumpDriveMFD/cancel.wav has changed
diff -r 000000000000 -r a538245bbf76 Sound/JumpDriveMFD/engage.wav
Binary file Sound/JumpDriveMFD/engage.wav has changed
diff -r 000000000000 -r a538245bbf76 Sound/JumpDriveMFD/load.wav
Binary file Sound/JumpDriveMFD/load.wav has changed
diff -r 000000000000 -r a538245bbf76 Sound/JumpDriveMFD/woosh1.wav
Binary file Sound/JumpDriveMFD/woosh1.wav has changed
diff -r 000000000000 -r a538245bbf76 Sound/JumpDriveMFD/woosh2.wav
Binary file Sound/JumpDriveMFD/woosh2.wav has changed
Show on old repository browser