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 [5e7918c55b]:

To Artifact [f6d1b8ebcb]:


972
973
974
975
976
977
978

979
980
981
982
983
984
985
986
987
988
989


990
991
992
993
994
995
996
997
998
999

1000
1001
1002
1003

1004
1005
1006
1007
1008
1009
1010

1011
1012
1013
1014
1015
1016

1017
1018
1019
1020
1021
1022
1023
  labelptr=0;
}

static int parse_pattern(int cla,int ptr,Hash*hash) {
  Class*cl=classes[cla];
  Uint8 depth=0;
  Uint16 nest[32];

  int x,y;
  for(;;) {
    nxttok();
    if(Tokenf(TF_MACRO)) ParseError("Unexpected macro\n");
    if(Tokenf(TF_DIR)) {
      cl->codes[ptr++]=tokenv&15;
    } else if(Tokenf(TF_NAME)) {
      switch(tokenv) {
        case OP_ADD: case OP_CLIMB: case OP_EIGHT: case OP_FOUR:
        case OP_HEIGHT: case OP_LOC: case OP_MARK: case OP_SUB:
        case OP_DIR: case OP_DIR_C: case OP_DIR_E: case OP_DIR_EC:


        case 0x0200 ... 0x02FF: // message
        case 0x4000 ... 0x7FFF: // class
        case 0xC000 ... 0xFFFF: // message
          cl->codes[ptr++]=tokenv;
          break;
        case OP_BEGIN: case OP_IF:
          if(depth==31) ParseError("Too much pattern nesting\n");
          nest[depth++]=ptr;
          cl->codes[ptr++]=tokenv;
          cl->codes[ptr++]=0;

          break;
        case OP_ELSE:
          if(!depth) ParseError("Premature end of subpattern\n");
          cl->codes[nest[depth-1]+1]=ptr;

          cl->codes[ptr++]=cl->codes[nest[depth-1]];
          cl->codes[nest[depth-1]]=OP_ELSE;
          cl->codes[ptr++]=0;
          break;
        case OP_THEN:
          if(!depth) ParseError("Premature end of subpattern\n");
          cl->codes[nest[--depth]+1]=ptr;

          break;
        case OP_AGAIN:
          if(!depth) ParseError("Premature end of subpattern\n");
          cl->codes[ptr++]=OP_GOTO;
          cl->codes[ptr++]=nest[depth-1];
          cl->codes[nest[--depth]+1]=ptr;

          break;
        case OP_USERFLAG:
          x=look_hash(glohash,HASH_SIZE,0x1000,0x10FF,0,"user flags");
          if(!x) ParseError("User flag ^%s not defined\n",tokenstr);
          if(Tokenf(TF_COMMA)) x+=0x100;
          if(Tokenf(TF_EQUAL)) ParseError("Improper token in pattern\n");
          cl->codes[ptr++]=x;







>











>
>







|


>




>

|





>



|
|

>







972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
  labelptr=0;
}

static int parse_pattern(int cla,int ptr,Hash*hash) {
  Class*cl=classes[cla];
  Uint8 depth=0;
  Uint16 nest[32];
  Uint16 nest0[32];
  int x,y;
  for(;;) {
    nxttok();
    if(Tokenf(TF_MACRO)) ParseError("Unexpected macro\n");
    if(Tokenf(TF_DIR)) {
      cl->codes[ptr++]=tokenv&15;
    } else if(Tokenf(TF_NAME)) {
      switch(tokenv) {
        case OP_ADD: case OP_CLIMB: case OP_EIGHT: case OP_FOUR:
        case OP_HEIGHT: case OP_LOC: case OP_MARK: case OP_SUB:
        case OP_DIR: case OP_DIR_C: case OP_DIR_E: case OP_DIR_EC:
        case OP_OBJTOPAT: case OP_OBJBOTTOMAT: case OP_CUT: case OP_MUL:
        case OP_OBJABOVE: case OP_OBJBELOW: case OP_TRACE:
        case 0x0200 ... 0x02FF: // message
        case 0x4000 ... 0x7FFF: // class
        case 0xC000 ... 0xFFFF: // message
          cl->codes[ptr++]=tokenv;
          break;
        case OP_BEGIN: case OP_IF:
          if(depth==31) ParseError("Too much pattern nesting\n");
          nest0[depth]=nest[depth]=ptr;
          cl->codes[ptr++]=tokenv;
          cl->codes[ptr++]=0;
          depth++;
          break;
        case OP_ELSE:
          if(!depth) ParseError("Premature end of subpattern\n");
          cl->codes[nest[depth-1]+1]=ptr;
          cl->codes[ptr++]=OP_ELSE;
          cl->codes[ptr++]=cl->codes[nest[depth-1]];
          cl->codes[nest[depth-1]]=OP_IF;
          cl->codes[ptr++]=0;
          break;
        case OP_THEN:
          if(!depth) ParseError("Premature end of subpattern\n");
          cl->codes[nest[--depth]+1]=ptr;
          cl->codes[ptr++]=OP_THEN;
          break;
        case OP_AGAIN:
          if(!depth) ParseError("Premature end of subpattern\n");
          cl->codes[ptr++]=OP_AGAIN;
          cl->codes[ptr++]=nest0[depth-1];
          cl->codes[nest[--depth]+1]=ptr;
          cl->codes[ptr++]=OP_THEN;
          break;
        case OP_USERFLAG:
          x=look_hash(glohash,HASH_SIZE,0x1000,0x10FF,0,"user flags");
          if(!x) ParseError("User flag ^%s not defined\n",tokenstr);
          if(Tokenf(TF_COMMA)) x+=0x100;
          if(Tokenf(TF_EQUAL)) ParseError("Improper token in pattern\n");
          cl->codes[ptr++]=x;