Free Hero Mesh

Check-in [345563f394]
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:Some corrections to parsing the (Order) block; the runtime handling still does not quite work properly yet
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 345563f3943186a7e8163959b3635c0d17601cea
User & Date: user on 2022-04-22 20:11:15
Other Links: manifest | tags
Context
2022-04-24
20:33
Implement (Rook), (Bishop), and (Queen) blocks in class definition blocks. check-in: 3a5d5440cc user: user tags: trunk
2022-04-22
20:11
Some corrections to parsing the (Order) block; the runtime handling still does not quite work properly yet check-in: 345563f394 user: user tags: trunk
03:22
Add the -U switch for experimental/unstable features. check-in: 747db98980 user: user tags: trunk
Changes

Modified class.c from [c278e9bdc7] to [8147a9749f].

2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
}

static void parse_order_block(void) {
  // OP_MISC1, OP_MISC1_C, etc = properties (_C=reverse)
  // 0x1000...0x10FF = Have flag
  // OP_RET = end of block
  Uint16 beg,ptr;
  if(!main_options['U']) ParseError("(Not implemented yet)\n"); //TODO: remove this when it is implemented properly in exec.c too
  orders=malloc(0x4000*sizeof(Uint16));
  if(!orders) fatal("Allocation failed\n");
  nxttok();
  if(tokent==TF_INT) {
    if(tokenv<1 || tokenv>254) ParseError("Order number out of range\n");
    beg=ptr=tokenv;
    nxttok();







|







2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
}

static void parse_order_block(void) {
  // OP_MISC1, OP_MISC1_C, etc = properties (_C=reverse)
  // 0x1000...0x10FF = Have flag
  // OP_RET = end of block
  Uint16 beg,ptr;
  if(!main_options['U']) ParseError("Experimental/unstable feature\n"); //TODO: remove this when it is implemented properly in exec.c too
  orders=malloc(0x4000*sizeof(Uint16));
  if(!orders) fatal("Allocation failed\n");
  nxttok();
  if(tokent==TF_INT) {
    if(tokenv<1 || tokenv>254) ParseError("Order number out of range\n");
    beg=ptr=tokenv;
    nxttok();
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231

2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
      case OP_USERFLAG:
        tokenv=look_hash(glohash,HASH_SIZE,0x1000,0x10FF,0,"user flags");
        if(!tokenv) ParseError("User flag ^%s not defined\n",tokenstr);
        orders[ptr++]=tokenv;
        break;
      default: ParseError("Unexpected token in (Order) block\n");
    }
    nxttok();
    while(tokent!=TF_CLOSE) {
      if(Tokenf(TF_MACRO|TF_EQUAL) || !Tokenf(TF_NAME)) ParseError("Unexpected token in (Order) block\n");
      if(ptr>=0x3FFE) ParseError("Out of order memory\n");
      switch(tokenv) {
        case OP_MISC1: case OP_MISC1_C:
        case OP_MISC2: case OP_MISC2_C:
        case OP_MISC3: case OP_MISC3_C:
        case OP_MISC4: case OP_MISC4_C:
        case OP_MISC5: case OP_MISC5_C:
        case OP_MISC6: case OP_MISC6_C:
        case OP_MISC7: case OP_MISC7_C:
        case OP_TEMPERATURE: case OP_TEMPERATURE_C:
        case OP_DENSITY: case OP_DENSITY_C:
        case OP_XLOC: case OP_XLOC_C:
        case OP_YLOC: case OP_YLOC_C:
        case OP_IMAGE: case OP_IMAGE_C:
          orders[ptr++]=tokenv;
          break;
        default: ParseError("Unexpected token in (Order) block\n");
      }
      nxttok();
    }
    orders[ptr++]=OP_RET;

  }
  if(!norders) ParseError("Empty (Order) block\n");
  orders=realloc(orders,ptr*sizeof(Uint16))?:orders;
  nxttok();
}

static void set_class_orders(void) {
  int i,j,k;
  if(main_options['C']) {
    for(j=1;j<=norders;j++) {
      printf("Order %d =",j);







<
|



















<


>



<







2201
2202
2203
2204
2205
2206
2207

2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227

2228
2229
2230
2231
2232
2233

2234
2235
2236
2237
2238
2239
2240
      case OP_USERFLAG:
        tokenv=look_hash(glohash,HASH_SIZE,0x1000,0x10FF,0,"user flags");
        if(!tokenv) ParseError("User flag ^%s not defined\n",tokenstr);
        orders[ptr++]=tokenv;
        break;
      default: ParseError("Unexpected token in (Order) block\n");
    }

    while(nxttok(),tokent!=TF_CLOSE) {
      if(Tokenf(TF_MACRO|TF_EQUAL) || !Tokenf(TF_NAME)) ParseError("Unexpected token in (Order) block\n");
      if(ptr>=0x3FFE) ParseError("Out of order memory\n");
      switch(tokenv) {
        case OP_MISC1: case OP_MISC1_C:
        case OP_MISC2: case OP_MISC2_C:
        case OP_MISC3: case OP_MISC3_C:
        case OP_MISC4: case OP_MISC4_C:
        case OP_MISC5: case OP_MISC5_C:
        case OP_MISC6: case OP_MISC6_C:
        case OP_MISC7: case OP_MISC7_C:
        case OP_TEMPERATURE: case OP_TEMPERATURE_C:
        case OP_DENSITY: case OP_DENSITY_C:
        case OP_XLOC: case OP_XLOC_C:
        case OP_YLOC: case OP_YLOC_C:
        case OP_IMAGE: case OP_IMAGE_C:
          orders[ptr++]=tokenv;
          break;
        default: ParseError("Unexpected token in (Order) block\n");
      }

    }
    orders[ptr++]=OP_RET;
    nxttok();
  }
  if(!norders) ParseError("Empty (Order) block\n");
  orders=realloc(orders,ptr*sizeof(Uint16))?:orders;

}

static void set_class_orders(void) {
  int i,j,k;
  if(main_options['C']) {
    for(j=1;j<=norders;j++) {
      printf("Order %d =",j);