int datacloud::myrequest(int col,int row,const unsigned char *mapfile,int hlod,const unsigned char *texfile,int tlod,const unsigned char *fogfile,databuf *hfield,databuf *texture,databuf *fogmap) { BOOLINT immediate=FALSE; // catch file existence check if (hfield==NULL && texture==NULL && fogmap==NULL) { if (!checkfile(mapfile,FALSE)) return(0); if (!checkfile(texfile,TRUE)) return(0); if (!checkfile(fogfile,FALSE)) return(0); return(1); } // check for height fields that should be delivered immediately if (mapfile!=NULL) if (TERRAIN->getminitile()==NULL) immediate=TRUE; else if (!TERRAIN->getminitile()->isloaded(col,row)) immediate=TRUE; // check for texture maps that should be delivered immediately if (texfile!=NULL) if (TERRAIN->getminitile()==NULL) immediate=TRUE; else if (TERRAIN->getminitile()->gettexid(col,row)==0) immediate=TRUE; // check for request of texture map only if (mapfile==NULL && texfile!=NULL && fogfile==NULL) immediate=TRUE; // schedule job as immediate or deferred with hi prio insertjob(col,row,mapfile,hlod,texfile,tlod,fogfile,immediate,FALSE); // immediate data delivery if (immediate) deliverdata(hfield,texture,fogmap,TRUE); return(0); }
// insert one job into the queue void datacloud::insertjob(int col,int row,const unsigned char *mapfile,int hlod,const unsigned char *texfile,int tlod,const unsigned char *fogfile,BOOLINT immediate,BOOLINT loprio) { double time; jobqueueelem *oldjob,*newjob; // check for already existing job oldjob=checkjob(col,row,mapfile,hlod,texfile,tlod,fogfile,immediate,loprio); // reset access time if (oldjob!=NULL) { time=gettime(); if (mapfile!=NULL) oldjob->hfield->access=time; if (texfile!=NULL) oldjob->texture->access=time; if (fogfile!=NULL) oldjob->fogmap->access=time; return; } // create new job newjob=new jobqueueelem; newjob->col=col; newjob->row=row; // schedule height field if (mapfile!=NULL) newjob->hfield=inserttile(mapfile,col,row,FALSE,immediate,loprio,hlod); else newjob->hfield=NULL; newjob->hlod=hlod; // schedule texture map if (texfile!=NULL) newjob->texture=inserttile(texfile,col,row,TRUE,immediate,loprio,tlod); else newjob->texture=NULL; newjob->tlod=tlod; // schedule fog field if (fogfile!=NULL) newjob->fogmap=inserttile(fogfile,col,row,FALSE,immediate,loprio,0); else newjob->fogmap=NULL; newjob->loprio=loprio; // insert job into job queue if (immediate) insertjob(NULL,newjob); // insert immediate job at head else insertjob(JOBQUEUETAIL,newjob); // insert job at tail }
// insert one job into the queue void datacloud::insertjob(int col,int row,unsigned char *mapfile,int hlod,unsigned char *texfile,int tlod,unsigned char *fogfile,BOOLINT immediate,BOOLINT loprio) { // check for already existing job if (checkjob(mapfile,texfile,fogfile,immediate,loprio)) return; jobqueueelem *newjob=new jobqueueelem; newjob->col=col; newjob->row=row; // schedule height field if (mapfile!=NULL) newjob->hfield=inserttile(mapfile,col,row,FALSE,immediate,loprio); else newjob->hfield=NULL; newjob->hlod=hlod; // schedule texture map if (texfile!=NULL) newjob->texture=inserttile(texfile,col,row,TRUE,immediate,loprio); else newjob->texture=NULL; newjob->tlod=tlod; // schedule fog field if (fogfile!=NULL) newjob->fogmap=inserttile(fogfile,col,row,FALSE,immediate,loprio); else newjob->fogmap=NULL; newjob->loprio=loprio; // insert immediate job at begin if (immediate) insertjob(NULL,newjob); // insert hi prio job before lo prio jobs else if (!loprio) { jobqueueelem *job=JOBQUEUETAIL; // scan past lo prio jobs in reverse order while (job!=NULL) { if (!job->loprio) break; job=job->prev; } // insert after last hi prio job insertjob(job,newjob); } // insert lo prio job at end else insertjob(JOBQUEUETAIL,newjob); }
void datacloud::mypreload(int col,int row,const unsigned char *mapfile,int hlod,const unsigned char *texfile,int tlod,const unsigned char *fogfile) { // schedule job as deferred with lo prio insertjob(col,row,mapfile,hlod,texfile,tlod,fogfile,FALSE,TRUE); }