Free Hero Mesh

Diff
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Differences From Artifact [55b874cfd0]:

To Artifact [c46d8e64e4]:


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
static void init_palette(void) {
  double gamma;
  int usegamma=1;
  int i,j;
  SDL_Color pal[256];
  FILE*fp=0;
  const char*v;
  optionquery[2]=Q_gamma;
  gamma=strtod(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"0",0);
  if(gamma<=0.0 || gamma==1.0) usegamma=0;
  optionquery[2]=Q_palette;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  if(v && *v) {
    fp=fopen(v,"r");
    if(!fp) fatal("Unable to load palette file '%s'\n%m",v);
  }
  for(i=0;i<256;i++) {
    if(fp) {







|


|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
static void init_palette(void) {
  double gamma;
  int usegamma=1;
  int i,j;
  SDL_Color pal[256];
  FILE*fp=0;
  const char*v;
  optionquery[1]=Q_gamma;
  gamma=strtod(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"0",0);
  if(gamma<=0.0 || gamma==1.0) usegamma=0;
  optionquery[1]=Q_palette;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  if(v && *v) {
    fp=fopen(v,"r");
    if(!fp) fatal("Unable to load palette file '%s'\n%m",v);
  }
  for(i=0;i<256;i++) {
    if(fp) {
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
    break;
  }
  if(!curpic) fatal("Allocation failed\n");
  for(i=0;i<256;i++) havesize[i]=(havesize[i]==n)?1:0;
  picture_size=decide_picture_size(nwantsize,wantsize,havesize);
  if(sqlite3_prepare_v2(userdb,"SELECT `ID`, `OFFSET` FROM `PICTURES`;",-1,&st,0))
   fatal("Unable to prepare SQL statement while loading pictures: %s\n",sqlite3_errmsg(userdb));
  optionquery[2]=Q_screenFlags;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  i=v&&strchr(v,'h');
  picts=SDL_CreateRGBSurface((i?SDL_HWSURFACE:SDL_SWSURFACE)|SDL_SRCCOLORKEY,picture_size<<4,picture_size*((n+15)>>4),8,0,0,0,0);
  if(!picts) fatal("Error allocating surface for pictures: %s\n",SDL_GetError());
  init_palette();
  for(i=0;i<n;i++) {
    if((j=sqlite3_step(st))!=SQLITE_ROW) fatal("SQL error (%d): %s\n",j,j==SQLITE_DONE?"Incorrect number of rows in a temporary table":sqlite3_errmsg(userdb));







|







266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
    break;
  }
  if(!curpic) fatal("Allocation failed\n");
  for(i=0;i<256;i++) havesize[i]=(havesize[i]==n)?1:0;
  picture_size=decide_picture_size(nwantsize,wantsize,havesize);
  if(sqlite3_prepare_v2(userdb,"SELECT `ID`, `OFFSET` FROM `PICTURES`;",-1,&st,0))
   fatal("Unable to prepare SQL statement while loading pictures: %s\n",sqlite3_errmsg(userdb));
  optionquery[1]=Q_screenFlags;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  i=v&&strchr(v,'h');
  picts=SDL_CreateRGBSurface((i?SDL_HWSURFACE:SDL_SWSURFACE)|SDL_SRCCOLORKEY,picture_size<<4,picture_size*((n+15)>>4),8,0,0,0,0);
  if(!picts) fatal("Error allocating surface for pictures: %s\n",SDL_GetError());
  init_palette();
  for(i=0;i<n;i++) {
    if((j=sqlite3_step(st))!=SQLITE_ROW) fatal("SQL error (%d): %s\n",j,j==SQLITE_DONE?"Incorrect number of rows in a temporary table":sqlite3_errmsg(userdb));