Free Hero Mesh

Check-in [6e7ed8025b]
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:Implement the global (Density) block.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6e7ed8025bfcb79145bc77469f07116a858a5d07
User & Date: user on 2022-07-16 01:20:13
Other Links: manifest | tags
Context
2022-07-18
03:06
Change some dealing with IMG/DEP lumps; in future the MUL lumps may also be implemented. check-in: d1dcb9242a user: user tags: trunk
2022-07-16
01:20
Implement the global (Density) block. check-in: 6e7ed8025b user: user tags: trunk
2022-07-14
06:09
If sqlite3.o is not present, try to automatically compile sqlite3.c if it is present. check-in: f5ea4ecd8d user: user tags: trunk
Changes

Modified PORTING from [1829f5c3c9] to [e07d4dfbf6].

247
248
249
250
251
252
253


















The same consideration about line endings with DOS also applies to Windows.


=== Mac OS X ===

(TODO)


























>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
The same consideration about line endings with DOS also applies to Windows.


=== Mac OS X ===

(TODO)


=== Sandboxing ===

Many sandbox systems have problems, such as:

* Assumes all text is Unicode.

* Cannot request a command to use with popen (or from configuration files).

* When asking for a file, cannot also include certain other files whose
names are done by adding additional text onto the end of the name (this is
needed for SQLite to work, and also for non-composite puzzle sets in Free
Hero Mesh).

* Assumes a desktop environment.

Therefore, if it is to be used, a better one should be made up.

Modified class.c from [f32dcb1f64] to [1653acd7e0].

121
122
123
124
125
126
127

128
129
130
131
132
133
134
static char pushback=0;
static Hash*glohash;
static InputStack*inpstack;
static MacroStack*macstack;
static TokenList**macros;
static LabelStack*labelstack;
static Uint16*labelptr;


#define ParseError(a,...) fatal("On line %d: " a,linenum,##__VA_ARGS__)

static const unsigned char chkind[256]={
  ['$']=1, ['!']=1, ['\'']=1, ['#']=1, ['@']=1, ['%']=1, ['&']=1, [':']=1, ['^']=1,
  ['0'...'9']=2, ['-']=2, ['+']=2,
  ['A'...'Z']=3, ['a'...'z']=3, ['_']=3, ['?']=3, ['.']=3, ['*']=3, ['/']=3,







>







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
static char pushback=0;
static Hash*glohash;
static InputStack*inpstack;
static MacroStack*macstack;
static TokenList**macros;
static LabelStack*labelstack;
static Uint16*labelptr;
static Uint8 dense[8];

#define ParseError(a,...) fatal("On line %d: " a,linenum,##__VA_ARGS__)

static const unsigned char chkind[256]={
  ['$']=1, ['!']=1, ['\'']=1, ['#']=1, ['@']=1, ['%']=1, ['&']=1, [':']=1, ['^']=1,
  ['0'...'9']=2, ['-']=2, ['+']=2,
  ['A'...'Z']=3, ['a'...'z']=3, ['_']=3, ['?']=3, ['.']=3, ['*']=3, ['/']=3,
2150
2151
2152
2153
2154
2155
2156






2157
2158
2159
2160
2161
2162
2163
      break;
    } else {
      ParseError("Invalid directly inside of a class definition\n");
    }
  }
  end_label_stack(cl->codes,hash);
  if(!cl->nimages && !(cl->cflags&CF_GROUP)) cl->oflags|=OF_INVISIBLE;






  if(main_options['C']) dump_class(cla,ptr,hash);
  if(main_options['H']) {
    for(i=0;i<LOCAL_HASH_SIZE;i++) if(hash[i].id) printf(" \"%s\": %04X\n",hash[i].txt,hash[i].id);
  }
  for(i=0;i<LOCAL_HASH_SIZE;i++) {
    if(vst && hash[i].id>=0x2000 && hash[i].id<0x2800) {
      sqlite3_reset(vst);







>
>
>
>
>
>







2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
      break;
    } else {
      ParseError("Invalid directly inside of a class definition\n");
    }
  }
  end_label_stack(cl->codes,hash);
  if(!cl->nimages && !(cl->cflags&CF_GROUP)) cl->oflags|=OF_INVISIBLE;
  if(cl->collisionLayers && *dense && !cl->density) {
    for(i=0;i<8;i++) if(dense[i] && ((1<<i)&cl->collisionLayers)) {
      cl->density=dense[i];
      break;
    }
  }
  if(main_options['C']) dump_class(cla,ptr,hash);
  if(main_options['H']) {
    for(i=0;i<LOCAL_HASH_SIZE;i++) if(hash[i].id) printf(" \"%s\": %04X\n",hash[i].txt,hash[i].id);
  }
  for(i=0;i<LOCAL_HASH_SIZE;i++) {
    if(vst && hash[i].id>=0x2000 && hash[i].id<0x2800) {
      sqlite3_reset(vst);
2516
2517
2518
2519
2520
2521
2522











2523
2524
2525
2526
2527
2528
2529
      if(!(i&15)) printf("\n    [%04X]",i);
      printf(" %04X",ll_code[i]);
    }
    putchar('\n');
    printf("---\n\n");
  }
}












void load_classes(void) {
  int i;
  int gloptr=0;
  Hash*glolocalhash;
  char*nam=sqlite3_mprintf("%s.class",basefilename);
  sqlite3_stmt*vst=0;







>
>
>
>
>
>
>
>
>
>
>







2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
      if(!(i&15)) printf("\n    [%04X]",i);
      printf(" %04X",ll_code[i]);
    }
    putchar('\n');
    printf("---\n\n");
  }
}

static void parse_density_block(void) {
  int i;
  for(i=0;i<8;i++) {
    nxttok();
    if(tokent==TF_CLOSE) return;
    if(tokent!=TF_INT || tokenv<1 || tokenv>255) ParseError("Number 1-255 or close parenthesis expected\n");
    dense[i]=tokenv;
  }
  ParseError("Too many global density numbers are specified\n");
}

void load_classes(void) {
  int i;
  int gloptr=0;
  Hash*glolocalhash;
  char*nam=sqlite3_mprintf("%s.class",basefilename);
  sqlite3_stmt*vst=0;
2690
2691
2692
2693
2694
2695
2696



2697
2698
2699
2700
2701
2702
2703
          level_table_definition();
          break;
        case OP_INPUTXY:
          has_xy_input=1;
          nxttok();
          if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n");
          break;



        default:
          ParseError("Invalid top level definition: %s\n",tokenstr);
      }
    } else {
      ParseError("Invalid top level definition\n");
    }
  }







>
>
>







2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
          level_table_definition();
          break;
        case OP_INPUTXY:
          has_xy_input=1;
          nxttok();
          if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n");
          break;
        case OP_DENSITY:
          parse_density_block();
          break;
        default:
          ParseError("Invalid top level definition: %s\n",tokenstr);
      }
    } else {
      ParseError("Invalid top level definition\n");
    }
  }

Modified class.doc from [346d117541] to [8becc682a9].

285
286
287
288
289
290
291






292
293
294
295
296
297
298
  created, destroyed, or moved. It still receives broadcast messages
  normally, and can also be addressed specifically.

(CollisionLayers <userflags...>)
  Define user flags as CollisionLayers bits; the first defined flag is
  bit0. Up to 8 flags can be defined in this way.







(InputXY <options...>)
  Enables coordinate input. Currently there are no options, so the options
  must be left blank. See the documentation about the CLICK message for
  more details about coordinate input.

(LevelTable <definitions...>)
  Define the level table. See the section about level table definition







>
>
>
>
>
>







285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
  created, destroyed, or moved. It still receives broadcast messages
  normally, and can also be addressed specifically.

(CollisionLayers <userflags...>)
  Define user flags as CollisionLayers bits; the first defined flag is
  bit0. Up to 8 flags can be defined in this way.

(Density <numbers...>)
  Define the default Density settings for classes that use the collision
  layers. Each number must be in range 1 to 255, and there cannot be more
  than eight density numbers defined. Their order is the same as the order
  of the user flags in the (CollisionLayers) block.

(InputXY <options...>)
  Enables coordinate input. Currently there are no options, so the options
  must be left blank. See the documentation about the CLICK message for
  more details about coordinate input.

(LevelTable <definitions...>)
  Define the level table. See the section about level table definition