Skip to content

Commit

Permalink
Merge pull request #159 from riojax/d3d9client
Browse files Browse the repository at this point in the history
Multiple fixes
  • Loading branch information
jarmonik authored Jan 13, 2022
2 parents dbc3550 + eab5ef9 commit c3e6f7f
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 42 deletions.
2 changes: 1 addition & 1 deletion OVP/D3D9Client/VVessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ static inline const int clip(int v, int vMin, int vMax)

inline const char *value_string (char *buf, size_t buf_size, double val)
{
static const char unit_prefixes[] = { 'µ', 'm', '\0', 'k' , 'M' , 'G' , 'T' , 'P' };
static const char unit_prefixes[] = { (char)230/*'µ'*/, 'm', '\0', 'k' , 'M' , 'G' , 'T' , 'P'};

int index = (int) (log10(val)) / 3;
val /= pow(10.0, index*3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ double VesselXRSoundEngine::GetPlasmaLevel()
const double extTemp = GetExternalTemperature();
const double noseconeTemp = extTemp + degreesK;

const double noseconeTempLimit = 2840 + 273; // convert to kelvin
const double noseconeTempLimit = (double)2840 + (double)273; // convert to kelvin
const double minVisibilityTemp = noseconeTempLimit * 0.387; // tweaked to coincide with Orbiter visual plasma; org in XR code was 0.387
const double maxVisibilityTemp = noseconeTempLimit * 0.80; // was 0.80 in XR code; also tweaked to coincide with Orbiter visual plasma

Expand Down
12 changes: 8 additions & 4 deletions Src/Orbiter/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ void Pane::TriggerPanelRedrawArea (int pid, int aid)
if (panel) {
if (panel->GetId() == pid) {
int idx = panel->AreaIndex (aid);
panel->RedrawArea (idx, PANEL_REDRAW_USER);
if (idx >= 0)
panel->RedrawArea (idx, PANEL_REDRAW_USER);
}
} else if (panel2d) {
if (panel2d->GetId() == pid) {
Expand Down Expand Up @@ -714,11 +715,14 @@ bool Pane::BltPanelAreaBackground (int aid, SURFHANDLE surf)
{
if (panel) {
int idx = panel->AreaIndex (aid);
return panel->BltAreaBackground (idx, surf);
if (idx >= 0)
return panel->BltAreaBackground (idx, surf);
} else if (vcockpit) {
int idx = vcockpit->AreaIndex (aid);
return vcockpit->BltAreaBackground (idx, surf);
} else return false;
if (idx >= 0)
return vcockpit->BltAreaBackground (idx, surf);
}
return false;
}

void Pane::TriggerVCRedrawArea (int vcid, int aid)
Expand Down
8 changes: 6 additions & 2 deletions Src/Orbiter/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ bool State::Read (const char *fname)
mjd0 = MJD (time (NULL)); // default to current system time
mjd0 += UTC_CT_diff*day; // map from UTC to CT (or TDB) time scales
mjd = mjd0;
memset (scnhelp, 0, 128); // no scenario help by default
memset (script, 0, 128); // no scenario script by default
memset (solsys, 0, 64); // no scenario solsys by default
memset (context, 0, 64); // no scenario context by default
memset (script, 0, 128); // no scenario script by default
memset (scnhelp, 0, 128); // no scenario help by default
memset (playback, 0, 128); // no scenario playback by default
memset (focus, 0, 64); // no scenario focus by default

if (FindLine (ifs, "BEGIN_ENVIRONMENT")) {
for (;;) {
Expand Down
8 changes: 4 additions & 4 deletions Src/Orbiter/ddeserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool DDEServer::DDERequest (HWND hServer, HWND hClient, WORD fmt, ATOM item)
return true;
}

DDEACK ddeack = {-1, 0, 0, 0};
DDEACK ddeack = {0, 0, 0, 0}; // bAppReturnCode = 0x0000 -> Normal
SendMessage (hClient, WM_DDE_ACK, (WPARAM)hServer, PackDDElParam(WM_DDE_ACK, *(UINT*)&ddeack, item));
return false;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ void DDEServer::get_vesselid (HWND hClient, ATOM item, DWORD idx)
}
DDEDATA *ddedata = AllocDatablock (32);
char *cbuf = (char*)ddedata->Value;
sprintf (cbuf, "%d", id);
sprintf (cbuf, "%p", id);
PostMessage (hClient, WM_DDE_DATA, (WPARAM)hServer, PackDDElParam(WM_DDE_DATA,(UINT_PTR)ddedata,item));
}

Expand All @@ -217,7 +217,7 @@ bool DDEServer::get_objid (HWND hClient, ATOM item, char *fmtstr)
if (id) {
DDEDATA *ddedata = AllocDatablock(32);
char *cbuf = (char*)ddedata->Value;
sprintf (cbuf, "%d", id);
sprintf (cbuf, "%p", id);
PostMessage (hClient, WM_DDE_DATA, (WPARAM)hServer, PackDDElParam(WM_DDE_DATA,(UINT_PTR)ddedata,item));
return true;
} else {
Expand Down Expand Up @@ -259,7 +259,7 @@ bool DDEServer::get_state (HWND hClient, ATOM item, char *fmtstr)
bool mapequ = false;
char *c;
c = strtok (fmtstr,",");
n = sscanf(c, "%d", &id);
n = sscanf(c, "%lld", &id);
if (!n) return false;

// Currently, this function is only defined for vessels
Expand Down
16 changes: 8 additions & 8 deletions Src/Orbiter/elevmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ struct ElevationTile {
~ElevationTile() { if (data) delete []data; }
void Clear() { if (data) { delete[]data; data = 0; } last_access = 0.0; }
INT16 *data;
int lvl, tgtlvl;
double latmin, latmax;
double lngmin, lngmax;
double emin, emax;
double last_access;
int lat0, lng0;
bool celldiag;
int nmlidx;
int lvl = 0, tgtlvl = 0;
double latmin = 0, latmax = 0;
double lngmin = 0, lngmax = 0;
double emin = 0, emax = 0;
double last_access = 0;
int lat0 = 0, lng0 = 0;
bool celldiag = false;
int nmlidx = 0;
Vector normal;
};

Expand Down
4 changes: 2 additions & 2 deletions Src/Plugin/TransX/TransXFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ void TransXFunction::findfinish(FILEHANDLE scn)

void TransXFunction::savedouble(FILEHANDLE scn, double savenumber)
{
char buffer[80];
char buffer[80]="";
sprintf(buffer," %.12g",savenumber);
oapiWriteScenario_string(scn,"Double",buffer);
}

void TransXFunction::savevector(FILEHANDLE scn, VECTOR3 &vector)
{
char buffer[100];
char buffer[100]="";
sprintf(buffer," %.12g %.12g %.12g",vector.x,vector.y,vector.z);
oapiWriteScenario_string(scn,"Vector",buffer);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Plugin/TransX/basefunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ void basefunction::doupdate(Sketchpad *sketchpad,int tw, int th,int viewmode)
TextShow(sketchpad,"Focus ApD:", wpos,hpos, craft.getapodistance());
}
hpos+=linespacing;
char buffer[20];
char buffer[20]="";
int length=snprintf(buffer, sizeof(buffer) - 1, "Pe MJD: %.4f",(craft.getpedeltatime()+craft.gettimestamp())/SECONDS_PER_DAY+simstartMJD);
sketchpad->Text(wpos,hpos,buffer, length);
hpos+=linespacing;
Expand Down
6 changes: 3 additions & 3 deletions Src/Plugin/TransX/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bool SelectVariableBody(void *id, char *str, void *usrdata)

void TextShow(Sketchpad *sketchpad,const char *label,int wpos,int hpos,OBJHANDLE handle)
{
char buffer[30],buffer2[20];
char buffer[30]="", buffer2[20]="";
oapiGetObjectName(handle,buffer2,20);
strcpy(buffer,label);
strcat(buffer,buffer2);
Expand Down Expand Up @@ -184,7 +184,7 @@ void TextForm(char *buffer,const char *label,double value)
index[0]='T';
}
strcpy(buffer,label);
char buffer2[20];
char buffer2[20]="";
sprintf(buffer2,"%.4g",value);
strcat(buffer2,index);
strcat(buffer,buffer2);
Expand All @@ -193,7 +193,7 @@ void TextForm(char *buffer,const char *label,double value)

void TextShow(Sketchpad *sketchpad,const char *label, int wpos, int hpos, double value)
{
char buffer[30];
char buffer[30]="";
TextForm(buffer,label,value);

int length=strlen(buffer);
Expand Down
2 changes: 1 addition & 1 deletion Src/Plugin/TransX/mfdvarhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void MFDvarhandler::addtolist(MFDvariable *item)

void MFDvarhandler::saveallvariables(FILEHANDLE scn)
{
char buffer[80];
char buffer[80]="";
class dblliter *iterator=listhead.getiterator();
class MFDvariable *pointer=static_cast<MFDvariable*>(iterator->front());
while (pointer!=NULL)
Expand Down
2 changes: 1 addition & 1 deletion Src/Plugin/TransX/mfdvariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void MFDvariable::setcmdnugget(cmdnugget *nugget)
bool MFDvariable::showgeneric(Sketchpad *sketchpad,int width,int line, char *inbuff)
{
// This is a helper function that formats output to the MFD screen
char buffer[MAX_NAME_LENGTH];
char buffer[MAX_NAME_LENGTH]="";
int linecentre=(int) width/2;
int linepos= 6*line;
int inlength=strlen(inbuff);
Expand Down
16 changes: 8 additions & 8 deletions Src/Plugin/TransX/mfdvartypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void MFDvarmoon::ch_adjmode()
void MFDvarmoon::showadjustment(Sketchpad *sketchpad, int width, int line) const
// This shows the mode of adjustment currently in force for the current MFDvariable
{
char buffer[20];
char buffer[20]="";
int ypos=int(7*line);
int xpos=int(width/2);
int length;
Expand Down Expand Up @@ -286,7 +286,7 @@ bool MFDvarmoon::validate()

bool MFDvarmoon::show(Sketchpad *sketchpad, int width, int line)
{
char buffer[20];
char buffer[20]="";
if (target!=NULL)
{
oapiGetObjectName(target,buffer,20);
Expand Down Expand Up @@ -337,7 +337,7 @@ void MFDvarfloat::init(MFDvarhandler *vars,int viewmode1,int viewmode2,char *vna

bool MFDvarshiplist::show(Sketchpad *sketchpad,int width,int line)
{
char buffer[20];
char buffer[20]="";
liststring *entry=static_cast<liststring*>(iterator->current());//It is this type
if (entry==NULL)
strcpy(buffer,"New Plan");
Expand Down Expand Up @@ -374,7 +374,7 @@ void MFDvarshiplist::dec_variable()

bool MFDvarfloat::show(Sketchpad *sketchpad, int width, int line)
{
char buffer[20];
char buffer[20]="";
int linecentre=(int) width/2;
int linepos= 6*line;
strcpy(buffer,name);
Expand Down Expand Up @@ -433,7 +433,7 @@ void MFDvarfloat::chm_adjmode()
void MFDvarfloat::showadjustment(Sketchpad *sketchpad, int width, int line) const
// This shows the mode of adjustment currently in force for the current MFDvariable
{
char buffer[MAX_NAME_LENGTH];
char buffer[MAX_NAME_LENGTH]="";
int ypos=int(7*line);
int xpos=int(width/2);
int length;
Expand Down Expand Up @@ -550,7 +550,7 @@ MFDvarfloat::~MFDvarfloat()

bool MFDsemiintdiscrete::show(Sketchpad *sketchpad, int width, int line)
{
char buffer[20];
char buffer[20]="";
double temp=value*0.5;
sprintf(buffer,"%.1f",temp);
showgeneric(sketchpad, width, line,buffer);
Expand All @@ -559,7 +559,7 @@ bool MFDsemiintdiscrete::show(Sketchpad *sketchpad, int width, int line)

bool MFDvarMJD::show(Sketchpad *sketchpad, int width, int line)
{
char buffer[20];
char buffer[20]="";
sprintf(buffer,"%.4f", value);
showgeneric(sketchpad, width, line, buffer);
return true;
Expand Down Expand Up @@ -668,7 +668,7 @@ void MFDvarangle::init(MFDvarhandler *vars,char *vname, bool vloop)

bool MFDvarangle::show(Sketchpad *sketchpad, int width, int line)
{
char buffer[20];
char buffer[20]="";
sprintf(buffer,"%.4f'", value/PI*180);
showgeneric(sketchpad, width,line,buffer);
return true;
Expand Down
2 changes: 1 addition & 1 deletion Src/Plugin/TransX/planfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void slingshot::graphupdate(Sketchpad *sketchpad, Graph *graph,basefunction *bas

void minorejectplan::wordupdate(Sketchpad *sketchpad, int width, int height, basefunction *base)
{
char buffer[20];
char buffer[20]="";
int linespacing=height/24;
int pos=16*linespacing;
int len;
Expand Down
4 changes: 2 additions & 2 deletions Src/Plugin/TransX/transxstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void transxstate::savecurrent(FILEHANDLE scn)
if (saveflag) return;
saveflag=true;
//Save each function
char buffer[20];//Too big, but who cares!
char buffer[20]="";//Too big, but who cares!
strcpy(buffer,"FNumber");
oapiWriteScenario_int(scn,buffer,baselist.size());
std::deque<class basefunction*>::iterator a;
Expand Down Expand Up @@ -492,7 +492,7 @@ bool transxstate::doupdate(Sketchpad *sketchpad, int tw, int th,unsigned int cur
cvarfunction->processvisiblevars();//Update any visibility changes
cfunction->doupdate(sketchpad,tw,th,currview);
}
char buffer[20];
char buffer[20]="";
int length=snprintf(buffer,sizeof(buffer)-1,"Stage %i:%i",curfunction,(int)baselist.size());
sketchpad->Text(tw/2,0,buffer,length);
length=sprintf(buffer,"Vars Stage %i",curvarfunction);
Expand Down
2 changes: 1 addition & 1 deletion Src/Vessel/DeltaGlider/DockingSubsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ bool NoseconeIndicator::RedrawVC (DEVMESHHANDLE hMesh, SURFHANDLE surf)
GROUPEDITSPEC ges;
static WORD vtxofs = VC_NCONE_INDICATOR_vofs;
static const DWORD nvtx = 2;
static WORD vidx[nvtx] = {vtxofs,vtxofs+1};
static WORD vidx[nvtx] = {vtxofs,WORD(vtxofs+1)};
static float v[2] = {0.2427f,0.3003f};
NTVERTEX vtx[nvtx];
for (DWORD i = 0; i < nvtx; i++)
Expand Down
4 changes: 2 additions & 2 deletions Src/Vessel/DeltaGlider/MomentInd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void AngRateIndicator::Reset2D (int panelid, MESHHANDLE hMesh)
if (!vtxbuf_2D) {
vtxbuf_2D = new NTVERTEX[nvtx];
memcpy (vtxbuf_2D, grp->Vtx+vtxofs, nvtx*sizeof(NTVERTEX));
w0_2D = vtxbuf_2D[0].x - vtxbuf_2D[1].x;
w0_2D = (double)vtxbuf_2D[0].x - (double)vtxbuf_2D[1].x;
for (int i = 0; i < 3; i++) {
xcnt_2D[i] = vtxbuf_2D[6+i*7].x;
ycnt_2D[i] = vtxbuf_2D[6+i*21].y;
Expand All @@ -75,7 +75,7 @@ void AngRateIndicator::ResetVC (DEVMESHHANDLE hMesh)
vtxbuf_VC = new NTVERTEX[nvtx];
GROUPREQUESTSPEC grs = {vtxbuf_VC, nvtx, 0, 0, 0, 0, 0, 0};
oapiGetMeshGroup(hMesh, GRP_ANGVEL_DISP_OVR_VC, &grs);
w0_VC = vtxbuf_VC[0].x - vtxbuf_VC[1].x;
w0_VC = (double)vtxbuf_VC[0].x - (double)vtxbuf_VC[1].x;
for (i = 0; i < 3; i++) {
xcnt_VC[i] = vtxbuf_VC[6+i*7].x;
ycnt_VC[i] = vtxbuf_VC[6+i*21].y;
Expand Down

0 comments on commit c3e6f7f

Please sign in to comment.