| | @@ -993,16 +993,17 @@ |
| 993 | 993 | ** |
| 994 | 994 | ** 0x01 A rail that merges with the preferred branch |
| 995 | 995 | */ |
| 996 | 996 | u16 aPriority[GR_MAX_RAIL]; |
| 997 | 997 | int mxMatch = 0; |
| 998 | | - memset(aPriority, 0, p->mxRail+1); |
| 998 | + memset(aPriority, 0, (p->mxRail+1)*sizeof(aPriority[0])); |
| 999 | 999 | if( pLeftBranch ){ |
| 1000 | 1000 | for(pRow=p->pFirst; pRow; pRow=pRow->pNext){ |
| 1001 | 1001 | int iMatch = match_text(pLeftBranch, pRow->zBranch); |
| 1002 | | - if( iMatch>0 && iMatch<0x3fff ){ |
| 1003 | | - aPriority[pRow->iRail] |= iMatch*4; |
| 1002 | + if( iMatch>0 ){ |
| 1003 | + if( iMatch>10 ) iMatch = 10; |
| 1004 | + aPriority[pRow->iRail] |= 1<<(iMatch+1); |
| 1004 | 1005 | if( mxMatch<iMatch ) mxMatch = iMatch; |
| 1005 | 1006 | for(i=0; i<=p->mxRail; i++){ |
| 1006 | 1007 | if( pRow->mergeIn[i] ) aPriority[i] |= 1; |
| 1007 | 1008 | } |
| 1008 | 1009 | if( pRow->mergeOut>=0 ) aPriority[pRow->mergeOut] |= 1; |
| | @@ -1027,18 +1028,21 @@ |
| 1027 | 1028 | } |
| 1028 | 1029 | |
| 1029 | 1030 | #if 0 |
| 1030 | 1031 | fprintf(stderr,"mergeRail: 0x%llx\n", p->mergeRail); |
| 1031 | 1032 | fprintf(stderr,"Priority:"); |
| 1032 | | - for(i=0; i<=p->mxRail; i++) fprintf(stderr," %d", aPriority[i]); |
| 1033 | + for(i=0; i<=p->mxRail; i++){ |
| 1034 | + fprintf(stderr," %x.%x", |
| 1035 | + aPriority[i]/4, aPriority[i]&3); |
| 1036 | + } |
| 1033 | 1037 | fprintf(stderr,"\n"); |
| 1034 | 1038 | #endif |
| 1035 | 1039 | |
| 1036 | 1040 | j = 0; |
| 1037 | | - for(kk=4; kk<=mxMatch*4; kk+=4){ |
| 1041 | + for(kk=4; kk<=1<<(mxMatch+1); kk*=2){ |
| 1038 | 1042 | for(i=0; i<=p->mxRail; i++){ |
| 1039 | | - if( aPriority[i]>=kk && aPriority[i]<=kk+3 ){ |
| 1043 | + if( aPriority[i]>=kk && aPriority[i]<kk*2 ){ |
| 1040 | 1044 | aMap[i] = j++; |
| 1041 | 1045 | } |
| 1042 | 1046 | } |
| 1043 | 1047 | } |
| 1044 | 1048 | for(i=p->mxRail; i>=0; i--){ |
| 1045 | 1049 | |