Changeset 674 for abuse/trunk/src/game.cpp
- Timestamp:
- May 16, 2011, 2:37:43 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/game.cpp
r673 r674 226 226 continue; 227 227 228 f->suggest.cx1=(f-> cx1- amount);229 f->suggest.cy1 = f-> cy1- amount / 2;230 f->suggest.cx2=(f-> cx2+ amount);231 f->suggest.cy2 = f-> cy2+ amount / 2;228 f->suggest.cx1=(f->m_aa.x - amount); 229 f->suggest.cy1 = f->m_aa.y - amount / 2; 230 f->suggest.cx2=(f->m_bb.x + amount); 231 f->suggest.cy2 = f->m_bb.y + amount / 2; 232 232 f->suggest.shift_down = f->shift_down; 233 233 f->suggest.shift_right = f->shift_right; … … 249 249 250 250 if(f->next && f->next->local_player() 251 && f->suggest.cy2 >= f->next-> cy1)251 && f->suggest.cy2 >= f->next->m_aa.y) 252 252 f->suggest.send_view = 0; 253 253 } … … 263 263 { 264 264 for(view *f = first_view; f; f = f->next) 265 if(f->drawable() && pos.x >= f->cx1 && pos.y >= f->cy1 266 && pos.x <= f->cx2 && pos.y <= f->cy2) 265 if(f->drawable() && pos >= f->m_aa && pos <= f->m_bb) 267 266 return f; 268 267 return NULL; … … 285 284 return vec2i(-1, -1); 286 285 287 return vec2i((pos.x - f-> cx1+ f->xoff() * bg_xmul / bg_xdiv) / b_wid,288 (pos.y - f-> cy1+ f->yoff() * bg_ymul / bg_ydiv) / b_hi);286 return vec2i((pos.x - f->m_aa.x + f->xoff() * bg_xmul / bg_xdiv) / b_wid, 287 (pos.y - f->m_aa.y + f->yoff() * bg_ymul / bg_ydiv) / b_hi); 289 288 } 290 289 … … 299 298 300 299 if(dev & MAP_MODE) 301 return vec2i((pos.x - v-> cx1) * ftile_width()300 return vec2i((pos.x - v->m_aa.x) * ftile_width() 302 301 / AUTOTILE_WIDTH + map_xoff * ftile_width(), 303 (pos.y - v-> cy1) * ftile_height()302 (pos.y - v->m_aa.y) * ftile_height() 304 303 / AUTOTILE_HEIGHT + map_yoff * ftile_height()); 305 304 306 return pos - v ec2i(v->cx1 - v->xoff(), v->cy1 -v->yoff());305 return pos - v->m_aa + vec2i(v->xoff(), v->yoff()); 307 306 } 308 307 … … 310 309 { 311 310 if (!(dev & MAP_MODE)) 312 return pos + v ec2i(v->cx1 - v->xoff(), v->cy1 -v->yoff());311 return pos + v->m_aa - vec2i(v->xoff(), v->yoff()); 313 312 314 313 vec2i tmp; … … 318 317 else if(v->focus) 319 318 tmp = vec2i(v->focus->x / ftile_width() 320 - (v-> cx2 - v->cx1) / AUTOTILE_WIDTH / 2,319 - (v->m_bb.x - v->m_aa.x) / AUTOTILE_WIDTH / 2, 321 320 v->focus->y / ftile_height() 322 - (v-> cy2 - v->cy1) / AUTOTILE_HEIGHT / 2);321 - (v->m_bb.y - v->m_aa.y) / AUTOTILE_HEIGHT / 2); 323 322 else 324 323 tmp = vec2i(0, 0); … … 328 327 329 328 vec2i ret(pos.x * AUTOTILE_WIDTH / ftile_width() 330 - tmp.x * AUTOTILE_WIDTH + v-> cx1,329 - tmp.x * AUTOTILE_WIDTH + v->m_aa.x, 331 330 pos.y * AUTOTILE_HEIGHT / ftile_height() 332 - tmp.y * AUTOTILE_HEIGHT + v-> cy1);331 - tmp.y * AUTOTILE_HEIGHT + v->m_aa.y); 333 332 if (tmp.x > 0) 334 333 ret.x -= (v->focus->x * AUTOTILE_WIDTH / ftile_width()) … … 392 391 else 393 392 first_view = new view(NULL, NULL, 0); 394 first_view->cx1 = (xres + 1) / 2 - 155; 395 first_view->cy1 = (yres + 1) / 2 - 95; 396 first_view->cx2 = (xres + 1) / 2 + 155; 397 if(total_weapons) 398 first_view->cy2 = (yres + 1) / 2 + 68; 399 else 400 first_view->cy2 = (yres + 1) / 2 + 95; 393 first_view->m_aa.x = (xres + 1) / 2 - 155; 394 first_view->m_aa.y = (yres + 1) / 2 - 95; 395 first_view->m_bb.x = (xres + 1) / 2 + 155; 396 first_view->m_bb.y = (yres + 1) / 2 + (total_weapons ? 68 : 95); 401 397 d = 1; 402 398 } … … 415 411 416 412 if(playing_state(state) && !(dev & EDIT_MODE)) 417 wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(8 , 8));413 wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(8)); 418 414 else 419 wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1 , 1));415 wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1)); 420 416 421 417 if(old_state == SCENE_STATE && new_state != SCENE_STATE) … … 650 646 { 651 647 if(state == SCENE_STATE) 652 main_screen->SetClip(v ec2i(v->cx1, v->cy1), vec2i(v->cx2 + 1, v->cy2 +1));648 main_screen->SetClip(v->m_aa, v->m_bb + vec2i(1)); 653 649 image *tit = cache.img(title_screen); 654 650 main_screen->PutImage(tit, main_screen->Size() / 2 - tit->Size() / 2); … … 667 663 668 664 if(small_render) 669 main_screen->AddDirty(v ec2i(v->cx1, v->cy1), vec2i((v->cx2 - v->cx1 + 1)*2 + v->cx1 + 1, v->cy1+(v->cy2 - v->cy1 + 1)*2 +1));665 main_screen->AddDirty(v->m_aa, (v->m_bb - v->m_aa + vec2i(1)) * 2 + vec2i(v->m_aa.x, 0) + vec2i(1)); 670 666 else 671 main_screen->AddDirty(v ec2i(v->cx1, v->cy1), vec2i(v->cx2 + 1, v->cy2 +1));667 main_screen->AddDirty(v->m_aa, v->m_bb + vec2i(1)); 672 668 673 669 if(v->draw_solid != -1) // fill the screen and exit.. … … 675 671 int c = v->draw_solid; 676 672 main_screen->Lock(); 677 for(int y = v-> cy1; y <= v->cy2; y++)678 memset(main_screen->scan_line(y)+v-> cx1, c, v->cx2 - v->cx1+ 1);673 for(int y = v->m_aa.y; y <= v->m_bb.y; y++) 674 memset(main_screen->scan_line(y)+v->m_aa.x, c, v->m_bb.x - v->m_aa.x + 1); 679 675 main_screen->Unlock(); 680 676 v->draw_solid = -1; … … 682 678 } 683 679 684 int32_t old_cx1 = 0, old_cy1 = 0, old_cx2 = 0, old_cy2 = 0; // if we do a small render, we need to restore these 685 image *old_screen = NULL; 680 // if we do a small render, we need to restore these 681 vec2i old_aa(0), old_bb(0); 682 image *old_screen = NULL; 683 686 684 if(small_render && (dev & DRAW_LIGHTS)) // cannot do this if we skip lighting 687 685 { 688 old_cx1 = v->cx1; 689 old_cy1 = v->cy1; 690 old_cx2 = v->cx2; 691 old_cy2 = v->cy2; 692 693 v->cx1 = 0; 694 v->cy1 = 0; 695 v->cx2 = small_render->Size().x-1; 696 v->cy2 = small_render->Size().y-1; 686 old_aa = v->m_aa; 687 old_bb = v->m_bb; 688 689 v->m_aa = vec2i(0); 690 v->m_bb = small_render->Size() - vec2i(1); 697 691 698 692 old_screen = main_screen; … … 716 710 // if(yoff > max_yoff) yoff = max_yoff; 717 711 718 current_vxadd = xoff - v-> cx1;719 current_vyadd = yoff - v-> cy1;720 721 main_screen->SetClip(v ec2i(v->cx1, v->cy1), vec2i(v->cx2 + 1, v->cy2 +1));712 current_vxadd = xoff - v->m_aa.x; 713 current_vyadd = yoff - v->m_aa.y; 714 715 main_screen->SetClip(v->m_aa, v->m_bb + vec2i(1)); 722 716 723 717 nxoff = xoff * bg_xmul / bg_xdiv; … … 725 719 726 720 727 x1 = nxoff / btile_width(); y1 = nyoff / btile_height();728 x2 = x1+(v->cx2 - v->cx1 + btile_width())/btile_width();729 y2 = y1+(v->cy2 - v->cy1 + btile_height())/btile_height();730 731 732 xo = v-> cx1- nxoff % btile_width();733 yo = v-> cy1- nyoff % btile_height();721 x1 = nxoff / btile_width(); 722 y1 = nyoff / btile_height(); 723 x2 = x1 + (v->m_bb.x - v->m_aa.x + btile_width()) / btile_width(); 724 y2 = y1 + (v->m_bb.y - v->m_aa.y + btile_height()) / btile_height(); 725 726 xo = v->m_aa.x - nxoff % btile_width(); 727 yo = v->m_aa.y - nyoff % btile_height(); 734 728 735 729 int xinc, yinc, draw_x, draw_y; … … 785 779 if(v->focus) 786 780 { 787 x1 = v->focus->x / ftile_width() -(v->cx2 - v->cx1)/fw / 2;788 y1 = v->focus->y / ftile_height() -(v->cy2 - v->cy1)/fh / 2;781 x1 = v->focus->x / ftile_width() - (v->m_bb.x - v->m_aa.x) / fw / 2; 782 y1 = v->focus->y / ftile_height() - (v->m_bb.y - v->m_aa.y) / fh / 2; 789 783 } else x1 = y1 = 0; 790 784 } 791 785 if(x1 > 0) 792 xo = v-> cx1-((v->focus->x * fw / ftile_width()) %fw);793 else xo = v-> cx1;786 xo = v->m_aa.x - ((v->focus->x * fw / ftile_width()) % fw); 787 else xo = v->m_aa.x; 794 788 if(y1 > 0) 795 yo = v-> cy1-((v->focus->y * fh / ftile_height()) %fh);796 else yo = v-> cy1;789 yo = v->m_aa.y - ((v->focus->y * fh / ftile_height()) % fh); 790 else yo = v->m_aa.y; 797 791 } else 798 792 { 799 793 fw = ftile_width(); 800 794 fh = ftile_height(); 801 x1=(xoff)/fw; y1=(yoff)/fh; 802 xo = v->cx1 - xoff % fw; 803 yo = v->cy1 - yoff % fh; 795 x1 = xoff / fw; 796 y1 = yoff / fh; 797 xo = v->m_aa.x - xoff % fw; 798 yo = v->m_aa.y - yoff % fh; 804 799 805 800 } … … 807 802 if(y1 < 0) y1 = 0; 808 803 809 x2 = x1+(v->cx2 - v->cx1 + fw)/fw; 810 y2 = y1+(v->cy2 - v->cy1 + fh)/fh; 811 if(x2 >= current_level->foreground_width()) 812 x2 = current_level->foreground_width()-1; 813 if(y2 >= current_level->foreground_height()) 814 y2 = current_level->foreground_height()-1; 815 804 x2 = x1 + (v->m_bb.x - v->m_aa.x + fw) / fw; 805 y2 = y1 + (v->m_bb.y - v->m_aa.y + fh) / fh; 806 x2 = Min(x2, current_level->foreground_width() - 1); 807 y2 = Min(y2, current_level->foreground_height() - 1); 816 808 817 809 xinc = fw; … … 987 979 if(help_text_frames >= 0) 988 980 { 989 int color; 990 991 if(help_text_frames < 10) 992 color = 2; 993 else 994 color = 2+(help_text_frames - 10); 995 996 int x1 = v->cx1, y1 = v->cy1, x2 = v->cx2, y2 = v->cy1 + wm->font()->Size().y+10; 997 998 remap_area(main_screen, x1, y1, x2, y2, white_light + 40 * 256); 999 main_screen->Bar(vec2i(x1, y1), vec2i(x2, y1), color); 1000 main_screen->Bar(vec2i(x1, y2), vec2i(x2, y2), color); 1001 1002 wm->font()->PutString(main_screen, vec2i(x1 + 5, y1 + 5), 1003 help_text, color); 981 int color = 2 + Max(0, help_text_frames - 10); 982 983 vec2i aa = v->m_aa; 984 vec2i bb(v->m_bb.x, v->m_aa.y + wm->font()->Size().y + 10); 985 986 remap_area(main_screen, aa.x, aa.y, bb.x, bb.y, white_light + 40 * 256); 987 main_screen->Bar(aa, vec2i(bb.x, aa.y), color); 988 main_screen->Bar(vec2i(aa.x, bb.y), bb, color); 989 990 wm->font()->PutString(main_screen, aa + vec2i(5), help_text, color); 1004 991 if(color > 30) 1005 992 help_text_frames = -1; … … 1012 999 dev_cont->dev_draw(v); 1013 1000 if(cache.in_use()) 1014 main_screen->PutImage(cache.img(vmm_image), vec2i(v-> cx1, v->cy2- cache.img(vmm_image)->Size().y+1));1001 main_screen->PutImage(cache.img(vmm_image), vec2i(v->m_aa.x, v->m_bb.y - cache.img(vmm_image)->Size().y+1)); 1015 1002 1016 1003 if(dev & DRAW_LIGHTS) … … 1018 1005 if(small_render) 1019 1006 { 1020 double_light_screen(main_screen, xoff, yoff, white_light, v->ambient, old_screen, old_cx1, old_cy1); 1021 1022 v->cx1 = old_cx1; 1023 v->cy1 = old_cy1; 1024 v->cx2 = old_cx2; 1025 v->cy2 = old_cy2; 1007 double_light_screen(main_screen, xoff, yoff, white_light, v->ambient, old_screen, old_aa.x, old_aa.y); 1008 1009 v->m_aa = old_aa; 1010 v->m_bb = old_bb; 1026 1011 main_screen = old_screen; 1027 1012 } else … … 1447 1432 char str[16]; 1448 1433 sprintf(str, "%ld", (long)(10000.0f / avg_ms)); 1449 console_font->PutString(main_screen, vec2i(first_view->cx1, first_view->cy1), str);1434 console_font->PutString(main_screen, first_view->m_aa, str); 1450 1435 1451 1436 sprintf(str, "%d", total_active); 1452 console_font->PutString(main_screen, vec2i(first_view->cx1, first_view->cy1 +10), str);1437 console_font->PutString(main_screen, first_view->m_aa + vec2i(0, 10), str); 1453 1438 } 1454 1439 … … 1469 1454 int w, h; 1470 1455 1471 w =(f->cx2 - f->cx1+ 1);1472 h =(f->cy2 - f->cy1+ 1);1456 w = (f->m_bb.x - f->m_aa.x + 1); 1457 h = (f->m_bb.y - f->m_aa.y + 1); 1473 1458 1474 1459 total_active += current_level->add_drawables(f->xoff()-w / 4, f->yoff()-h / 4, … … 1496 1481 { 1497 1482 for(view *f = first_view; f; f = f->next) 1498 main_screen->PutImage(cache.img(pause_image), vec2i((f->cx1 + f->cx2)/2 - cache.img(pause_image)->Size().x/2, 1499 f->cy1 + 5), 1); 1483 main_screen->PutImage(cache.img(pause_image), vec2i((f->m_aa.x + f->m_bb.x) / 2 - cache.img(pause_image)->Size().x/2, f->m_aa.y + 5), 1); 1500 1484 } 1501 1485 … … 1907 1891 int w, h; 1908 1892 1909 w =(f->cx2 - f->cx1+ 1);1910 h =(f->cy2 - f->cy1+ 1);1893 w = (f->m_bb.x - f->m_aa.x + 1); 1894 h = (f->m_bb.y - f->m_aa.y + 1); 1911 1895 total_active += current_level->add_actives(f->xoff()-w / 4, f->yoff()-h / 4, 1912 1896 f->xoff()+w + w / 4, f->yoff()+h + h / 4);
Note: See TracChangeset
for help on using the changeset viewer.