Free Hero Mesh

Check-in [4d77f3e034]
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:In the OBJECTS virtual table, efficiently check if you are trying to find only bizarro objects in the normal world or vice versa.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4d77f3e034a5bd18a02050cbf4ed70dc599cb0f7
User & Date: user on 2022-06-15 21:33:16
Other Links: manifest | tags
Context
2022-06-22
22:40
Start to implement move list encoding, to be used in future if coordinate input is implemented (and possibly other features that might benefit from this capability). check-in: 77553ee70b user: user tags: trunk
2022-06-15
21:33
In the OBJECTS virtual table, efficiently check if you are trying to find only bizarro objects in the normal world or vice versa. check-in: 4d77f3e034 user: user tags: trunk
2022-06-13
23:57
Implement MD5 hash algorithm. (This is not used in Free Hero Mesh, but may be used in other programs e.g. to compute the Z card in Fossil decks.) check-in: 2e44cdb36f user: user tags: trunk
Changes

Modified function.c from [d6030e09ca] to [e594635ab6].

838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
  Uint32 t;
  cur->rowid=-1;
  cur->unique=0;
  cur->eof=0;
  cur->arg[0]=idxNum;
  cur->arg[1]=0;
  cur->arg[2]=cur->arg[3]=1;
  if(!nobjects) {
    cur->eof=1;
    return SQLITE_OK;
  }
  if(idxStr) for(i=0;idxStr[i];i++) switch(idxStr[i]) {
    case 'a':
      cur->rowid=sqlite3_value_int64(argv[i]);
      cur->unique=1;







|







838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
  Uint32 t;
  cur->rowid=-1;
  cur->unique=0;
  cur->eof=0;
  cur->arg[0]=idxNum;
  cur->arg[1]=0;
  cur->arg[2]=cur->arg[3]=1;
  if(idxNum==-1 || !nobjects) {
    cur->eof=1;
    return SQLITE_OK;
  }
  if(idxStr) for(i=0;idxStr[i];i++) switch(idxStr[i]) {
    case 'a':
      cur->rowid=sqlite3_value_int64(argv[i]);
      cur->unique=1;
897
898
899
900
901
902
903





904
905
906
907
908
909
910
911
912
913
914
915
916
917

918
919
920
921
922
923
924
          break;
        }
        cur->rowid=objects[t]->up;
        if(cur->rowid==VOIDLINK) cur->eof=1;
        cur->unique=1;
      }
      break;





  }
  if(cur->unique) {
    if(cur->rowid<0 || cur->rowid>=nobjects || !objects[cur->rowid]) cur->eof=1;
    return SQLITE_OK;
  }
  if(cur->eof) return SQLITE_OK;
  if(idxNum&0x0400) cur->arg[2]=pfwidth;
  if(idxNum&0x4000) cur->arg[3]=pfheight;
  if(cur->rowid==-1) cur->rowid=0;
  return vt1_objects_next(pcur);
}

static int vt1_objects_index(sqlite3_vtab*vt,sqlite3_index_info*info) {
  sqlite3_str*str=sqlite3_str_new(0);

  int arg=0;
  int i,j;
  info->estimatedCost=100000.0;
  for(i=0;i<info->nConstraint;i++) if(info->aConstraint[i].usable) {
    j=info->aConstraint[i].op;
    switch(info->aConstraint[i].iColumn) {
      case -1: case 0: // ID







>
>
>
>
>














>







897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
          break;
        }
        cur->rowid=objects[t]->up;
        if(cur->rowid==VOIDLINK) cur->eof=1;
        cur->unique=1;
      }
      break;
    case 'h':
      if(sqlite3_value_type(argv[i])==SQLITE_INTEGER) {
        if(sqlite3_value_int64(argv[i])!=(pcur->pVtab==bizarro_vtab?1:0)) cur->eof=1;
      }
      break;
  }
  if(cur->unique) {
    if(cur->rowid<0 || cur->rowid>=nobjects || !objects[cur->rowid]) cur->eof=1;
    return SQLITE_OK;
  }
  if(cur->eof) return SQLITE_OK;
  if(idxNum&0x0400) cur->arg[2]=pfwidth;
  if(idxNum&0x4000) cur->arg[3]=pfheight;
  if(cur->rowid==-1) cur->rowid=0;
  return vt1_objects_next(pcur);
}

static int vt1_objects_index(sqlite3_vtab*vt,sqlite3_index_info*info) {
  sqlite3_str*str=sqlite3_str_new(0);
  sqlite3_value*v;
  int arg=0;
  int i,j;
  info->estimatedCost=100000.0;
  for(i=0;i<info->nConstraint;i++) if(info->aConstraint[i].usable) {
    j=info->aConstraint[i].op;
    switch(info->aConstraint[i].iColumn) {
      case -1: case 0: // ID
972
973
974
975
976
977
978



















979
980
981
982
983
984
985
        if(info->idxNum&0x0019) break;
        if(j==SQLITE_INDEX_CONSTRAINT_IS && !(info->idxNum&0x000E)) {
          info->idxNum|=0x0010;
          info->aConstraintUsage[i].omit=1;
          info->aConstraintUsage[i].argvIndex=++arg;
          sqlite3_str_appendchar(str,1,'g');
          info->estimatedCost/=80.0;



















        }
        break;
    }
  }
  if(info->nOrderBy==1) {
    if(info->aOrderBy->iColumn==0 && !info->aOrderBy->desc && !(info->idxNum&~0x0008)) info->orderByConsumed=1;
    if(info->aOrderBy->iColumn==-1 && !info->aOrderBy->desc && !(info->idxNum&~0x0008)) info->orderByConsumed=1;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
        if(info->idxNum&0x0019) break;
        if(j==SQLITE_INDEX_CONSTRAINT_IS && !(info->idxNum&0x000E)) {
          info->idxNum|=0x0010;
          info->aConstraintUsage[i].omit=1;
          info->aConstraintUsage[i].argvIndex=++arg;
          sqlite3_str_appendchar(str,1,'g');
          info->estimatedCost/=80.0;
        }
        break;
      case 12: // BIZARRO
        if(j==SQLITE_INDEX_CONSTRAINT_EQ || j==SQLITE_INDEX_CONSTRAINT_IS) {
          if(!sqlite3_vtab_rhs_value(info,i,&v) && sqlite3_value_type(v)==SQLITE_INTEGER && sqlite3_value_int64(v)!=(vt==bizarro_vtab?1:0)) {
            empty:
            info->idxNum=-1;
            info->aConstraintUsage[i].omit=1;
            info->idxFlags=SQLITE_INDEX_SCAN_UNIQUE;
            info->estimatedCost=1.0;
            info->estimatedRows=0;
            info->orderByConsumed=1;
            sqlite3_free(sqlite3_str_finish(str));
            return SQLITE_OK;
          } else {
            info->aConstraintUsage[i].argvIndex=++arg;
            sqlite3_str_appendchar(str,1,'h');
            info->estimatedCost/=20.0;
          }
        }
        break;
    }
  }
  if(info->nOrderBy==1) {
    if(info->aOrderBy->iColumn==0 && !info->aOrderBy->desc && !(info->idxNum&~0x0008)) info->orderByConsumed=1;
    if(info->aOrderBy->iColumn==-1 && !info->aOrderBy->desc && !(info->idxNum&~0x0008)) info->orderByConsumed=1;