Free Hero Mesh

Check-in [a4882ad0b9]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Add the "sqlFile" resource, and correct the gamma correction
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a4882ad0b9cfc9db2b300f10293a9fc8068b73f5
User & Date: user on 2018-04-13 21:19:07
Other Links: manifest | tags
Context
2018-04-13
23:26
Correct the way that picture sizes are decided check-in: 764ce30c41 user: user tags: trunk
21:19
Add the "sqlFile" resource, and correct the gamma correction check-in: a4882ad0b9 user: user tags: trunk
2018-04-09
16:36
Add "FATAL" to fatal error messages check-in: e345d1a7d7 user: user tags: trunk
Changes

Modified heromesh.h from [e948800055] to [756faba25e].

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  Uint16*messages; // use 0xFFFF if no such message block; not present if CF_GROUP
  Uint16*images; // high bit is set if available to editor; not present if CF_GROUP
  Sint32 height,weight,climb,density,volume,strength,arrivals,departures;
  Sint32 temperature,misc4,misc5,misc6,misc7;
  Uint16 uservars,oflags;
  Uint16 sharp[4];
  Uint16 hard[4];
  Uint8 cflags,shape,shovable;
} Class;

extern Class*classes[0x4000]; // 0 isn't used
extern const char*messages[0x4000]; // index is 256 less than message number
extern int max_animation; // max steps in animation queue
extern Sint32 max_volume; // max total volume to allow moving diagonally (default 10000)

// == bindings ==

typedef struct {
  char cmd;
  union {







|




|







74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  Uint16*messages; // use 0xFFFF if no such message block; not present if CF_GROUP
  Uint16*images; // high bit is set if available to editor; not present if CF_GROUP
  Sint32 height,weight,climb,density,volume,strength,arrivals,departures;
  Sint32 temperature,misc4,misc5,misc6,misc7;
  Uint16 uservars,oflags;
  Uint16 sharp[4];
  Uint16 hard[4];
  Uint8 cflags,shape,shovable,collisionLayers;
} Class;

extern Class*classes[0x4000]; // 0 isn't used
extern const char*messages[0x4000]; // index is 256 less than message number
extern int max_animation; // max steps in animation queue (default 32)
extern Sint32 max_volume; // max total volume to allow moving diagonally (default 10000)

// == bindings ==

typedef struct {
  char cmd;
  union {

Modified main.c from [76acffeba5] to [e8db13f7e3].

22
23
24
25
26
27
28


29
30
31
32
33
34
35
#include "heromesh.h"

static const char schema[]=
  "BEGIN;"
  "PRAGMA APPLICATION_ID(1296388936);"
  "PRAGMA RECURSIVE_TRIGGERS(1);"
  "CREATE TABLE IF NOT EXISTS `USERCACHEINDEX`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `TIME` INT);"


  "CREATE TEMPORARY TABLE `PICTURES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `OFFSET` INT);"
  "COMMIT;"
;

sqlite3*userdb;
xrm_db*resourcedb;
const char*basefilename;







>
>







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "heromesh.h"

static const char schema[]=
  "BEGIN;"
  "PRAGMA APPLICATION_ID(1296388936);"
  "PRAGMA RECURSIVE_TRIGGERS(1);"
  "CREATE TABLE IF NOT EXISTS `USERCACHEINDEX`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `TIME` INT);"
  "CREATE TABLE IF NOT EXISTS `USERCACHEDATA`(`ID` INTEGER PRIMARY KEY, `FILE` INT, `LEVEL` INT, `NAME` TEXT, `OFFSET` INT, `DATA` BLOB, `USERSTATE` BLOB);"
  "CREATE INDEX IF NOT EXISTS `USERCACHEDATA_I1` ON `USERCACHEDATA`(`FILE`, `LEVEL`) WHERE `LEVEL` IS NOT NULL;"
  "CREATE TEMPORARY TABLE `PICTURES`(`ID` INTEGER PRIMARY KEY, `NAME` TEXT, `OFFSET` INT);"
  "COMMIT;"
;

sqlite3*userdb;
xrm_db*resourcedb;
const char*basefilename;
73
74
75
76
77
78
79





80
81

82
83
84
85
86
87
88
  optionquery[1]=Q_sqlSmallAllocations;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  sqlite3_config(SQLITE_CONFIG_SMALL_MALLOC,(int)boolxrm(v,0));
  optionquery[1]=Q_sqlCoveringIndexScan;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN,(int)boolxrm(v,1));
  if(sqlite3_initialize()) fatal("Failure to initialize SQLite.\n");





  v=getenv("HOME")?:".";
  s=sqlite3_mprintf("%s%s.heromeshsession",v,v[strlen(v)-1]=='/'?"":"/");

  if(!s) fatal("Allocation failed\n");
  if(z=sqlite3_open(s,&userdb)) fatal("Failed to open user database %s (%s)\n",s,userdb?sqlite3_errmsg(userdb):sqlite3_errstr(z));
  sqlite3_free(s);
  optionquery[1]=Q_sqlExtensions;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  sqlite3_db_config(userdb,SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,*v?1:0,&z);
  if(*v) {







>
>
>
>
>
|
|
>







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  optionquery[1]=Q_sqlSmallAllocations;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  sqlite3_config(SQLITE_CONFIG_SMALL_MALLOC,(int)boolxrm(v,0));
  optionquery[1]=Q_sqlCoveringIndexScan;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN,(int)boolxrm(v,1));
  if(sqlite3_initialize()) fatal("Failure to initialize SQLite.\n");
  optionquery[1]=Q_sqlFile;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  if(v && *v) {
    s=sqlite3_mprintf("%s",v);
  } else {
    v=getenv("HOME")?:".";
    s=sqlite3_mprintf("%s%s.heromeshsession",v,v[strlen(v)-1]=='/'?"":"/");
  }
  if(!s) fatal("Allocation failed\n");
  if(z=sqlite3_open(s,&userdb)) fatal("Failed to open user database %s (%s)\n",s,userdb?sqlite3_errmsg(userdb):sqlite3_errstr(z));
  sqlite3_free(s);
  optionquery[1]=Q_sqlExtensions;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  sqlite3_db_config(userdb,SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,*v?1:0,&z);
  if(*v) {

Modified picture.c from [b1d6c4cbe4] to [399282ff2d].

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  for(i=0;i<256;i++) {
    if(fp) {
      if(fscanf(fp,"%2hhX%2hhX%2hhX ",&pal[i].r,&pal[i].g,&pal[i].b)!=3) fatal("Invalid palette file\n");
    } else {
      sscanf(default_palette+i*7,"%2hhX%2hhX%2hhX ",&pal[i].r,&pal[i].g,&pal[i].b);
    }
    if(usegamma) {
      j=(int)pow(pal[i].r+0.3,gamma); pal[i].r=j<0?0:j>255?255:j;
      j=(int)pow(pal[i].g+0.3,gamma); pal[i].g=j<0?0:j>255?255:j;
      j=(int)pow(pal[i].b+0.3,gamma); pal[i].b=j<0?0:j>255?255:j;
    }
  }
  if(fp) fclose(fp);
  SDL_SetColors(screen,pal,0,256);
  SDL_SetColors(picts,pal,0,256);
}








|
|
|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  for(i=0;i<256;i++) {
    if(fp) {
      if(fscanf(fp,"%2hhX%2hhX%2hhX ",&pal[i].r,&pal[i].g,&pal[i].b)!=3) fatal("Invalid palette file\n");
    } else {
      sscanf(default_palette+i*7,"%2hhX%2hhX%2hhX ",&pal[i].r,&pal[i].g,&pal[i].b);
    }
    if(usegamma) {
      j=(int)(255.0*pow(pal[i].r/255.0,gamma)+0.2); pal[i].r=j<0?0:j>255?255:j;
      j=(int)(255.0*pow(pal[i].g/255.0,gamma)+0.2); pal[i].g=j<0?0:j>255?255:j;
      j=(int)(255.0*pow(pal[i].b/255.0,gamma)+0.2); pal[i].b=j<0?0:j>255?255:j;
    }
  }
  if(fp) fclose(fp);
  SDL_SetColors(screen,pal,0,256);
  SDL_SetColors(picts,pal,0,256);
}

Modified quarks from [d5aac816d7] to [c0379a86e6].

194
195
196
197
198
199
200

201
202
203
204
205
206
207

! Solutions
saveSolutions
solutionComment
solutionTimestamp

! SQL settings

sqlInit
sqlExtensions
sqlMemStatus
sqlSmallAllocations
sqlCoveringIndexScan
sqlPowerSafe








>







194
195
196
197
198
199
200
201
202
203
204
205
206
207
208

! Solutions
saveSolutions
solutionComment
solutionTimestamp

! SQL settings
sqlFile
sqlInit
sqlExtensions
sqlMemStatus
sqlSmallAllocations
sqlCoveringIndexScan
sqlPowerSafe

Modified quarks.h from [93fb52c37c] to [3e75134810].

161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
176
177
178
179
180
181
#define Q_allowMouseWarp 162
#define Q_middle 163
#define Q_class 164
#define Q_quiz 165
#define Q_saveSolutions 166
#define Q_solutionComment 167
#define Q_solutionTimestamp 168
#define Q_sqlInit 169

#define Q_sqlExtensions 170
#define Q_sqlMemStatus 171
#define Q_sqlSmallAllocations 172
#define Q_sqlCoveringIndexScan 173
#define Q_sqlPowerSafe 174
#define Q_level 175
static const char*const global_quarks[]={
  "screenWidth",
  "screenHeight",
  "palette",
  "popupColors",
  "imageSize",
  "altImage",







|
>
|
|
|
|
|
|







161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#define Q_allowMouseWarp 162
#define Q_middle 163
#define Q_class 164
#define Q_quiz 165
#define Q_saveSolutions 166
#define Q_solutionComment 167
#define Q_solutionTimestamp 168
#define Q_sqlFile 169
#define Q_sqlInit 170
#define Q_sqlExtensions 171
#define Q_sqlMemStatus 172
#define Q_sqlSmallAllocations 173
#define Q_sqlCoveringIndexScan 174
#define Q_sqlPowerSafe 175
#define Q_level 176
static const char*const global_quarks[]={
  "screenWidth",
  "screenHeight",
  "palette",
  "popupColors",
  "imageSize",
  "altImage",
336
337
338
339
340
341
342

343
344
345
346
347
348
349
  "allowMouseWarp",
  "middle",
  "class",
  "quiz",
  "saveSolutions",
  "solutionComment",
  "solutionTimestamp",

  "sqlInit",
  "sqlExtensions",
  "sqlMemStatus",
  "sqlSmallAllocations",
  "sqlCoveringIndexScan",
  "sqlPowerSafe",
  "level",







>







337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
  "allowMouseWarp",
  "middle",
  "class",
  "quiz",
  "saveSolutions",
  "solutionComment",
  "solutionTimestamp",
  "sqlFile",
  "sqlInit",
  "sqlExtensions",
  "sqlMemStatus",
  "sqlSmallAllocations",
  "sqlCoveringIndexScan",
  "sqlPowerSafe",
  "level",