void ProcessTextureFile (void) { FILE *fp; uchar *texture; short tex; int x,y,i,j; char name[80]; printf("\nProcessing Texture file... "); texture = (uchar*) malloc(Map_Max_X*Map_Max_Y*sizeof(short)); sprintf(name,"%s-F",TheaterName); if ((fp = OpenCampFile(name,"COV","rb")) == NULL) { printf("Error reading texture file!\n"); printf("Press a key to continue:"); getch(); exit(-1); } fread(texture,sizeof(uchar),Map_Max_X*Map_Max_Y,fp); fclose (fp); for (y=0; y<Map_Max_Y; y++) { for (x=0; x<Map_Max_X; x++) { j = ((Map_Max_Y-1-y)*Map_Max_X) + x; i = (x*Map_Max_Y) + y; tex = texture[j]; if (tex < 8) SetGroundCover(i,tex); else if (tex < 16) { SetGroundCover(i,tex-8); SetRoad(i,1); } else if (tex < 24) { SetGroundCover(i,tex-16); SetRail(i,1); } else SetGroundCover(i,0); } } printf("\n"); free(texture); }
void Map::SetBridge( int row1, int column1, int row2, int column2, int bridgeType ) { if( bridgeType == TWO_WAY_ALWAYS_ON ) { SetRoad( row1, column1, row2, column2, ROAD_ON ); SetRoad( row2, column2, row1, column1, ROAD_ON ); } else if( bridgeType == TWO_WAY_ONE_TIME ) { SetRoad( row1, column1, row2, column2, ROAD_ONE_TIME ); SetRoad( row2, column2, row1, column1, ROAD_ONE_TIME ); } else if( ( bridgeType == TWO_WAY_ONOFF_ON ) || ( bridgeType == TWO_WAY_ONOFF_OFF ) ) { if( bridgeType == TWO_WAY_ONOFF_ON ) { SetRoad( row1, column1, row2, column2, ROAD_ONOFF_ON ); SetRoad( row2, column2, row1, column1, ROAD_ONOFF_ON ); } else//( bridgeType == TWO_WAY_ONOFF_OFF ) { SetRoad( row1, column1, row2, column2, ROAD_ONOFF_OFF ); SetRoad( row2, column2, row1, column1, ROAD_ONOFF_OFF ); } } else if( bridgeType == ONE_WAY_ALWAYS_ON ) { SetRoad( row1, column1, row2, column2, ROAD_ON ); SetRoad( row2, column2, row1, column1, ROAD_OFF ); } else if( bridgeType == ONE_WAY_ONE_TIME ) { SetRoad( row1, column1, row2, column2, ROAD_ONE_TIME ); SetRoad( row2, column2, row1, column1, ROAD_OFF ); } else if( ( bridgeType == ONE_WAY_ONOFF_ON ) || ( bridgeType == ONE_WAY_ONOFF_OFF ) ) { if( bridgeType == ONE_WAY_ONOFF_ON ) { SetRoad( row1, column1, row2, column2, ROAD_ONOFF_ON ); SetRoad( row2, column2, row1, column1, ROAD_OFF ); } else//( bridgeType == ONE_WAY_ONOFF_OFF ) { SetRoad( row1, column1, row2, column2, ROAD_ONOFF_OFF ); SetRoad( row2, column2, row1, column1, ROAD_OFF ); } } else if( bridgeType == UNBRIDGE ) { SetRoad( row1, column1, row2, column2, ROAD_OFF ); SetRoad( row2, column2, row1, column1, ROAD_OFF ); } }