Commit MetaInfo

Revision6be1454a0283618b3a3f380a7ddb8db42f415b79 (tree)
Time2014-05-17 02:40:13
AuthorFace
CommiterFace

Log Message

HashTable: removed proprietary table implementation in favor of STL

Change Summary

Incremental Difference

diff -r 927927d766c7 -r 6be1454a0283 Orbitersdk/samples/JumpDriveMFD/HashData.cpp
--- a/Orbitersdk/samples/JumpDriveMFD/HashData.cpp Fri May 16 17:58:05 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
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 927927d766c7 -r 6be1454a0283 Orbitersdk/samples/JumpDriveMFD/HashData.h
--- a/Orbitersdk/samples/JumpDriveMFD/HashData.h Fri May 16 17:58:05 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
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 927927d766c7 -r 6be1454a0283 Orbitersdk/samples/JumpDriveMFD/HashTable.cpp
--- a/Orbitersdk/samples/JumpDriveMFD/HashTable.cpp Fri May 16 17:58:05 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,325 +0,0 @@
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 927927d766c7 -r 6be1454a0283 Orbitersdk/samples/JumpDriveMFD/HashTable.h
--- a/Orbitersdk/samples/JumpDriveMFD/HashTable.h Fri May 16 17:58:05 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
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 927927d766c7 -r 6be1454a0283 Orbitersdk/samples/JumpDriveMFD/JumpDrive.cpp
--- a/Orbitersdk/samples/JumpDriveMFD/JumpDrive.cpp Fri May 16 17:58:05 2014 +0200
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDrive.cpp Fri May 16 19:40:13 2014 +0200
@@ -68,6 +68,7 @@
6868 snd_wooshin =data.soundSlot[3];
6969 fuel=0;
7070 fuelSource=0;
71+ aperture=0;
7172 }
7273
7374 // Destructor - removes the internal jump range table
diff -r 927927d766c7 -r 6be1454a0283 Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.cpp
--- a/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.cpp Fri May 16 17:58:05 2014 +0200
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.cpp Fri May 16 19:40:13 2014 +0200
@@ -36,24 +36,20 @@
3636 #include "windows.h"
3737 #include "orbitersdk.h"
3838 #include "orbitersoundsdk40.h"
39-#include "HashTable.h"
40-#include "HashData.h"
4139 #include "JumpDrive.h"
4240 #include "JumpDriveMFD.h"
4341 #include <stdio.h>
42+#include <map>
4443
4544 // Global variables
4645 int g_MFDmode; // identifier for new MFD mode
47-CHashTable *g_JumpDrives; // static hash table for drive instances
48-CHashTable *g_JumpDriveMFDs; // static hash table for MFD instances
49-unsigned long g_bucket, g_index, g_size;// used for drive hash table iteration
46+std::map< VESSEL*, JumpDrive* > g_JumpDrives; // static hash table for drive instances
47+std::map< VESSEL*, std::map< int, JumpDriveMFDData* > > g_JumpDriveMFDs; // static hash table for MFD instances
5048 Environment g_Environment; // static environment structure
5149 HBRUSH g_Bar; // used for drawing
5250 COLORREF g_MiddleGreen; // used for drawing
5351
5452 // Configurable settings
55- int JUMPDRIVES = 4;
56- int JUMPDRIVEMFDS = 4;
5753 double JUMPVEL = 5E4;
5854 double FLASHOFFSET = 1E1;
5955 double JUMPPOS = 7.5E8;
@@ -73,12 +69,6 @@
7369 strcpy(g_JumpDriveName, "S C O U T");
7470 char value[MAXCHARS];
7571 value[0]=0;
76- GetPrivateProfileString("Sizes", "Drives", 0, value, MAXCHARS, INIFILE);
77- if (value[0]!=0) JUMPDRIVES=atoi(value);
78- value[0]=0;
79- GetPrivateProfileString("Sizes", "MDFs", 0, value, MAXCHARS, INIFILE);
80- if (value[0]!=0) JUMPDRIVEMFDS=atoi(value);
81- value[0]=0;
8272 GetPrivateProfileString("Effects", "JumpVelocity", 0, value, MAXCHARS, INIFILE);
8373 if (value[0]!=0) JUMPVEL=atof(value);
8474 value[0]=0;
@@ -105,11 +95,6 @@
10595 value[0]=0;
10696 GetPrivateProfileString("Features", "FleetRange", 0, value, MAXCHARS, INIFILE);
10797 if (value[0]!=0) FLEETRANGE=atof(value);
108- g_JumpDrives=new CHashTable(JUMPDRIVES);
109- g_JumpDriveMFDs=new CHashTable(JUMPDRIVEMFDS);
110- g_bucket=0;
111- g_index=0;
112- g_size=g_JumpDrives->get_size();
11398 g_Bar=0;
11499 // Register the new MFD mode with Orbiter
115100 static char *name = "JumpDrive";
@@ -127,16 +112,10 @@
127112 // Unregister the custom MFD mode when the module is unloaded
128113 oapiUnregisterMFDMode (g_MFDmode);
129114
130- delete g_JumpDrives;
131- delete g_JumpDriveMFDs;
132115 if (g_Bar!=0) DeleteObject(g_Bar);
133116 if (fopen(INIFILE, "r")==0)
134117 {
135118 char value[MAXCHARS];
136- sprintf(value, "%d", JUMPDRIVES);
137- WritePrivateProfileString("Sizes", "Drives", value, INIFILE);
138- sprintf(value, "%d", JUMPDRIVEMFDS);
139- WritePrivateProfileString("Sizes", "MDFs", value, INIFILE);
140119 sprintf(value, "%e", JUMPVEL);
141120 WritePrivateProfileString("Effects", "JumpVelocity", value, INIFILE);
142121 sprintf(value, "%e", FLASHOFFSET);
@@ -158,48 +137,20 @@
158137 }
159138 }
160139
161-//This is the pre-step callback. In every step, one available drive instance will be
140+//This is the pre-step callback. In every step, all available drive instances will be
162141 //proceeded further on. This way you can have more than one vessel jumping simultaneously.
163142 DLLCLBK void opcPreStep (double SimT,double SimDT,double mjd)
164143 {
165- CHashData *data=0;
166- int i;
167- unsigned long oldbucket=g_bucket;
168- do
169- {
170- data=g_JumpDrives->content(g_bucket++);
171- if (g_bucket>=g_size) g_bucket=0;
172- if (data->key!=0)
173- {
174- for(i=g_index++;i>0;i--)
175- {
176- data=data->next;
177- if (data==0)
178- {
179- g_index=0;
180- break;
181- }
182- }
183- }
184- else data=0;
185- }
186- while (oldbucket!=g_bucket && data==0);
187- if (data!=0)
188- {
189- JumpDrive *entry=(JumpDrive *)data->data;
190- if (entry!=0) entry->Process(SimT,SimDT);
191- if (data->next==0) g_index=0;
192- else g_bucket=oldbucket;
193- }
144+ for(std::map< VESSEL*, JumpDrive* >::iterator i=g_JumpDrives.begin();i!=g_JumpDrives.end();i++)
145+ i->second->Process(SimT, SimDT);
194146
195147 double aperture=0;
196148 OBJHANDLE cam=oapiCameraTarget();
197149 if (cam!=NULL && oapiIsVessel(cam))
198150 {
199- char key[30];
200- sprintf(key, "%p", oapiGetVesselInterface(cam));
201- JumpDrive *drive=(JumpDrive *)g_JumpDrives->get(key);
202- if (drive!=NULL) aperture=drive->GetAperture();
151+ VESSEL *vessel=oapiGetVesselInterface(cam);
152+ if (g_JumpDrives.find(vessel)!=g_JumpDrives.end())
153+ aperture=g_JumpDrives[vessel]->GetAperture();
203154 }
204155 if (aperture>0)
205156 {
@@ -218,23 +169,21 @@
218169 }
219170 }
220171
172+//This is the opening callback. It sets the environment variables.
173+DLLCLBK void opcOpenRenderViewport (HWND renderWnd, DWORD width, DWORD height, BOOL fullscreen)
174+{
175+ g_Environment.FOV=oapiCameraAperture();
176+ g_Environment.Reset=true;
177+}
178+
221179 //This is the closing callback. All drive and MFD instances will be deleted.
222180 DLLCLBK void opcCloseRenderViewport ()
223181 {
224- JumpDrive *entry;
225- JumpDriveMFDData *entry2;
226- while(!g_JumpDrives->empty)
227- {
228- entry=(JumpDrive *)g_JumpDrives->clear(false);
229- delete entry;
230- }
231- while(!g_JumpDriveMFDs->empty)
232- {
233- entry2=(JumpDriveMFDData *)g_JumpDriveMFDs->clear(false);
234- delete entry2;
235- }
236- g_bucket=0;
237- g_index=0;
182+ for(std::map< VESSEL*, JumpDrive* >::iterator i=g_JumpDrives.begin();i!=g_JumpDrives.end();i++)
183+ delete i->second;
184+ for(std::map< VESSEL*, std::map< int, JumpDriveMFDData* > >::iterator i=g_JumpDriveMFDs.begin();i!=g_JumpDriveMFDs.end();i++)
185+ for(std::map< int, JumpDriveMFDData* >::iterator j=i->second.begin();j!=i->second.end();j++)
186+ delete j->second;
238187 }
239188
240189 // MFD class implementation
@@ -252,11 +201,9 @@
252201 this->vessel=vessel;
253202 width=(int)w/35;
254203 heigth=(int)h/28;
255-
256- sprintf(key, "%p", vessel);
257- Drive=(JumpDrive *)g_JumpDrives->get(key);
258- if (Drive==0)
259- {
204+
205+ if (g_JumpDrives.find(vessel)==g_JumpDrives.end())
206+ {
260207 sound=ConnectToOrbiterSoundDLL(vessel->GetHandle());
261208 RequestLoadVesselWave(sound, LOAD, LOADWAV, DEFAULT);
262209 RequestLoadVesselWave(sound, ENGAGE, ENGAGEWAV, DEFAULT);
@@ -277,19 +224,22 @@
277224 data.capacity=CAPACITY;
278225 data.cells=CELLS;
279226 Drive=new JumpDrive(data);
280- g_JumpDrives->put(key, Drive);
227+ g_JumpDrives[vessel]=Drive;
281228 }
282229 else
283230 {
231+ Drive=g_JumpDrives[vessel];
284232 sound=Drive->GetSoundHandle();
285233 }
286234
287- sprintf(key, "%p:%d", vessel, mfd);
288- Data=(JumpDriveMFDData *)g_JumpDriveMFDs->get(key);
289- if (Data==0)
235+ Data=NULL;
236+ if (g_JumpDriveMFDs.find(vessel)!=g_JumpDriveMFDs.end())
237+ if (g_JumpDriveMFDs[vessel].find(mfd)!=g_JumpDriveMFDs[vessel].end())
238+ Data=g_JumpDriveMFDs[vessel][mfd];
239+ if (Data==NULL)
290240 {
291241 Data=new JumpDriveMFDData;
292- g_JumpDriveMFDs->put(key, Data);
242+ g_JumpDriveMFDs[vessel][mfd]=Data;
293243 DWORD j=oapiGetObjectCount();
294244 OBJHANDLE obj=vessel->GetHandle();
295245 for(i=0; i<j; i++) if (oapiGetObjectByIndex(i)==obj) break;
@@ -726,23 +676,8 @@
726676 if (Drive->Start())
727677 {
728678 PlayVesselWave(sound,ENGAGE,NOLOOP,255);
729- CHashData *data=0;
730- unsigned long i, j=g_JumpDrives->get_size();
731- JumpDrive *entry=0;
732- for (i=0; i<j; i++)
733- {
734- data=g_JumpDrives->content(i);
735- if (data->key!=0)
736- {
737- do
738- {
739- entry=(JumpDrive *)data->data;
740- entry->FleetCommand(vessel, FLEETRANGE);
741- data=data->next;
742- }
743- while(data!=0);
744- }
745- }
679+ for(std::map< VESSEL*, JumpDrive* >::iterator i=g_JumpDrives.begin();i!=g_JumpDrives.end();i++)
680+ i->second->FleetCommand(vessel, FLEETRANGE);
746681 }
747682 else PlayVesselWave(sound,CHARGE,NOLOOP,255);
748683 break;
diff -r 927927d766c7 -r 6be1454a0283 Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.vcproj
--- a/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.vcproj Fri May 16 17:58:05 2014 +0200
+++ b/Orbitersdk/samples/JumpDriveMFD/JumpDriveMFD.vcproj Fri May 16 19:40:13 2014 +0200
@@ -237,58 +237,6 @@
237237 </File>
238238 </Filter>
239239 <File
240- RelativePath="HashData.cpp"
241- >
242- <FileConfiguration
243- Name="Release|Win32"
244- >
245- <Tool
246- Name="VCCLCompilerTool"
247- AdditionalIncludeDirectories=""
248- PreprocessorDefinitions=""
249- />
250- </FileConfiguration>
251- <FileConfiguration
252- Name="Debug|Win32"
253- >
254- <Tool
255- Name="VCCLCompilerTool"
256- AdditionalIncludeDirectories=""
257- PreprocessorDefinitions=""
258- />
259- </FileConfiguration>
260- </File>
261- <File
262- RelativePath="HashData.h"
263- >
264- </File>
265- <File
266- RelativePath="HashTable.cpp"
267- >
268- <FileConfiguration
269- Name="Release|Win32"
270- >
271- <Tool
272- Name="VCCLCompilerTool"
273- AdditionalIncludeDirectories=""
274- PreprocessorDefinitions=""
275- />
276- </FileConfiguration>
277- <FileConfiguration
278- Name="Debug|Win32"
279- >
280- <Tool
281- Name="VCCLCompilerTool"
282- AdditionalIncludeDirectories=""
283- PreprocessorDefinitions=""
284- />
285- </FileConfiguration>
286- </File>
287- <File
288- RelativePath="HashTable.h"
289- >
290- </File>
291- <File
292240 RelativePath="JumpDrive.cpp"
293241 >
294242 <FileConfiguration
Show on old repository browser