0 Members and 1 Guest are viewing this topic.
// --------------------------------------------------------------// Read status from scenario file// --------------------------------------------------------------void ShuttleA::clbkLoadStateEx (FILEHANDLE scn, void *vs){ char *line; while (oapiReadScenario_nextline (scn, line)) { if (!strnicmp (line, "[glow=yellow,2,300]PODANGLE[/glow]", 8 )) { sscanf (line+8, "%lf%lf", pod_angle+0, pod_angle+1); } else if (!strnicmp (line, "[glow=yellow,2,300]DOCKSTATE[/glow]", 9 )) { sscanf (line+9, "%d%lf", &dock_status, &dock_proc); } else if (!strnicmp (line, "[glow=yellow,2,300]AIRLOCK[/glow]", 7)) { sscanf (line+7, "%d%lf", &lock_status, &lock_proc); } else { ParseScenarioLineEx (line, vs); // unrecognised option - pass to Orbiter's generic parser } }}// --------------------------------------------------------------// Write status to scenario file// --------------------------------------------------------------void ShuttleA::clbkSaveState (FILEHANDLE scn){ char cbuf[256]; // default vessel parameters VESSEL2::clbkSaveState (scn); // custom parameters sprintf (cbuf, "%0.4f %0.4f", pod_angle[0], pod_angle[1]); oapiWriteScenario_string (scn, "[glow=yellow,2,300]PODANGLE[/glow]", cbuf); sprintf (cbuf, "%d %0.4f", dock_status, dock_proc); oapiWriteScenario_string (scn, "[glow=yellow,2,300]DOCKSTATE[/glow]", cbuf); sprintf (cbuf, "%d %0.4f", lock_status, lock_proc); oapiWriteScenario_string (scn, "[glow=yellow,2,300]AIRLOCK[/glow]", cbuf);}
Scn.SavedVariable(1, &NombreTotalEquipage);Scn.SavedVariable(2, &QuantiteOxygeneCabine);Scn.SavedVariable(3, &QuantiteCo2EnCabine);
Scn.SavedVariable("[glow=yellow,2,300]NombreEquipage[/glow]", &NombreTotalEquipage);Scn.SavedVariable("[glow=yellow,2,300]QuantiteOxygene[/glow]", &QuantiteOxygeneCabine);Scn.SavedVariable("[glow=yellow,2,300]QuantiteCo2[/glow]", &QuantiteCo2EnCabine);
SAVEVAR00 0§0,1§0,2§0,3§0,4§0,5§0,6§0,7§0,8§0,9§0,10§0,11§0,12§0,13§0,14§0,15§0,16§0,17§0,18§0,19§0,20§0,21§0,22§0,23§0,24§0,25§0,26§0,27§2,28§2,29§2,30§2,31§0,32§2,33§0,34§2,35§0,36§0,37§2,38§2,39§0,40§0,41§0,42§0,SAVEVAR01 43§0,44§0,45§0,46§0,47§0,48§0,49§0,50§3,51§0,52§3,53§0,54§3,55§3,56§0,57§0,58§0,59§0,60§0,61§0,62§0,63§0,64§0,65§1,66§1,67§1,68§1,69§0,70§1,71§0,72§1,73§0,74§0,75§1,76§1,77§0,78§2,79§0,80§1,81§0,82§1,83§1,SAVEVAR02 84§1,85§0,86§0,87§1,88§0,89§3,90§2,91§3,92§3,93§3,94§2,95§0,96§2,97§0,98§0,99§0,100§2,101§0,102§0,103§3,104§3,105§0,106§0,107§0,108§3,109§3,110§2,111§3,112§2,113§2,114§2,115§2,116§0,117§0,118§2,119§0,120§0SAVEVAR03 121§2,122§2,123§2,124§2,125§2,126§0,127§2,128§0,129§3,130§3,131§3,132§0,133§0,134§0,135§0,
#include "orbitersdk.h"#include "SaveRestoreScenario.h" // header du SDK class MyAddon: public VESSEL2 {public: MyAddon(OBJHANDLE hVessel, int flightmodel): VESSEL2 (hVessel, flightmodel) {} SaveRestoreScenario Scn; // handle de la classe .....}
// --------------------------------------------------------------// Read status from scenario file// --------------------------------------------------------------void [glow=yellow,2,300]MonAddon[/glow]::clbkLoadStateEx (FILEHANDLE scn, void *vs){ char *line; while (oapiReadScenario_nextline (scn, line)) { if(Scn.LoadScenario(line)==TRUE) continue; ParseScenarioLineEx (line, vs); }}// --------------------------------------------------------------// Write status to scenario file// --------------------------------------------------------------void [glow=yellow,2,300]MonAddon[/glow]::clbkSaveState (FILEHANDLE scn){ VESSEL2::clbkSaveState (scn); Scn.SaveScenario(scn);}
void MonAddon::clbkSetClassCaps (FILEHANDLE cfg){ //////////////////////////////////////////////////////////// // SAVERESTORESCENARIO DEMO // Here you declare the variable that will be saved //////////////////////////////////////////////////////////// Scn.InitClass(); // Variables compressée (utilisation normale) Scn.SavedVariable(0, &UneVarialeInt); Scn.SavedVariable(1, MonNom); Scn.SavedVariable(2, &UneVariableDouble); Scn.SavedVariable(3, &UneAutreDouble); // Variable avec nom, sauvegarde classique pour pouvoir éditer le scenario // A n'utiliser que pour les cas ou c'est vraiment nécessaire. Scn.SavedVariable("[glow=yellow,2,300]Altitude[/glow]",&Altitude); Scn.SavedVariable("[glow=yellow,2,300]CapitainName[/glow]",NomCapitaine); ///////////////////////////////////////////////////////////}
Scn.SavedVariable(0, &UneVarialeInt); //Scn.SavedVariable(1, MonNom); Scn.SavedVariable(2, &UneVariableDouble); Scn.SavedVariable(3, &UneAutreDouble);
Scn.SavedVariable(0, &UneVarialeInt); //Scn.SavedVariable(1, MonNom); Scn.SavedVariable(1, &UneVariableDouble); // ancienne "MonNon" Scn.SavedVariable(2, &UneAutreDouble); // ancienne "UneVariableDouble"
Fonction clbkSetClassCap(){ int UneVariableLocale; Scn.SavedVariable(1, &UneVariableLocale); }
int MaVariable=10;
0x045874 000x045875 000x045876 [b]10[/b]0x045877 00
void * Pointeur=&MaVariable;
char * Pointeur=&MaVariable; // erreur, type int attendu int * Pointeur=&MaVariable; // la ca marcherais, même type.
int RecupereValeur=*(int*)Pointeur;
int MaVariableDepart=20; // une variable avec la valeur 20void *Pointeur=&MaVariableDepart; // assigne l'adresse de la variable au pointeurint RecupereValeur=*(int*)Pointeur; // récupere valeur MaVariableDepart*(int*)Pointeur=45; // change valeur sans toucher a la variable.int NouvelleValeur=*(int*)Pointeur; // récupere valeur MaVariableDepart
Scn.SavedVariable(0, &UneVarialeInt); Scn.SavedVariable(1, MonNom); Scn.SavedVariable(2, &UneVariableDouble); Scn.SavedVariable(3, &UneAutreDouble);
Scn.SavedVariableINT(0, &UneVarialeInt); Scn.SavedVariableCHAR(1, MonNom); Scn.SavedVariableDOUBLE(2, &UneVariableDouble); Scn.SavedVariableDOUBLE(3, &UneAutreDouble);
Declaration:void LogError(int NoErreur);void LogError(char* TextErreur);void LogError(char* TextErreur,int NoErreur);
Appel:LogError(28 );LogError("Erreur");LogError("Erreur",35 );
Implementation de trois corps de fonction qui font les choses différement:void LogError(int NoErreur){ // ecrit le no d'erreur}void LogError(char* TextErreur){ // ecrit le texte de l'erreur}void LogError(char* TextErreur,int NoErreur){ // ecrit le texte de l'erreur et le no}
DanSteph a écrit:Vous touchez la du doigt le coeur de l'ordinateur....32 transistors ... ...3 volts et les zéro 0 volt.