![]() |
|
Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc. |
![]() |
|
Thread Tools |
![]() |
#1 |
Biblical Creationist
|
![]()
If someone were to create a vessel pack that had several vessels all related to each other in some way (eg: stages), would it be possible to for the developer of such a set to put all of their vessels into a single module?
And if they did do that, would the scenario editor be able to spawn each type of vessel independently of the other types in the module, or would they all be spawned at once and have to be deleted one by one? |
![]() |
![]() |
![]() |
#3 |
shoemaker without legs
![]() |
![]() Quote:
|
![]() |
![]() |
![]() |
#4 |
Beta Tester
![]() ![]() |
![]() Quote:
|
![]() |
![]() |
![]() |
#5 |
Addon Developer
![]() ![]() |
![]()
That's very interesting, i've never thought about that.
|
![]() |
![]() |
![]() |
#6 |
Beta Tester
![]() ![]() |
![]()
Given that you can create vessel config A and B that point to the same module M, you can compile both classes cA and cB into M with a common ovcInit and ovcExit like so:
Code:
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel) { VESSEL *vessel=new VESSEL(hvessel, flightmodel); char *className=new char[strlen(vessel->GetClassName())+1]; strcpy(className, vessel->GetClassName()); delete vessel; strlwr(className); if (strcmp(className, "a")==0) vessel=new cA (hvessel, flightmodel); else if (strcmp(className, "b")==0) vessel=new cB (hvessel, flightmodel); delete [] className; return vessel; } DLLCLBK void ovcExit (VESSEL *vessel) { if (vessel) { char *className=new char[strlen(vessel->GetClassName())+1]; strcpy(className, vessel->GetClassName()); strlwr(className); if (strcmp(className, "a")==0) delete (cA*)vessel; else if (strcmp(className, "b")==0) delete (cB*)vessel; delete [] className; } } |
![]() |
![]() |
Thanked by: |
![]() |
#7 |
Biblical Creationist
|
![]()
I did not know that the VESSEL class had a GetClassName() function. Though I was told that polymorphic objects don't need a (derived*) cast when delete is called. I was also told that objects always need delete[] to be called even if new (not new[]) is called. Since a class is technically an array.
|
![]() |
![]() |
![]() |
#8 |
Beta Tester
![]() ![]() |
![]() Quote:
I must admit that I never tried it for myself, but I've learned to not trust C++ to do the right thing implicitly. Quote:
|
![]() |
![]() |
Thanked by: |
![]() |
#10 |
Addon Developer
![]() |
![]()
They do, I tried that out a while ago in a failed attempt at an Orbiter mission system. I know now a class would have been better, but I think in C++, there's no longer any meaningful difference between a class and struct. Just something about the default visibility of members I think.
Last edited by Zatnikitelman; 07-14-2017 at 04:53 PM. |
![]() |
![]() |
![]() |
#11 |
Beta Tester
![]() ![]() |
![]() Quote:
You know now that a class would have been better. You think that there is no meaningful difference between a class and a struct. So.. if you know that a class would have been better, you'd know that there is a difference. But.. if you know that there is a difference, why do you think there is none? |
![]() |
![]() |
![]() |
#12 |
Heat shield 'tester'
|
![]() Quote:
Quote:
|
![]() |
![]() |
Thanked by: |
![]() |
#14 |
shoemaker without legs
![]() |
![]() Quote:
I didn't realise that I needed virtual destructors until then, though, and the realisation was not very funny. C++ has quite a few questionable decisions in its syntax, but this one tops it all. Like, I can't imagine any situation where it would be a good thing not to call the destructor of an inheriting class... Quote:
![]() |
![]() |
![]() |
![]() |
#15 |
Biblical Creationist
|
![]()
The virtual destructors I already knew about, but thanks anyways. I also already knew that structs and classes are basically identical except for default access (at least for C++). And it seems like the C++ community lied to me again.
|
![]() |
![]() |
![]() |
|
Thread Tools | |
|
|
Quick Links | Need Help? |