//------- Begin of function Firm::establish_contact_with_player --------// // // See if the town's location is an explored area, establish contact // with the player. // void Firm::establish_contact_with_player() { if( !nation_recno ) return; int xLoc, yLoc; Location* locPtr; for( yLoc=loc_y1 ; yLoc<=loc_y2 ; yLoc++ ) { for( xLoc=loc_x1 ; xLoc<=loc_x2 ; xLoc++ ) { locPtr = world.get_loc(xLoc, yLoc); locPtr->set_firm(firm_recno); if( locPtr->explored() && nation_array.player_recno ) { NationRelation *relation = (~nation_array)->get_relation(nation_recno); if( !remote.is_enable() ) { relation->has_contact = 1; } else { if( !relation->has_contact && !relation->contact_msg_flag ) { // packet structure : <player nation> <explored nation> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_NATION_CONTACT, 2*sizeof(short)); *shortPtr = nation_array.player_recno; shortPtr[1] = nation_recno; relation->contact_msg_flag = 1; } } } } } }
//---------- Begin of function MapMatrix::draw_map ------------// // see also World::explore // void MapMatrix::draw_map() { //----------- draw map now ------------// sys.yield(); short fireColor = vga_back.translate_color(FIRE_COLOR); short plantColor = vga_back.translate_color(plant_res.plant_map_color); short seaColor = vga_back.translate_color(0x32); short rockColor = vga_back.translate_color( 0x59 ); short mapModeColor = vga_back.translate_color( VGA_GRAY+10 ); short unexploredColor = vga_back.translate_color(UNEXPLORED_COLOR); short shadowColor = vga_back.translate_color( VGA_GRAY+2 ); short roadColor = vga_back.translate_color( VGA_GRAY+12 ); short nationColorArray[MAX_NATION+2]; for( int n = 0; n < MAX_NATION+2; ++n ) nationColorArray[n] = vga_back.translate_color(nation_array.nation_power_color_array[n]); // #### begin Ban 8/12 #######// int temp3 = vga_back.buf_true_pitch() -2; short *temp6 = vga_back.buf_ptr((image_x1 + image_x2)/2, image_y1); #ifdef ASM_FOR_MSVC _asm { MOV AX , DS MOV ES , AX MOV EDX, temp3 MOV EDI, temp6 CLD MOV AX, word ptr UNEXPLORED_COLOR MOV CX, AX // processing the color for drawing SHL EAX, 16 MOV AX, CX MOV EBX, 100 XOR ECX, ECX PutLineUpper: // draw upper triangle INC ECX REP STOSD MOV ECX, 101 // restore ECX after STOSD for updating EDI SUB ECX, EBX ADD EDI, EDX // updating EDI to start point of next line SUB EDI, ECX SUB EDI, ECX SUB EDI, ECX SUB EDI, ECX DEC EBX // decrease the remain height JNZ PutLineUpper // loop MOV EBX, 99 // ready parameters for drawing lower triangle ADD EDX, 4 ADD EDI, 4 PutLineLower: // draw lower triangle MOV ECX, EBX REP STOSD ADD EDI, EDX // updating EDI to start point of next line SUB EDI, EBX SUB EDI, EBX SUB EDI, EBX SUB EDI, EBX DEC EBX // decrease the remain height JNZ PutLineLower // loop } #else int lineDiff = temp3 / 2; int lineLength = 2; // Blacken upper half of minimap. for ( int i = 0; i < 100; ++i ) { for ( int j = 0; j < lineLength; ++j ) { *temp6 = UNEXPLORED_COLOR; ++temp6; } temp6 += lineDiff - lineLength; lineLength += 2; } // Blacken lower half of minimap. lineLength = 99 * 2; lineDiff += 2; temp6 += 2; for ( int i = 0; i < 99; ++i ) { for ( int j = 0; j < lineLength; ++j ) { *temp6 = UNEXPLORED_COLOR; ++temp6; } temp6 += lineDiff - lineLength; lineLength -= 2; } #endif // #### end Ban 8/12 #######// // { // traversal of location in MapMatrix // int pixelX = (image_x1 + image_x2 + 1) / 2; // int pixelY = image_y1; // int xLoc, yLoc; // int writePtrInc = vga_back.buf_pitch() + 1; // for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) // { // short* writePtr = vga_back.buf_ptr(pixelX, pixelY); // xLoc = 0; // Location *locPtr = get_loc( xLoc, yLoc ); // for( xLoc = 0; xLoc < max_x_loc; (xLoc += 2), (writePtr += writePtrInc), (locPtr+=2) ) // { // } // } // } switch(map_mode) { case MAP_MODE_TERRAIN: { int pixelX = (image_x1 + image_x2 + 1) / 2; int pixelY = image_y1; int xLoc, yLoc; int writePtrInc = vga_back.buf_pitch() + 1; for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) { short* writePtr = vga_back.buf_ptr(pixelX, pixelY); int tileYOffset = (yLoc & TERRAIN_TILE_Y_MASK) * TERRAIN_TILE_WIDTH; xLoc = 0; Location* locPtr = get_loc( xLoc, yLoc ); for( ; xLoc < max_x_loc; (xLoc += 2), (locPtr += 2), (writePtr += writePtrInc) ) { if( locPtr->explored() ) { // ##### begin Gilbert 10/2 #######// if( filter_object_flag || filter_nation_flag ) // do not anything except filtered objects when filters are on *writePtr = mapModeColor; else if( locPtr->fire_str() > 0) // ##### end Gilbert 10/2 #######// *writePtr = fireColor; else if( locPtr->is_plant() || xLoc+1<max_x_loc && locPtr[1].is_plant() ) *writePtr = plantColor; else if( locPtr->is_rock() ) *writePtr = rockColor; else if( locPtr->has_dirt() ) { Rock *dirtPtr = dirt_array[locPtr->dirt_recno()]; RockInfo *dirtInfo = rock_res.get_rock_info(dirtPtr->rock_recno); if (dirtInfo->rock_type == 'P') *writePtr = seaColor; else *writePtr = rockColor; } else if( locPtr->is_road() ) *writePtr = vga_back.translate_color(terrain_res.get_map_tile(locPtr->road_terrain_id)[tileYOffset + (xLoc & TERRAIN_TILE_X_MASK)]); else { if( xLoc < 2 || terrain_res[locPtr->terrain_id]->average_type >= terrain_res[(locPtr-2)->terrain_id]->average_type ) { // get terrain pixel from terrain_res *writePtr = vga_back.translate_color(terrain_res.get_map_tile(locPtr->terrain_id)[tileYOffset + (xLoc & TERRAIN_TILE_X_MASK)]); } else { *writePtr = shadowColor; } } } //else // not needed because filled black already //{ // *writePtr = unexploredColor; //} } } } break; // ##### begin Gilbert 2/11 #####// case MAP_MODE_TRADE: // ##### end Gilbert 2/11 #####// case MAP_MODE_SPOT: { // traversal of location in MapMatrix int pixelX = (image_x1 + image_x2 + 1) / 2; int pixelY = image_y1; int xLoc, yLoc; int writePtrInc = vga_back.buf_pitch() + 1; for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) { short* writePtr = vga_back.buf_ptr(pixelX, pixelY); xLoc = 0; Location* locPtr = get_loc( xLoc, yLoc ); for( ; xLoc < max_x_loc; (xLoc += 2), (locPtr +=2), (writePtr += writePtrInc) ) { if( locPtr->explored() ) { *writePtr = mapModeColor; } } } } break; case MAP_MODE_POWER: { int pixelX = (image_x1 + image_x2 + 1) / 2; int pixelY = image_y1; int xLoc, yLoc; int writePtrInc = vga_back.buf_pitch() + 1; for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) { short* writePtr = vga_back.buf_ptr(pixelX, pixelY); xLoc = 0; Location *locPtr = get_loc( xLoc, yLoc ); for( xLoc = 0; xLoc < max_x_loc; (xLoc += 2), (locPtr +=2), (writePtr += writePtrInc) ) { if( locPtr->explored() ) { // ####### begin Gilbert 10/2 #########// if( filter_object_flag || filter_nation_flag ) // do not anything except filtered objects when filters are on *writePtr = mapModeColor; else if( locPtr->sailable() ) // ####### end Gilbert 10/2 #########// *writePtr = seaColor; else if( locPtr->is_rock() || locPtr[1].is_rock() ) *writePtr = rockColor; /* else if( locPtr->has_dirt() ) { Rock *dirtPtr = dirt_array[locPtr->dirt_recno()]; RockInfo *dirtInfo = rock_res.get_rock_info(dirtPtr->rock_recno); if (dirtInfo->rock_type == 'P') *writePtr = seaColor; else *writePtr = rockColor; } else if( locPtr->is_plant() || xLoc+1<max_x_loc && locPtr[1].is_plant() ) *writePtr = plantColor; */ else // ###### begin Gilbert 21/12 ########// { if( power_mode ) *writePtr = nationColorArray[locPtr->power_nation_recno]; else *writePtr = nationColorArray[0]; } // ###### end Gilbert 21/12 ########// } } } } break; case MAP_MODE_ALTITUDE: { int pixelX = (image_x1 + image_x2 + 1) / 2; int pixelY = image_y1; int xLoc, yLoc; int writePtrInc = vga_back.buf_pitch() + 1; for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) { short* writePtr = vga_back.buf_ptr(pixelX, pixelY); xLoc = 0; for( xLoc = 0; xLoc < max_x_loc; (xLoc += 2), (writePtr += writePtrInc) ) { Corner *cornerPtr = get_corner( xLoc, yLoc ); short alt = cornerPtr->get_altitude(); if( alt > 255 ) alt = 255; else if( alt < 0 ) alt = 0; *writePtr = vga.make_pixel((BYTE)alt, 128, 32); } } } break; } sys.yield(); }