diff options
author | Franklin Wei <frankhwei536@gmail.com> | 2014-08-26 20:08:17 -0400 |
---|---|---|
committer | Michael Giacomelli <giac2000@hotmail.com> | 2014-09-14 03:48:00 +0200 |
commit | e47ed2a534d78e98711ff3b0296959df6ffd3bb9 (patch) | |
tree | b17892eaee067d7dc9ca11dfeb6fab00903147d7 /apps/plugins | |
parent | 12f5c63474c03a5f06ea5c04de267a1a8fa36233 (diff) | |
download | rockbox-e47ed2a534d78e98711ff3b0296959df6ffd3bb9.tar.gz rockbox-e47ed2a534d78e98711ff3b0296959df6ffd3bb9.zip |
Superdom: whitespace cleanup
Change-Id: Iab7aa68c4ed34809e1e9200cba9ee5bc0a09be8e
Reviewed-on: http://gerrit.rockbox.org/930
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/superdom.c | 1328 |
1 files changed, 664 insertions, 664 deletions
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index cc2ef98143..b9c18abec4 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c | |||
@@ -118,8 +118,8 @@ char buf[255]; | |||
118 | #define SUPERDOM_RIGHT BUTTON_RIGHT | 118 | #define SUPERDOM_RIGHT BUTTON_RIGHT |
119 | #define SUPERDOM_CANCEL (BUTTON_HOME|BUTTON_REPEAT) | 119 | #define SUPERDOM_CANCEL (BUTTON_HOME|BUTTON_REPEAT) |
120 | 120 | ||
121 | #elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \ | 121 | #elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \ |
122 | CONFIG_KEYPAD == SAMSUNG_YPR0_PAD | 122 | CONFIG_KEYPAD == SAMSUNG_YPR0_PAD |
123 | #define SUPERDOM_OK BUTTON_SELECT | 123 | #define SUPERDOM_OK BUTTON_SELECT |
124 | #define SUPERDOM_UP BUTTON_UP | 124 | #define SUPERDOM_UP BUTTON_UP |
125 | #define SUPERDOM_DOWN BUTTON_DOWN | 125 | #define SUPERDOM_DOWN BUTTON_DOWN |
@@ -165,8 +165,8 @@ char buf[255]; | |||
165 | #elif (CONFIG_KEYPAD == ONDAVX747_PAD) || (CONFIG_KEYPAD == MROBE500_PAD) | 165 | #elif (CONFIG_KEYPAD == ONDAVX747_PAD) || (CONFIG_KEYPAD == MROBE500_PAD) |
166 | #define SUPERDOM_CANCEL BUTTON_POWER | 166 | #define SUPERDOM_CANCEL BUTTON_POWER |
167 | 167 | ||
168 | #elif (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) || \ | 168 | #elif (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) || \ |
169 | (CONFIG_KEYPAD == SAMSUNG_YH920_PAD) | 169 | (CONFIG_KEYPAD == SAMSUNG_YH920_PAD) |
170 | #define SUPERDOM_OK BUTTON_PLAY | 170 | #define SUPERDOM_OK BUTTON_PLAY |
171 | #define SUPERDOM_UP BUTTON_UP | 171 | #define SUPERDOM_UP BUTTON_UP |
172 | #define SUPERDOM_DOWN BUTTON_DOWN | 172 | #define SUPERDOM_DOWN BUTTON_DOWN |
@@ -222,7 +222,7 @@ char buf[255]; | |||
222 | #define SUPERDOM_RIGHT BUTTON_RIGHT | 222 | #define SUPERDOM_RIGHT BUTTON_RIGHT |
223 | #define SUPERDOM_CANCEL BUTTON_POWER | 223 | #define SUPERDOM_CANCEL BUTTON_POWER |
224 | 224 | ||
225 | #elif (CONFIG_KEYPAD == HM60X_PAD) || \ | 225 | #elif (CONFIG_KEYPAD == HM60X_PAD) || \ |
226 | (CONFIG_KEYPAD == HM801_PAD) | 226 | (CONFIG_KEYPAD == HM801_PAD) |
227 | #define SUPERDOM_OK BUTTON_SELECT | 227 | #define SUPERDOM_OK BUTTON_SELECT |
228 | #define SUPERDOM_UP BUTTON_UP | 228 | #define SUPERDOM_UP BUTTON_UP |
@@ -375,73 +375,73 @@ void draw_board(void) { | |||
375 | } else { | 375 | } else { |
376 | rb->lcd_set_foreground(LCD_LIGHTGRAY); | 376 | rb->lcd_set_foreground(LCD_LIGHTGRAY); |
377 | } | 377 | } |
378 | rb->lcd_fillrect(MARGIN+(BOX_WIDTH*(i-1)), | 378 | rb->lcd_fillrect(MARGIN+(BOX_WIDTH*(i-1)), |
379 | MARGIN+(BOX_HEIGHT*(j-1)), BOX_WIDTH, | 379 | MARGIN+(BOX_HEIGHT*(j-1)), BOX_WIDTH, |
380 | BOX_HEIGHT); | 380 | BOX_HEIGHT); |
381 | #if LCD_DEPTH != 16 | 381 | #if LCD_DEPTH != 16 |
382 | rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); | 382 | rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); |
383 | #endif | 383 | #endif |
384 | if(board[i][j].ind) { | 384 | if(board[i][j].ind) { |
385 | MY_BITMAP_PART(superdom_boarditems, | 385 | MY_BITMAP_PART(superdom_boarditems, |
386 | board[i][j].colour?ICON_WIDTH:0, 0, ICON_STRIDE, | 386 | board[i][j].colour?ICON_WIDTH:0, 0, ICON_STRIDE, |
387 | #if LCD_WIDTH > LCD_HEIGHT | 387 | #if LCD_WIDTH > LCD_HEIGHT |
388 | MARGIN+(BOX_WIDTH*(i-1))+1, | 388 | MARGIN+(BOX_WIDTH*(i-1))+1, |
389 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT+1, | 389 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT+1, |
390 | #else | 390 | #else |
391 | MARGIN+(BOX_WIDTH*(i-1))+1+ICON_WIDTH, | 391 | MARGIN+(BOX_WIDTH*(i-1))+1+ICON_WIDTH, |
392 | MARGIN+(BOX_HEIGHT*(j-1))+1, | 392 | MARGIN+(BOX_HEIGHT*(j-1))+1, |
393 | #endif | 393 | #endif |
394 | ICON_WIDTH, ICON_HEIGHT); | 394 | ICON_WIDTH, ICON_HEIGHT); |
395 | } | 395 | } |
396 | if(board[i][j].farm) { | 396 | if(board[i][j].farm) { |
397 | MY_BITMAP_PART(superdom_boarditems, | 397 | MY_BITMAP_PART(superdom_boarditems, |
398 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT, | 398 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT, |
399 | ICON_STRIDE, MARGIN+(BOX_WIDTH*(i-1))+1, | 399 | ICON_STRIDE, MARGIN+(BOX_WIDTH*(i-1))+1, |
400 | MARGIN+(BOX_HEIGHT*(j-1))+1, | 400 | MARGIN+(BOX_HEIGHT*(j-1))+1, |
401 | ICON_WIDTH, ICON_HEIGHT); | 401 | ICON_WIDTH, ICON_HEIGHT); |
402 | } | 402 | } |
403 | if(board[i][j].tank) { | 403 | if(board[i][j].tank) { |
404 | MY_BITMAP_PART(superdom_boarditems, | 404 | MY_BITMAP_PART(superdom_boarditems, |
405 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*2, | 405 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*2, |
406 | ICON_STRIDE, MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, | 406 | ICON_STRIDE, MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, |
407 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT+1, | 407 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT+1, |
408 | ICON_WIDTH, ICON_HEIGHT); | 408 | ICON_WIDTH, ICON_HEIGHT); |
409 | } | 409 | } |
410 | if(board[i][j].men) { | 410 | if(board[i][j].men) { |
411 | MY_BITMAP_PART(superdom_boarditems, | 411 | MY_BITMAP_PART(superdom_boarditems, |
412 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*3, | 412 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*3, |
413 | #if LCD_WIDTH > LCD_HEIGHT | 413 | #if LCD_WIDTH > LCD_HEIGHT |
414 | ICON_STRIDE, MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, | 414 | ICON_STRIDE, MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, |
415 | MARGIN+(BOX_HEIGHT*(j-1))+1, | 415 | MARGIN+(BOX_HEIGHT*(j-1))+1, |
416 | #else | 416 | #else |
417 | ICON_STRIDE, MARGIN+(BOX_WIDTH*(i-1))+1, | 417 | ICON_STRIDE, MARGIN+(BOX_WIDTH*(i-1))+1, |
418 | MARGIN+(BOX_HEIGHT*(j-1))+1+ICON_HEIGHT, | 418 | MARGIN+(BOX_HEIGHT*(j-1))+1+ICON_HEIGHT, |
419 | #endif | 419 | #endif |
420 | ICON_WIDTH, ICON_HEIGHT); | 420 | ICON_WIDTH, ICON_HEIGHT); |
421 | } | 421 | } |
422 | if(board[i][j].plane) { | 422 | if(board[i][j].plane) { |
423 | MY_BITMAP_PART(superdom_boarditems, | 423 | MY_BITMAP_PART(superdom_boarditems, |
424 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*4, | 424 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*4, |
425 | #if LCD_WIDTH > LCD_HEIGHT | 425 | #if LCD_WIDTH > LCD_HEIGHT |
426 | ICON_STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH*2+1, | 426 | ICON_STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH*2+1, |
427 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT+1, | 427 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT+1, |
428 | #else | 428 | #else |
429 | ICON_STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, | 429 | ICON_STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, |
430 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT*2+1, | 430 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT*2+1, |
431 | #endif | 431 | #endif |
432 | ICON_WIDTH, ICON_HEIGHT); | 432 | ICON_WIDTH, ICON_HEIGHT); |
433 | } | 433 | } |
434 | if(board[i][j].nuke) { | 434 | if(board[i][j].nuke) { |
435 | MY_BITMAP_PART(superdom_boarditems, | 435 | MY_BITMAP_PART(superdom_boarditems, |
436 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*5, | 436 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*5, |
437 | #if LCD_WIDTH > LCD_HEIGHT | 437 | #if LCD_WIDTH > LCD_HEIGHT |
438 | ICON_STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH*2+1, | 438 | ICON_STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH*2+1, |
439 | MARGIN+(BOX_HEIGHT*(j-1))+1, | 439 | MARGIN+(BOX_HEIGHT*(j-1))+1, |
440 | #else | 440 | #else |
441 | ICON_STRIDE,MARGIN+(BOX_WIDTH*(i-1))+1, | 441 | ICON_STRIDE,MARGIN+(BOX_WIDTH*(i-1))+1, |
442 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT*2+1, | 442 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT*2+1, |
443 | #endif | 443 | #endif |
444 | ICON_WIDTH, ICON_HEIGHT); | 444 | ICON_WIDTH, ICON_HEIGHT); |
445 | } | 445 | } |
446 | #if LCD_DEPTH != 16 | 446 | #if LCD_DEPTH != 16 |
447 | rb->lcd_set_drawmode(DRMODE_SOLID); | 447 | rb->lcd_set_drawmode(DRMODE_SOLID); |
@@ -489,8 +489,8 @@ void gen_interest(void) { | |||
489 | 489 | ||
490 | void draw_cursor(void) { | 490 | void draw_cursor(void) { |
491 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | 491 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); |
492 | rb->lcd_fillrect(MARGIN+((cursor.x-1)*BOX_WIDTH), | 492 | rb->lcd_fillrect(MARGIN+((cursor.x-1)*BOX_WIDTH), |
493 | MARGIN+((cursor.y-1)*BOX_HEIGHT), BOX_WIDTH+1, BOX_HEIGHT+1); | 493 | MARGIN+((cursor.y-1)*BOX_HEIGHT), BOX_WIDTH+1, BOX_HEIGHT+1); |
494 | rb->lcd_set_drawmode(DRMODE_SOLID); | 494 | rb->lcd_set_drawmode(DRMODE_SOLID); |
495 | rb->lcd_update(); | 495 | rb->lcd_update(); |
496 | } | 496 | } |
@@ -504,58 +504,58 @@ void gen_resources(void) { | |||
504 | gen_interest(); | 504 | gen_interest(); |
505 | rb->srand(*rb->current_tick); | 505 | rb->srand(*rb->current_tick); |
506 | /* Generate Human's resources */ | 506 | /* Generate Human's resources */ |
507 | for(i=0;i<humanres.inds;i++) { | 507 | for(i=0;i<humanres.inds;i++) { |
508 | inccash += (300+rb->rand()%200); | 508 | inccash += (300+rb->rand()%200); |
509 | } | ||
510 | for(i=0;i<humanres.farms;i++) { | ||
511 | incfood += (200+rb->rand()%200); | ||
512 | } | ||
513 | if(humanres.inds) | ||
514 | ratecash = inccash/humanres.inds; | ||
515 | if(humanres.farms) | ||
516 | ratefood = incfood/humanres.farms; | ||
517 | if(ratecash > 450) { | ||
518 | if(ratefood > 350) { | ||
519 | rb->splash(HZ*2, "Patriotism sweeps the land, all production" | ||
520 | " is up this year!"); | ||
521 | } else { | ||
522 | rb->splash(HZ*2, "Factories working at maximum efficiency," | ||
523 | " cash production up this year!"); | ||
509 | } | 524 | } |
510 | for(i=0;i<humanres.farms;i++) { | 525 | } else if(ratecash > 350) { |
511 | incfood += (200+rb->rand()%200); | 526 | if(ratefood > 350) { |
527 | rb->splash(HZ*2, "Record crop harvest this year!"); | ||
528 | } else if(ratefood > 250) { | ||
529 | rb->splash(HZ*2, "Production continues as normal"); | ||
530 | } else { | ||
531 | rb->splash(HZ*2, "Spoilage of crops leads to reduced farm" | ||
532 | " output this year"); | ||
512 | } | 533 | } |
513 | if(humanres.inds) | 534 | } else { |
514 | ratecash = inccash/humanres.inds; | 535 | if(ratefood > 350) { |
515 | if(humanres.farms) | 536 | rb->splash(HZ*2, "Record crop harvest this year!"); |
516 | ratefood = incfood/humanres.farms; | 537 | } else if(ratefood > 250) { |
517 | if(ratecash > 450) { | 538 | rb->splash(HZ*2, "Factory unions introduced. Industrial" |
518 | if(ratefood > 350) { | 539 | " production is down this year."); |
519 | rb->splash(HZ*2, "Patriotism sweeps the land, all production" | ||
520 | " is up this year!"); | ||
521 | } else { | ||
522 | rb->splash(HZ*2, "Factories working at maximum efficiency," | ||
523 | " cash production up this year!"); | ||
524 | } | ||
525 | } else if(ratecash > 350) { | ||
526 | if(ratefood > 350) { | ||
527 | rb->splash(HZ*2, "Record crop harvest this year!"); | ||
528 | } else if(ratefood > 250) { | ||
529 | rb->splash(HZ*2, "Production continues as normal"); | ||
530 | } else { | ||
531 | rb->splash(HZ*2, "Spoilage of crops leads to reduced farm" | ||
532 | " output this year"); | ||
533 | } | ||
534 | } else { | 540 | } else { |
535 | if(ratefood > 350) { | 541 | rb->splash(HZ*2, "Internet created. All production is down" |
536 | rb->splash(HZ*2, "Record crop harvest this year!"); | 542 | " due to time wasted."); |
537 | } else if(ratefood > 250) { | ||
538 | rb->splash(HZ*2, "Factory unions introduced. Industrial" | ||
539 | " production is down this year."); | ||
540 | } else { | ||
541 | rb->splash(HZ*2, "Internet created. All production is down" | ||
542 | " due to time wasted."); | ||
543 | } | ||
544 | } | 543 | } |
545 | humanres.cash += inccash; | 544 | } |
546 | humanres.food += incfood; | 545 | humanres.cash += inccash; |
546 | humanres.food += incfood; | ||
547 | 547 | ||
548 | /* Generate Computer's resources */ | 548 | /* Generate Computer's resources */ |
549 | inccash = 0; | 549 | inccash = 0; |
550 | incfood = 0; | 550 | incfood = 0; |
551 | for(i=0;i<compres.inds;i++) { | 551 | for(i=0;i<compres.inds;i++) { |
552 | inccash += (300+rb->rand()%200); | 552 | inccash += (300+rb->rand()%200); |
553 | } | 553 | } |
554 | for(i=0;i<compres.farms;i++) { | 554 | for(i=0;i<compres.farms;i++) { |
555 | incfood += (200+rb->rand()%200); | 555 | incfood += (200+rb->rand()%200); |
556 | } | 556 | } |
557 | compres.cash += inccash; | 557 | compres.cash += inccash; |
558 | compres.food += incfood; | 558 | compres.food += incfood; |
559 | } | 559 | } |
560 | 560 | ||
561 | static void update_score(void) { | 561 | static void update_score(void) { |
@@ -575,46 +575,46 @@ static int settings_menu(void) { | |||
575 | int selection = 0; | 575 | int selection = 0; |
576 | 576 | ||
577 | MENUITEM_STRINGLIST(menu, "Super Domination Settings", NULL, | 577 | MENUITEM_STRINGLIST(menu, "Super Domination Settings", NULL, |
578 | "Computer starting farms", "Computer starting factories", | 578 | "Computer starting farms", "Computer starting factories", |
579 | "Human starting farms", "Human starting factories", | 579 | "Human starting farms", "Human starting factories", |
580 | "Starting cash", "Starting food", "Moves per turn"); | 580 | "Starting cash", "Starting food", "Moves per turn"); |
581 | 581 | ||
582 | while(1) { | 582 | while(1) { |
583 | switch(rb->do_menu(&menu, &selection, NULL, false)) { | 583 | switch(rb->do_menu(&menu, &selection, NULL, false)) { |
584 | case 0: | 584 | case 0: |
585 | rb->set_int("Computer starting farms", "", UNIT_INT, | 585 | rb->set_int("Computer starting farms", "", UNIT_INT, |
586 | &superdom_settings.compstartfarms, NULL, | 586 | &superdom_settings.compstartfarms, NULL, |
587 | 1, 0, 5, NULL); | 587 | 1, 0, 5, NULL); |
588 | break; | 588 | break; |
589 | case 1: | 589 | case 1: |
590 | rb->set_int("Computer starting factories", "", UNIT_INT, | 590 | rb->set_int("Computer starting factories", "", UNIT_INT, |
591 | &superdom_settings.compstartinds, NULL, | 591 | &superdom_settings.compstartinds, NULL, |
592 | 1, 0, 5, NULL); | 592 | 1, 0, 5, NULL); |
593 | break; | 593 | break; |
594 | case 2: | 594 | case 2: |
595 | rb->set_int("Human starting farms", "", UNIT_INT, | 595 | rb->set_int("Human starting farms", "", UNIT_INT, |
596 | &superdom_settings.humanstartfarms, NULL, | 596 | &superdom_settings.humanstartfarms, NULL, |
597 | 1, 0, 5, NULL); | 597 | 1, 0, 5, NULL); |
598 | break; | 598 | break; |
599 | case 3: | 599 | case 3: |
600 | rb->set_int("Human starting factories", "", UNIT_INT, | 600 | rb->set_int("Human starting factories", "", UNIT_INT, |
601 | &superdom_settings.humanstartinds, NULL, | 601 | &superdom_settings.humanstartinds, NULL, |
602 | 1, 0, 5, NULL); | 602 | 1, 0, 5, NULL); |
603 | break; | 603 | break; |
604 | case 4: | 604 | case 4: |
605 | rb->set_int("Starting cash", "", UNIT_INT, | 605 | rb->set_int("Starting cash", "", UNIT_INT, |
606 | &superdom_settings.startcash, NULL, | 606 | &superdom_settings.startcash, NULL, |
607 | 250, 0, 5000, NULL); | 607 | 250, 0, 5000, NULL); |
608 | break; | 608 | break; |
609 | case 5: | 609 | case 5: |
610 | rb->set_int("Starting food", "", UNIT_INT, | 610 | rb->set_int("Starting food", "", UNIT_INT, |
611 | &superdom_settings.startfood, NULL, | 611 | &superdom_settings.startfood, NULL, |
612 | 250, 0, 5000, NULL); | 612 | 250, 0, 5000, NULL); |
613 | break; | 613 | break; |
614 | case 6: | 614 | case 6: |
615 | rb->set_int("Moves per turn", "", UNIT_INT, | 615 | rb->set_int("Moves per turn", "", UNIT_INT, |
616 | &superdom_settings.movesperturn, NULL, | 616 | &superdom_settings.movesperturn, NULL, |
617 | 1, 1, 5, NULL); | 617 | 1, 1, 5, NULL); |
618 | break; | 618 | break; |
619 | case MENU_ATTACHED_USB: | 619 | case MENU_ATTACHED_USB: |
620 | return RET_VAL_USB; | 620 | return RET_VAL_USB; |
@@ -650,29 +650,29 @@ static int start_menu(void) { | |||
650 | int selection = 0; | 650 | int selection = 0; |
651 | 651 | ||
652 | MENUITEM_STRINGLIST(menu, "Super Domination Menu", NULL, | 652 | MENUITEM_STRINGLIST(menu, "Super Domination Menu", NULL, |
653 | "Play Super Domination", "Settings", | 653 | "Play Super Domination", "Settings", |
654 | "Help", "Playback Control", "Quit"); | 654 | "Help", "Playback Control", "Quit"); |
655 | 655 | ||
656 | while(1) { | 656 | while(1) { |
657 | switch(rb->do_menu(&menu, &selection, NULL, false)) { | 657 | switch(rb->do_menu(&menu, &selection, NULL, false)) { |
658 | case 0: | 658 | case 0: |
659 | return RET_VAL_OK; /* start playing */ | 659 | return RET_VAL_OK; /* start playing */ |
660 | break; | 660 | break; |
661 | case 1: | 661 | case 1: |
662 | if(settings_menu()==RET_VAL_USB) | 662 | if(settings_menu()==RET_VAL_USB) |
663 | return RET_VAL_USB; | 663 | return RET_VAL_USB; |
664 | break; | 664 | break; |
665 | case 2: | 665 | case 2: |
666 | if(superdom_help()==RET_VAL_USB) | 666 | if(superdom_help()==RET_VAL_USB) |
667 | return RET_VAL_USB; | 667 | return RET_VAL_USB; |
668 | break; | 668 | break; |
669 | case 3: | 669 | case 3: |
670 | if(playback_control(NULL)) | 670 | if(playback_control(NULL)) |
671 | return RET_VAL_USB; | 671 | return RET_VAL_USB; |
672 | break; | 672 | break; |
673 | case 4: | 673 | case 4: |
674 | return RET_VAL_QUIT_ERR; | 674 | return RET_VAL_QUIT_ERR; |
675 | break; | 675 | break; |
676 | } | 676 | } |
677 | } | 677 | } |
678 | return RET_VAL_QUIT_ERR; | 678 | return RET_VAL_QUIT_ERR; |
@@ -731,32 +731,32 @@ static int save_game(void) { | |||
731 | 731 | ||
732 | static int ingame_menu(void) { | 732 | static int ingame_menu(void) { |
733 | MENUITEM_STRINGLIST(menu, "Super Domination Menu", NULL, | 733 | MENUITEM_STRINGLIST(menu, "Super Domination Menu", NULL, |
734 | "Return to game", "Save Game", | 734 | "Return to game", "Save Game", |
735 | "Playback Control", "Quit"); | 735 | "Playback Control", "Quit"); |
736 | 736 | ||
737 | switch(rb->do_menu(&menu, NULL, NULL, false)) { | 737 | switch(rb->do_menu(&menu, NULL, NULL, false)) { |
738 | case 0: | 738 | case 0: |
739 | return RET_VAL_OK; | 739 | return RET_VAL_OK; |
740 | break; | 740 | break; |
741 | case 1: | 741 | case 1: |
742 | if(!save_game()) | 742 | if(!save_game()) |
743 | rb->splash(HZ, "Game saved"); | 743 | rb->splash(HZ, "Game saved"); |
744 | else | 744 | else |
745 | rb->splash(HZ, "Error in save"); | 745 | rb->splash(HZ, "Error in save"); |
746 | break; | 746 | break; |
747 | case 2: | 747 | case 2: |
748 | if(playback_control(NULL)) | 748 | if(playback_control(NULL)) |
749 | return RET_VAL_USB; | ||
750 | break; | ||
751 | case 3: | ||
752 | return RET_VAL_QUIT_ERR; | ||
753 | break; | ||
754 | case MENU_ATTACHED_USB: | ||
755 | return RET_VAL_USB; | 749 | return RET_VAL_USB; |
756 | break; | 750 | break; |
757 | case GO_TO_PREVIOUS: | 751 | case 3: |
758 | return RET_VAL_OK; | 752 | return RET_VAL_QUIT_ERR; |
759 | break; | 753 | break; |
754 | case MENU_ATTACHED_USB: | ||
755 | return RET_VAL_USB; | ||
756 | break; | ||
757 | case GO_TO_PREVIOUS: | ||
758 | return RET_VAL_OK; | ||
759 | break; | ||
760 | } | 760 | } |
761 | return RET_VAL_OK; | 761 | return RET_VAL_OK; |
762 | } | 762 | } |
@@ -789,9 +789,9 @@ static int get_number(char* param, int* value, int max) { | |||
789 | for(j=0;j<3;j++) { | 789 | for(j=0;j<3;j++) { |
790 | rb->lcd_getstringsize(button_labels[i][j], &width, &height); | 790 | rb->lcd_getstringsize(button_labels[i][j], &width, &height); |
791 | rb->lcd_putsxy( | 791 | rb->lcd_putsxy( |
792 | NUM_MARGIN_X+(j*NUM_BOX_WIDTH)+NUM_BOX_WIDTH/2-width/2, | 792 | NUM_MARGIN_X+(j*NUM_BOX_WIDTH)+NUM_BOX_WIDTH/2-width/2, |
793 | NUM_MARGIN_Y+(i*NUM_BOX_HEIGHT)+NUM_BOX_HEIGHT/2-height/2, | 793 | NUM_MARGIN_Y+(i*NUM_BOX_HEIGHT)+NUM_BOX_HEIGHT/2-height/2, |
794 | button_labels[i][j]); | 794 | button_labels[i][j]); |
795 | } | 795 | } |
796 | } | 796 | } |
797 | rb->lcd_putsxyf(NUM_MARGIN_X+10, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10,"%d",*value); | 797 | rb->lcd_putsxyf(NUM_MARGIN_X+10, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10,"%d",*value); |
@@ -801,113 +801,113 @@ static int get_number(char* param, int* value, int max) { | |||
801 | else | 801 | else |
802 | rb->lcd_puts_scroll(0, (NUM_MARGIN_Y/height-1)/2, param); | 802 | rb->lcd_puts_scroll(0, (NUM_MARGIN_Y/height-1)/2, param); |
803 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | 803 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); |
804 | rb->lcd_fillrect(NUM_MARGIN_X+(NUM_BOX_WIDTH*x), | 804 | rb->lcd_fillrect(NUM_MARGIN_X+(NUM_BOX_WIDTH*x), |
805 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*y), | 805 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*y), |
806 | NUM_BOX_WIDTH+1, NUM_BOX_HEIGHT+1); | 806 | NUM_BOX_WIDTH+1, NUM_BOX_HEIGHT+1); |
807 | rb->lcd_set_drawmode(DRMODE_SOLID); | 807 | rb->lcd_set_drawmode(DRMODE_SOLID); |
808 | rb->lcd_update(); | 808 | rb->lcd_update(); |
809 | while(!done) { | 809 | while(!done) { |
810 | button = rb->button_get(true); | 810 | button = rb->button_get(true); |
811 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | 811 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); |
812 | rb->lcd_fillrect(NUM_MARGIN_X+(NUM_BOX_WIDTH*x), | 812 | rb->lcd_fillrect(NUM_MARGIN_X+(NUM_BOX_WIDTH*x), |
813 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*y), | 813 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*y), |
814 | NUM_BOX_WIDTH+1, NUM_BOX_HEIGHT+1); | 814 | NUM_BOX_WIDTH+1, NUM_BOX_HEIGHT+1); |
815 | rb->lcd_set_drawmode(DRMODE_SOLID); | 815 | rb->lcd_set_drawmode(DRMODE_SOLID); |
816 | switch(button) { | 816 | switch(button) { |
817 | case SUPERDOM_OK: | 817 | case SUPERDOM_OK: |
818 | if(y!=3) { | 818 | if(y!=3) { |
819 | *value *= 10; | 819 | *value *= 10; |
820 | *value += button_labels[y][x][0] - '0'; | 820 | *value += button_labels[y][x][0] - '0'; |
821 | } else if(x==0) { | 821 | } else if(x==0) { |
822 | *value /= 10; | 822 | *value /= 10; |
823 | } else if(x==1) { | 823 | } else if(x==1) { |
824 | *value *= 10; | 824 | *value *= 10; |
825 | } else if(x==2) { | 825 | } else if(x==2) { |
826 | done = true; | ||
827 | break; | ||
828 | } | ||
829 | if ((unsigned) *value > (unsigned) max) | ||
830 | *value = max; | ||
831 | rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); | ||
832 | rb->lcd_fillrect(0, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, | ||
833 | LCD_WIDTH, 30); | ||
834 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
835 | rb->lcd_putsxyf(NUM_MARGIN_X+10,NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, | ||
836 | "%d", *value); | ||
837 | break; | ||
838 | case SUPERDOM_CANCEL: | ||
839 | *value = 0; | ||
840 | done = true; | 826 | done = true; |
841 | ret = RET_VAL_QUIT_ERR; | ||
842 | break; | 827 | break; |
828 | } | ||
829 | if ((unsigned) *value > (unsigned) max) | ||
830 | *value = max; | ||
831 | rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); | ||
832 | rb->lcd_fillrect(0, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, | ||
833 | LCD_WIDTH, 30); | ||
834 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
835 | rb->lcd_putsxyf(NUM_MARGIN_X+10,NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, | ||
836 | "%d", *value); | ||
837 | break; | ||
838 | case SUPERDOM_CANCEL: | ||
839 | *value = 0; | ||
840 | done = true; | ||
841 | ret = RET_VAL_QUIT_ERR; | ||
842 | break; | ||
843 | #if CONFIG_KEYPAD != IRIVER_H10_PAD | 843 | #if CONFIG_KEYPAD != IRIVER_H10_PAD |
844 | case SUPERDOM_LEFT: | 844 | case SUPERDOM_LEFT: |
845 | if(x==0) { | 845 | if(x==0) { |
846 | #ifdef IPOD_STYLE | 846 | #ifdef IPOD_STYLE |
847 | if(y>0) | 847 | if(y>0) |
848 | y--; | 848 | y--; |
849 | else | 849 | else |
850 | y=3; | 850 | y=3; |
851 | #endif | 851 | #endif |
852 | x=2; | 852 | x=2; |
853 | } else { | 853 | } else { |
854 | x--; | 854 | x--; |
855 | } | 855 | } |
856 | break; | 856 | break; |
857 | case SUPERDOM_RIGHT: | 857 | case SUPERDOM_RIGHT: |
858 | if(x==2) { | 858 | if(x==2) { |
859 | #ifdef IPOD_STYLE | 859 | #ifdef IPOD_STYLE |
860 | if(y==3) | 860 | if(y==3) |
861 | y=0; | 861 | y=0; |
862 | else | 862 | else |
863 | y++; | 863 | y++; |
864 | #endif | 864 | #endif |
865 | x=0; | 865 | x=0; |
866 | } else { | 866 | } else { |
867 | x++; | 867 | x++; |
868 | } | 868 | } |
869 | break; | 869 | break; |
870 | #endif | 870 | #endif |
871 | #ifndef IPOD_STYLE | 871 | #ifndef IPOD_STYLE |
872 | case SUPERDOM_UP: | 872 | case SUPERDOM_UP: |
873 | if(y==0) { | 873 | if(y==0) { |
874 | #if CONFIG_KEYPAD == IRIVER_H10_PAD | 874 | #if CONFIG_KEYPAD == IRIVER_H10_PAD |
875 | if(x > 0) | 875 | if(x > 0) |
876 | x--; | 876 | x--; |
877 | else | 877 | else |
878 | x=2; | 878 | x=2; |
879 | #endif | 879 | #endif |
880 | y=3; | 880 | y=3; |
881 | } else { | 881 | } else { |
882 | y--; | 882 | y--; |
883 | } | 883 | } |
884 | break; | 884 | break; |
885 | case SUPERDOM_DOWN: | 885 | case SUPERDOM_DOWN: |
886 | if(y==3) { | 886 | if(y==3) { |
887 | #if CONFIG_KEYPAD == IRIVER_H10_PAD | 887 | #if CONFIG_KEYPAD == IRIVER_H10_PAD |
888 | if(x < 2) | 888 | if(x < 2) |
889 | x++; | 889 | x++; |
890 | else | 890 | else |
891 | x=0; | 891 | x=0; |
892 | #endif | 892 | #endif |
893 | y=0; | 893 | y=0; |
894 | } else { | 894 | } else { |
895 | y++; | 895 | y++; |
896 | } | 896 | } |
897 | break; | 897 | break; |
898 | #endif | 898 | #endif |
899 | default: | 899 | default: |
900 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) | 900 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) |
901 | { | 901 | { |
902 | done = true; | 902 | done = true; |
903 | ret = RET_VAL_USB; | 903 | ret = RET_VAL_USB; |
904 | } | 904 | } |
905 | break; | 905 | break; |
906 | } | 906 | } |
907 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | 907 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); |
908 | rb->lcd_fillrect(NUM_MARGIN_X+(NUM_BOX_WIDTH*x), | 908 | rb->lcd_fillrect(NUM_MARGIN_X+(NUM_BOX_WIDTH*x), |
909 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*y), | 909 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*y), |
910 | NUM_BOX_WIDTH+1, NUM_BOX_HEIGHT+1); | 910 | NUM_BOX_WIDTH+1, NUM_BOX_HEIGHT+1); |
911 | rb->lcd_set_drawmode(DRMODE_SOLID); | 911 | rb->lcd_set_drawmode(DRMODE_SOLID); |
912 | rb->lcd_update(); | 912 | rb->lcd_update(); |
913 | } | 913 | } |
@@ -920,24 +920,24 @@ static int get_number(char* param, int* value, int max) { | |||
920 | 920 | ||
921 | static bool tile_has_item(int type, int x, int y) { | 921 | static bool tile_has_item(int type, int x, int y) { |
922 | switch(type) { | 922 | switch(type) { |
923 | case 0: | 923 | case 0: |
924 | return (board[x][y].men > 0); | 924 | return (board[x][y].men > 0); |
925 | break; | 925 | break; |
926 | case 1: | 926 | case 1: |
927 | return board[x][y].tank; | 927 | return board[x][y].tank; |
928 | break; | 928 | break; |
929 | case 2: | 929 | case 2: |
930 | return board[x][y].plane; | 930 | return board[x][y].plane; |
931 | break; | 931 | break; |
932 | case 3: | 932 | case 3: |
933 | return board[x][y].farm; | 933 | return board[x][y].farm; |
934 | break; | 934 | break; |
935 | case 4: | 935 | case 4: |
936 | return board[x][y].ind; | 936 | return board[x][y].ind; |
937 | break; | 937 | break; |
938 | case 5: | 938 | case 5: |
939 | return board[x][y].nuke; | 939 | return board[x][y].nuke; |
940 | break; | 940 | break; |
941 | } | 941 | } |
942 | return false; | 942 | return false; |
943 | } | 943 | } |
@@ -979,24 +979,24 @@ static int buy_resources(int colour, int type, int x, int y, int nummen) { | |||
979 | res = &compres; | 979 | res = &compres; |
980 | } | 980 | } |
981 | switch(type) { | 981 | switch(type) { |
982 | case 0: /* men */ | 982 | case 0: /* men */ |
983 | price = 1*nummen; | 983 | price = 1*nummen; |
984 | break; | 984 | break; |
985 | case 1: /* tank */ | 985 | case 1: /* tank */ |
986 | price = 300; | 986 | price = 300; |
987 | break; | 987 | break; |
988 | case 2: /* plane */ | 988 | case 2: /* plane */ |
989 | price = 600; | 989 | price = 600; |
990 | break; | 990 | break; |
991 | case 3: /* Farm */ | 991 | case 3: /* Farm */ |
992 | price = 1150; | 992 | price = 1150; |
993 | break; | 993 | break; |
994 | case 4: /* Factory */ | 994 | case 4: /* Factory */ |
995 | price = 1300; | 995 | price = 1300; |
996 | break; | 996 | break; |
997 | case 5: /* nuke */ | 997 | case 5: /* nuke */ |
998 | price = 2000; | 998 | price = 2000; |
999 | break; | 999 | break; |
1000 | } | 1000 | } |
1001 | if(res->cash < price) { | 1001 | if(res->cash < price) { |
1002 | if(human) | 1002 | if(human) |
@@ -1021,30 +1021,30 @@ static int buy_resources(int colour, int type, int x, int y, int nummen) { | |||
1021 | return RET_VAL_QUIT_ERR; | 1021 | return RET_VAL_QUIT_ERR; |
1022 | } | 1022 | } |
1023 | switch(type) { | 1023 | switch(type) { |
1024 | case 0: | 1024 | case 0: |
1025 | board[x][y].men += nummen; | 1025 | board[x][y].men += nummen; |
1026 | res->men += nummen; | 1026 | res->men += nummen; |
1027 | break; | 1027 | break; |
1028 | case 1: | 1028 | case 1: |
1029 | board[x][y].tank = true; | 1029 | board[x][y].tank = true; |
1030 | res->tanks++; | 1030 | res->tanks++; |
1031 | break; | 1031 | break; |
1032 | case 2: | 1032 | case 2: |
1033 | board[x][y].plane = true; | 1033 | board[x][y].plane = true; |
1034 | res->planes++; | 1034 | res->planes++; |
1035 | break; | 1035 | break; |
1036 | case 3: | 1036 | case 3: |
1037 | board[x][y].farm = true; | 1037 | board[x][y].farm = true; |
1038 | res->farms++; | 1038 | res->farms++; |
1039 | break; | 1039 | break; |
1040 | case 4: | 1040 | case 4: |
1041 | board[x][y].ind = true; | 1041 | board[x][y].ind = true; |
1042 | res->inds++; | 1042 | res->inds++; |
1043 | break; | 1043 | break; |
1044 | case 5: | 1044 | case 5: |
1045 | board[x][y].nuke = true; | 1045 | board[x][y].nuke = true; |
1046 | res->nukes++; | 1046 | res->nukes++; |
1047 | break; | 1047 | break; |
1048 | } | 1048 | } |
1049 | res->cash -= price; | 1049 | res->cash -= price; |
1050 | 1050 | ||
@@ -1058,46 +1058,46 @@ static int buy_resources_menu(void) { | |||
1058 | int selection = 0,nummen; | 1058 | int selection = 0,nummen; |
1059 | 1059 | ||
1060 | MENUITEM_STRINGLIST(menu, "Buy Resources", NULL, | 1060 | MENUITEM_STRINGLIST(menu, "Buy Resources", NULL, |
1061 | "Buy men ($1)", "Buy tank ($300)", "Buy plane ($600)", | 1061 | "Buy men ($1)", "Buy tank ($300)", "Buy plane ($600)", |
1062 | "Buy Farm ($1150)", "Buy Factory ($1300)", | 1062 | "Buy Farm ($1150)", "Buy Factory ($1300)", |
1063 | "Buy Nuke ($2000)", | 1063 | "Buy Nuke ($2000)", |
1064 | "Finish buying"); | 1064 | "Finish buying"); |
1065 | 1065 | ||
1066 | while(1) { | 1066 | while(1) { |
1067 | switch(rb->do_menu(&menu, &selection, NULL, false)) { | 1067 | switch(rb->do_menu(&menu, &selection, NULL, false)) { |
1068 | case 0: | 1068 | case 0: |
1069 | nummen = 0; | 1069 | nummen = 0; |
1070 | if(get_number("How many men would you like?", &nummen, | 1070 | if(get_number("How many men would you like?", &nummen, |
1071 | humanres.cash) == RET_VAL_USB) | 1071 | humanres.cash) == RET_VAL_USB) |
1072 | return RET_VAL_USB; | ||
1073 | if(!nummen) | ||
1074 | break; | ||
1075 | /* fall through */ | ||
1076 | case 1: | ||
1077 | case 2: | ||
1078 | case 3: | ||
1079 | case 4: | ||
1080 | case 5: | ||
1081 | if(buy_resources(COLOUR_LIGHT, selection, 0, 0, nummen) | ||
1082 | == RET_VAL_USB) | ||
1083 | return RET_VAL_USB; | ||
1084 | break; | ||
1085 | case 6: | ||
1086 | return RET_VAL_OK; | ||
1087 | break; | ||
1088 | case MENU_ATTACHED_USB: | ||
1089 | return RET_VAL_USB; | 1072 | return RET_VAL_USB; |
1073 | if(!nummen) | ||
1090 | break; | 1074 | break; |
1091 | case GO_TO_PREVIOUS: | 1075 | /* fall through */ |
1092 | return RET_VAL_OK; | 1076 | case 1: |
1093 | break; | 1077 | case 2: |
1078 | case 3: | ||
1079 | case 4: | ||
1080 | case 5: | ||
1081 | if(buy_resources(COLOUR_LIGHT, selection, 0, 0, nummen) | ||
1082 | == RET_VAL_USB) | ||
1083 | return RET_VAL_USB; | ||
1084 | break; | ||
1085 | case 6: | ||
1086 | return RET_VAL_OK; | ||
1087 | break; | ||
1088 | case MENU_ATTACHED_USB: | ||
1089 | return RET_VAL_USB; | ||
1090 | break; | ||
1091 | case GO_TO_PREVIOUS: | ||
1092 | return RET_VAL_OK; | ||
1093 | break; | ||
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | return RET_VAL_OK; | 1096 | return RET_VAL_OK; |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | static int move_unit(int colour, int type, int fromx, int fromy, | 1099 | static int move_unit(int colour, int type, int fromx, int fromy, |
1100 | int tox, int toy, int nummen) { | 1100 | int tox, int toy, int nummen) { |
1101 | const char *itemnames[][3] = { | 1101 | const char *itemnames[][3] = { |
1102 | { | 1102 | { |
1103 | "troops", | 1103 | "troops", |
@@ -1118,7 +1118,7 @@ static int move_unit(int colour, int type, int fromx, int fromy, | |||
1118 | 1118 | ||
1119 | if(human) { | 1119 | if(human) { |
1120 | rb->splashf(HZ, "Select where you want to move %s from", | 1120 | rb->splashf(HZ, "Select where you want to move %s from", |
1121 | itemnames[0][type]); | 1121 | itemnames[0][type]); |
1122 | if((temp = select_square()) != RET_VAL_OK) | 1122 | if((temp = select_square()) != RET_VAL_OK) |
1123 | return temp; | 1123 | return temp; |
1124 | fromx = cursor.x; | 1124 | fromx = cursor.x; |
@@ -1138,7 +1138,7 @@ static int move_unit(int colour, int type, int fromx, int fromy, | |||
1138 | if(human) { | 1138 | if(human) { |
1139 | nummen = board[fromx][fromy].men; | 1139 | nummen = board[fromx][fromy].men; |
1140 | if((temp = get_number("How many men do you want to move?", &nummen, | 1140 | if((temp = get_number("How many men do you want to move?", &nummen, |
1141 | nummen)) != RET_VAL_OK) | 1141 | nummen)) != RET_VAL_OK) |
1142 | return temp; | 1142 | return temp; |
1143 | } | 1143 | } |
1144 | if(nummen > board[fromx][fromy].men) { | 1144 | if(nummen > board[fromx][fromy].men) { |
@@ -1149,7 +1149,7 @@ static int move_unit(int colour, int type, int fromx, int fromy, | |||
1149 | } | 1149 | } |
1150 | if(human) { | 1150 | if(human) { |
1151 | rb->splashf(HZ, "Select where you want to move %s to", | 1151 | rb->splashf(HZ, "Select where you want to move %s to", |
1152 | itemnames[2][type]); | 1152 | itemnames[2][type]); |
1153 | if((temp = select_square()) != RET_VAL_OK) | 1153 | if((temp = select_square()) != RET_VAL_OK) |
1154 | return temp; | 1154 | return temp; |
1155 | tox = cursor.x; | 1155 | tox = cursor.x; |
@@ -1168,18 +1168,18 @@ static int move_unit(int colour, int type, int fromx, int fromy, | |||
1168 | return RET_VAL_QUIT_ERR; | 1168 | return RET_VAL_QUIT_ERR; |
1169 | } | 1169 | } |
1170 | switch(type) { | 1170 | switch(type) { |
1171 | case 0: | 1171 | case 0: |
1172 | board[fromx][fromy].men -= nummen; | 1172 | board[fromx][fromy].men -= nummen; |
1173 | board[tox][toy].men += nummen; | 1173 | board[tox][toy].men += nummen; |
1174 | break; | 1174 | break; |
1175 | case 1: | 1175 | case 1: |
1176 | board[fromx][fromy].tank = false; | 1176 | board[fromx][fromy].tank = false; |
1177 | board[tox][toy].tank = true; | 1177 | board[tox][toy].tank = true; |
1178 | break; | 1178 | break; |
1179 | case 2: | 1179 | case 2: |
1180 | board[fromx][fromy].plane = false; | 1180 | board[fromx][fromy].plane = false; |
1181 | board[tox][toy].plane = true; | 1181 | board[tox][toy].plane = true; |
1182 | break; | 1182 | break; |
1183 | } | 1183 | } |
1184 | return RET_VAL_OK; | 1184 | return RET_VAL_OK; |
1185 | } | 1185 | } |
@@ -1188,22 +1188,22 @@ static int move_unit_menu(void) { | |||
1188 | int selection = 0; | 1188 | int selection = 0; |
1189 | 1189 | ||
1190 | MENUITEM_STRINGLIST(menu, "Move unit", NULL, | 1190 | MENUITEM_STRINGLIST(menu, "Move unit", NULL, |
1191 | "Move men", "Move tank", "Move plane"); | 1191 | "Move men", "Move tank", "Move plane"); |
1192 | switch(rb->do_menu(&menu, &selection, NULL, false)) { | 1192 | switch(rb->do_menu(&menu, &selection, NULL, false)) { |
1193 | case 0: | 1193 | case 0: |
1194 | case 1: | 1194 | case 1: |
1195 | case 2: | 1195 | case 2: |
1196 | switch(move_unit(COLOUR_LIGHT, selection, 0, 0, 0, 0, 0)) { | 1196 | switch(move_unit(COLOUR_LIGHT, selection, 0, 0, 0, 0, 0)) { |
1197 | case RET_VAL_OK: | 1197 | case RET_VAL_OK: |
1198 | humanres.moves--; | 1198 | humanres.moves--; |
1199 | break; | ||
1200 | case RET_VAL_USB: | ||
1201 | return RET_VAL_USB; | ||
1202 | break; | ||
1203 | } | ||
1204 | break; | 1199 | break; |
1205 | case MENU_ATTACHED_USB: | 1200 | case RET_VAL_USB: |
1206 | return RET_VAL_USB; | 1201 | return RET_VAL_USB; |
1202 | break; | ||
1203 | } | ||
1204 | break; | ||
1205 | case MENU_ATTACHED_USB: | ||
1206 | return RET_VAL_USB; | ||
1207 | } | 1207 | } |
1208 | return RET_VAL_OK; | 1208 | return RET_VAL_OK; |
1209 | } | 1209 | } |
@@ -1263,99 +1263,99 @@ static int movement_menu(void) { | |||
1263 | int selection = 0, temp; | 1263 | int selection = 0, temp; |
1264 | 1264 | ||
1265 | MENUITEM_STRINGLIST(menu, "Movement", NULL, | 1265 | MENUITEM_STRINGLIST(menu, "Movement", NULL, |
1266 | "Move unit", "Buy additional moves ($100)", | 1266 | "Move unit", "Buy additional moves ($100)", |
1267 | "Launch nuclear missile", "Check map", | 1267 | "Launch nuclear missile", "Check map", |
1268 | "Finish moving", "Game menu"); | 1268 | "Finish moving", "Game menu"); |
1269 | 1269 | ||
1270 | while(1) { | 1270 | while(1) { |
1271 | switch(rb->do_menu(&menu, &selection, NULL, false)) { | 1271 | switch(rb->do_menu(&menu, &selection, NULL, false)) { |
1272 | case 0: | ||
1273 | if(humanres.moves) { | ||
1274 | if(move_unit_menu()==RET_VAL_USB) | ||
1275 | return RET_VAL_USB; | ||
1276 | } else { | ||
1277 | rb->splash(HZ, "You have no more moves left." | ||
1278 | " You can buy more for $100 each."); | ||
1279 | } | ||
1280 | break; | ||
1281 | case 1: | ||
1282 | if(humanres.cash > 100) { | ||
1283 | humanres.moves++; | ||
1284 | humanres.cash -= 100; | ||
1285 | rb->snprintf(buf, sizeof(buf), "You now have %d moves", | ||
1286 | humanres.moves); | ||
1287 | rb->splash(HZ, buf); | ||
1288 | } | ||
1289 | break; | ||
1290 | case 2: | ||
1291 | if(humanres.nukes==0) { | ||
1292 | rb->splash(HZ, "You do not have any nukes to launch"); | ||
1293 | } else { | ||
1294 | rb->splash(HZ, "Select place to launch nuke from"); | ||
1295 | switch(select_square()) { | ||
1296 | case RET_VAL_OK: | ||
1297 | if(launch_nuke(COLOUR_LIGHT, cursor.x, cursor.y, | ||
1298 | 0, 0) == RET_VAL_USB) | ||
1299 | return RET_VAL_USB; | ||
1300 | break; | ||
1301 | case RET_VAL_USB: | ||
1302 | return RET_VAL_USB; | ||
1303 | break; | ||
1304 | } | ||
1305 | } | ||
1306 | break; | ||
1307 | case 3: | ||
1308 | if(select_square() == RET_VAL_USB) | ||
1309 | return RET_VAL_USB; | ||
1310 | break; | ||
1311 | case 4: | ||
1312 | return RET_VAL_OK; | ||
1313 | break; | ||
1314 | case 5: | ||
1315 | if((temp = ingame_menu()) != RET_VAL_OK) | ||
1316 | return temp; | ||
1317 | break; | ||
1318 | case MENU_ATTACHED_USB: | ||
1319 | return RET_VAL_USB; | ||
1320 | break; | ||
1321 | } | ||
1322 | } | ||
1323 | return RET_VAL_OK; | ||
1324 | } | ||
1325 | |||
1326 | static const char* inventory_data(int selected_item, void * data, | ||
1327 | char * buffer, size_t buffer_len) { | ||
1328 | (void)data; | ||
1329 | switch(selected_item) { | ||
1330 | case 0: | 1272 | case 0: |
1331 | rb->snprintf(buffer,buffer_len,"Men: %d", humanres.men); | 1273 | if(humanres.moves) { |
1274 | if(move_unit_menu()==RET_VAL_USB) | ||
1275 | return RET_VAL_USB; | ||
1276 | } else { | ||
1277 | rb->splash(HZ, "You have no more moves left." | ||
1278 | " You can buy more for $100 each."); | ||
1279 | } | ||
1332 | break; | 1280 | break; |
1333 | case 1: | 1281 | case 1: |
1334 | rb->snprintf(buffer,buffer_len,"Tanks: %d", humanres.tanks); | 1282 | if(humanres.cash > 100) { |
1283 | humanres.moves++; | ||
1284 | humanres.cash -= 100; | ||
1285 | rb->snprintf(buf, sizeof(buf), "You now have %d moves", | ||
1286 | humanres.moves); | ||
1287 | rb->splash(HZ, buf); | ||
1288 | } | ||
1335 | break; | 1289 | break; |
1336 | case 2: | 1290 | case 2: |
1337 | rb->snprintf(buffer,buffer_len,"Planes: %d", humanres.planes); | 1291 | if(humanres.nukes==0) { |
1292 | rb->splash(HZ, "You do not have any nukes to launch"); | ||
1293 | } else { | ||
1294 | rb->splash(HZ, "Select place to launch nuke from"); | ||
1295 | switch(select_square()) { | ||
1296 | case RET_VAL_OK: | ||
1297 | if(launch_nuke(COLOUR_LIGHT, cursor.x, cursor.y, | ||
1298 | 0, 0) == RET_VAL_USB) | ||
1299 | return RET_VAL_USB; | ||
1300 | break; | ||
1301 | case RET_VAL_USB: | ||
1302 | return RET_VAL_USB; | ||
1303 | break; | ||
1304 | } | ||
1305 | } | ||
1338 | break; | 1306 | break; |
1339 | case 3: | 1307 | case 3: |
1340 | rb->snprintf(buffer,buffer_len,"Factories: %d", humanres.inds); | 1308 | if(select_square() == RET_VAL_USB) |
1309 | return RET_VAL_USB; | ||
1341 | break; | 1310 | break; |
1342 | case 4: | 1311 | case 4: |
1343 | rb->snprintf(buffer,buffer_len,"Farms: %d", humanres.farms); | 1312 | return RET_VAL_OK; |
1344 | break; | 1313 | break; |
1345 | case 5: | 1314 | case 5: |
1346 | rb->snprintf(buffer,buffer_len,"Nukes: %d", humanres.nukes); | 1315 | if((temp = ingame_menu()) != RET_VAL_OK) |
1347 | break; | 1316 | return temp; |
1348 | case 6: | ||
1349 | rb->snprintf(buffer,buffer_len,"Cash: %d", humanres.cash); | ||
1350 | break; | ||
1351 | case 7: | ||
1352 | rb->snprintf(buffer,buffer_len,"Food: %d", humanres.food); | ||
1353 | break; | 1317 | break; |
1354 | case 8: | 1318 | case MENU_ATTACHED_USB: |
1355 | rb->snprintf(buffer,buffer_len,"Bank: %d", humanres.bank); | 1319 | return RET_VAL_USB; |
1356 | break; | 1320 | break; |
1357 | default: | 1321 | } |
1358 | return NULL; | 1322 | } |
1323 | return RET_VAL_OK; | ||
1324 | } | ||
1325 | |||
1326 | static const char* inventory_data(int selected_item, void * data, | ||
1327 | char * buffer, size_t buffer_len) { | ||
1328 | (void)data; | ||
1329 | switch(selected_item) { | ||
1330 | case 0: | ||
1331 | rb->snprintf(buffer,buffer_len,"Men: %d", humanres.men); | ||
1332 | break; | ||
1333 | case 1: | ||
1334 | rb->snprintf(buffer,buffer_len,"Tanks: %d", humanres.tanks); | ||
1335 | break; | ||
1336 | case 2: | ||
1337 | rb->snprintf(buffer,buffer_len,"Planes: %d", humanres.planes); | ||
1338 | break; | ||
1339 | case 3: | ||
1340 | rb->snprintf(buffer,buffer_len,"Factories: %d", humanres.inds); | ||
1341 | break; | ||
1342 | case 4: | ||
1343 | rb->snprintf(buffer,buffer_len,"Farms: %d", humanres.farms); | ||
1344 | break; | ||
1345 | case 5: | ||
1346 | rb->snprintf(buffer,buffer_len,"Nukes: %d", humanres.nukes); | ||
1347 | break; | ||
1348 | case 6: | ||
1349 | rb->snprintf(buffer,buffer_len,"Cash: %d", humanres.cash); | ||
1350 | break; | ||
1351 | case 7: | ||
1352 | rb->snprintf(buffer,buffer_len,"Food: %d", humanres.food); | ||
1353 | break; | ||
1354 | case 8: | ||
1355 | rb->snprintf(buffer,buffer_len,"Bank: %d", humanres.bank); | ||
1356 | break; | ||
1357 | default: | ||
1358 | return NULL; | ||
1359 | } | 1359 | } |
1360 | return buffer; | 1360 | return buffer; |
1361 | } | 1361 | } |
@@ -1376,58 +1376,58 @@ static int production_menu(void) { | |||
1376 | int selection = 0, temp; | 1376 | int selection = 0, temp; |
1377 | 1377 | ||
1378 | MENUITEM_STRINGLIST(menu, "Production", NULL, | 1378 | MENUITEM_STRINGLIST(menu, "Production", NULL, |
1379 | "Buy resources", "Show inventory", "Check map", | 1379 | "Buy resources", "Show inventory", "Check map", |
1380 | "Invest money", "Withdraw money", | 1380 | "Invest money", "Withdraw money", |
1381 | "Finish turn", "Game menu"); | 1381 | "Finish turn", "Game menu"); |
1382 | 1382 | ||
1383 | while(1) { | 1383 | while(1) { |
1384 | switch(rb->do_menu(&menu, &selection, NULL, false)) { | 1384 | switch(rb->do_menu(&menu, &selection, NULL, false)) { |
1385 | case 0: | 1385 | case 0: |
1386 | if(buy_resources_menu() == RET_VAL_USB) | 1386 | if(buy_resources_menu() == RET_VAL_USB) |
1387 | return RET_VAL_USB; | ||
1388 | break; | ||
1389 | case 1: | ||
1390 | if(show_inventory() == RET_VAL_USB) | ||
1391 | return RET_VAL_USB; | ||
1392 | break; | ||
1393 | case 2: | ||
1394 | if(select_square() == RET_VAL_USB) | ||
1395 | return RET_VAL_USB; | ||
1396 | break; | ||
1397 | case 3: | ||
1398 | temp = humanres.cash; | ||
1399 | if(get_number("How much do you want to invest?", &temp, | ||
1400 | humanres.cash) == RET_VAL_USB) | ||
1401 | return RET_VAL_USB; | ||
1402 | if(temp > humanres.cash) { | ||
1403 | rb->splash(HZ, "You don't have that much cash to invest"); | ||
1404 | } else { | ||
1405 | humanres.cash -= temp; | ||
1406 | humanres.bank += temp; | ||
1407 | } | ||
1408 | break; | ||
1409 | case 4: | ||
1410 | temp = humanres.bank; | ||
1411 | if(get_number("How much do you want to withdraw?", &temp, | ||
1412 | humanres.bank) == RET_VAL_USB) | ||
1413 | return RET_VAL_USB; | ||
1414 | if(temp > humanres.bank) { | ||
1415 | rb->splash(HZ, "You don't have that much cash to withdraw"); | ||
1416 | } else { | ||
1417 | humanres.cash += temp; | ||
1418 | humanres.bank -= temp; | ||
1419 | } | ||
1420 | break; | ||
1421 | case 5: | ||
1422 | return RET_VAL_OK; | ||
1423 | break; | ||
1424 | case 6: | ||
1425 | if((temp = ingame_menu()) != RET_VAL_OK) | ||
1426 | return temp; | ||
1427 | break; | ||
1428 | case MENU_ATTACHED_USB: | ||
1429 | return RET_VAL_USB; | 1387 | return RET_VAL_USB; |
1430 | break; | 1388 | break; |
1389 | case 1: | ||
1390 | if(show_inventory() == RET_VAL_USB) | ||
1391 | return RET_VAL_USB; | ||
1392 | break; | ||
1393 | case 2: | ||
1394 | if(select_square() == RET_VAL_USB) | ||
1395 | return RET_VAL_USB; | ||
1396 | break; | ||
1397 | case 3: | ||
1398 | temp = humanres.cash; | ||
1399 | if(get_number("How much do you want to invest?", &temp, | ||
1400 | humanres.cash) == RET_VAL_USB) | ||
1401 | return RET_VAL_USB; | ||
1402 | if(temp > humanres.cash) { | ||
1403 | rb->splash(HZ, "You don't have that much cash to invest"); | ||
1404 | } else { | ||
1405 | humanres.cash -= temp; | ||
1406 | humanres.bank += temp; | ||
1407 | } | ||
1408 | break; | ||
1409 | case 4: | ||
1410 | temp = humanres.bank; | ||
1411 | if(get_number("How much do you want to withdraw?", &temp, | ||
1412 | humanres.bank) == RET_VAL_USB) | ||
1413 | return RET_VAL_USB; | ||
1414 | if(temp > humanres.bank) { | ||
1415 | rb->splash(HZ, "You don't have that much cash to withdraw"); | ||
1416 | } else { | ||
1417 | humanres.cash += temp; | ||
1418 | humanres.bank -= temp; | ||
1419 | } | ||
1420 | break; | ||
1421 | case 5: | ||
1422 | return RET_VAL_OK; | ||
1423 | break; | ||
1424 | case 6: | ||
1425 | if((temp = ingame_menu()) != RET_VAL_OK) | ||
1426 | return temp; | ||
1427 | break; | ||
1428 | case MENU_ATTACHED_USB: | ||
1429 | return RET_VAL_USB; | ||
1430 | break; | ||
1431 | } | 1431 | } |
1432 | } | 1432 | } |
1433 | return RET_VAL_OK; | 1433 | return RET_VAL_OK; |
@@ -1471,90 +1471,90 @@ static int select_square(void) { | |||
1471 | while(1) { | 1471 | while(1) { |
1472 | button = rb->button_get(true); | 1472 | button = rb->button_get(true); |
1473 | switch(button) { | 1473 | switch(button) { |
1474 | case SUPERDOM_CANCEL: | 1474 | case SUPERDOM_CANCEL: |
1475 | rb->splash(HZ, "Cancelled"); | 1475 | rb->splash(HZ, "Cancelled"); |
1476 | return RET_VAL_QUIT_ERR; | 1476 | return RET_VAL_QUIT_ERR; |
1477 | break; | 1477 | break; |
1478 | case SUPERDOM_OK: | 1478 | case SUPERDOM_OK: |
1479 | return RET_VAL_OK; | 1479 | return RET_VAL_OK; |
1480 | break; | 1480 | break; |
1481 | #if CONFIG_KEYPAD != IRIVER_H10_PAD | 1481 | #if CONFIG_KEYPAD != IRIVER_H10_PAD |
1482 | case SUPERDOM_LEFT: | 1482 | case SUPERDOM_LEFT: |
1483 | case (SUPERDOM_LEFT|BUTTON_REPEAT): | 1483 | case (SUPERDOM_LEFT|BUTTON_REPEAT): |
1484 | draw_cursor(); /* Deselect the current tile */ | 1484 | draw_cursor(); /* Deselect the current tile */ |
1485 | if(cursor.x>1) { | 1485 | if(cursor.x>1) { |
1486 | cursor.x--; | 1486 | cursor.x--; |
1487 | } else { | 1487 | } else { |
1488 | #ifdef IPOD_STYLE | 1488 | #ifdef IPOD_STYLE |
1489 | if(cursor.y>1) | 1489 | if(cursor.y>1) |
1490 | cursor.y--; | 1490 | cursor.y--; |
1491 | else | 1491 | else |
1492 | cursor.y = 10; | 1492 | cursor.y = 10; |
1493 | #endif | 1493 | #endif |
1494 | cursor.x = 10; | 1494 | cursor.x = 10; |
1495 | } | 1495 | } |
1496 | update_score(); | 1496 | update_score(); |
1497 | draw_cursor(); | 1497 | draw_cursor(); |
1498 | break; | 1498 | break; |
1499 | case SUPERDOM_RIGHT: | 1499 | case SUPERDOM_RIGHT: |
1500 | case (SUPERDOM_RIGHT|BUTTON_REPEAT): | 1500 | case (SUPERDOM_RIGHT|BUTTON_REPEAT): |
1501 | draw_cursor(); /* Deselect the current tile */ | 1501 | draw_cursor(); /* Deselect the current tile */ |
1502 | if(cursor.x<10) { | 1502 | if(cursor.x<10) { |
1503 | cursor.x++; | 1503 | cursor.x++; |
1504 | } else { | 1504 | } else { |
1505 | #ifdef IPOD_STYLE | 1505 | #ifdef IPOD_STYLE |
1506 | if(cursor.y<10) | 1506 | if(cursor.y<10) |
1507 | cursor.y++; | 1507 | cursor.y++; |
1508 | else | 1508 | else |
1509 | cursor.y = 1; | 1509 | cursor.y = 1; |
1510 | #endif | 1510 | #endif |
1511 | cursor.x = 1; | 1511 | cursor.x = 1; |
1512 | } | 1512 | } |
1513 | update_score(); | 1513 | update_score(); |
1514 | draw_cursor(); | 1514 | draw_cursor(); |
1515 | break; | 1515 | break; |
1516 | #endif | 1516 | #endif |
1517 | #ifndef IPOD_STYLE | 1517 | #ifndef IPOD_STYLE |
1518 | case SUPERDOM_UP: | 1518 | case SUPERDOM_UP: |
1519 | case (SUPERDOM_UP|BUTTON_REPEAT): | 1519 | case (SUPERDOM_UP|BUTTON_REPEAT): |
1520 | draw_cursor(); /* Deselect the current tile */ | 1520 | draw_cursor(); /* Deselect the current tile */ |
1521 | if(cursor.y>1) { | 1521 | if(cursor.y>1) { |
1522 | cursor.y--; | 1522 | cursor.y--; |
1523 | } else { | 1523 | } else { |
1524 | #if CONFIG_KEYPAD == IRIVER_H10_PAD | 1524 | #if CONFIG_KEYPAD == IRIVER_H10_PAD |
1525 | if(cursor.x > 1) | 1525 | if(cursor.x > 1) |
1526 | cursor.x--; | 1526 | cursor.x--; |
1527 | else | 1527 | else |
1528 | cursor.x = 10; | 1528 | cursor.x = 10; |
1529 | #endif | 1529 | #endif |
1530 | cursor.y = 10; | 1530 | cursor.y = 10; |
1531 | } | 1531 | } |
1532 | update_score(); | 1532 | update_score(); |
1533 | draw_cursor(); | 1533 | draw_cursor(); |
1534 | break; | 1534 | break; |
1535 | case SUPERDOM_DOWN: | 1535 | case SUPERDOM_DOWN: |
1536 | case (SUPERDOM_DOWN|BUTTON_REPEAT): | 1536 | case (SUPERDOM_DOWN|BUTTON_REPEAT): |
1537 | draw_cursor(); /* Deselect the current tile */ | 1537 | draw_cursor(); /* Deselect the current tile */ |
1538 | if(cursor.y<10) { | 1538 | if(cursor.y<10) { |
1539 | cursor.y++; | 1539 | cursor.y++; |
1540 | } else { | 1540 | } else { |
1541 | #if CONFIG_KEYPAD == IRIVER_H10_PAD | 1541 | #if CONFIG_KEYPAD == IRIVER_H10_PAD |
1542 | if(cursor.x < 10) | 1542 | if(cursor.x < 10) |
1543 | cursor.x++; | 1543 | cursor.x++; |
1544 | else | 1544 | else |
1545 | cursor.x = 1; | 1545 | cursor.x = 1; |
1546 | #endif | 1546 | #endif |
1547 | cursor.y = 1; | 1547 | cursor.y = 1; |
1548 | } | 1548 | } |
1549 | update_score(); | 1549 | update_score(); |
1550 | draw_cursor(); | 1550 | draw_cursor(); |
1551 | break; | 1551 | break; |
1552 | #endif | 1552 | #endif |
1553 | default: | 1553 | default: |
1554 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) | 1554 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) |
1555 | { | 1555 | { |
1556 | return RET_VAL_USB; | 1556 | return RET_VAL_USB; |
1557 | } | 1557 | } |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | } | 1560 | } |
@@ -1599,7 +1599,7 @@ static int attack_territory(int colour, int x, int y) { | |||
1599 | return -1; | 1599 | return -1; |
1600 | } | 1600 | } |
1601 | str_diff = calc_strength(COLOUR_DARK, x, y) - | 1601 | str_diff = calc_strength(COLOUR_DARK, x, y) - |
1602 | calc_strength(COLOUR_LIGHT, x, y); | 1602 | calc_strength(COLOUR_LIGHT, x, y); |
1603 | if(human) { | 1603 | if(human) { |
1604 | str_diff = -str_diff; | 1604 | str_diff = -str_diff; |
1605 | } | 1605 | } |
@@ -1635,11 +1635,11 @@ static int attack_territory(int colour, int x, int y) { | |||
1635 | } else { | 1635 | } else { |
1636 | if(human) | 1636 | if(human) |
1637 | rb->splash(HZ, "Your troops were unable to overcome" | 1637 | rb->splash(HZ, "Your troops were unable to overcome" |
1638 | " the enemy troops"); | 1638 | " the enemy troops"); |
1639 | else | 1639 | else |
1640 | rb->splash(HZ*2, "The computer attempted to " | 1640 | rb->splash(HZ*2, "The computer attempted to " |
1641 | "attack, but the invasion was" | 1641 | "attack, but the invasion was" |
1642 | " pushed back"); | 1642 | " pushed back"); |
1643 | return 0; | 1643 | return 0; |
1644 | } | 1644 | } |
1645 | return 0; | 1645 | return 0; |
@@ -1649,30 +1649,30 @@ static int war_menu(void) { | |||
1649 | int selection = 0, temp; | 1649 | int selection = 0, temp; |
1650 | 1650 | ||
1651 | MENUITEM_STRINGLIST(menu, "War!", NULL, | 1651 | MENUITEM_STRINGLIST(menu, "War!", NULL, |
1652 | "Select territory to attack", | 1652 | "Select territory to attack", |
1653 | "Finish turn", "Game menu"); | 1653 | "Finish turn", "Game menu"); |
1654 | 1654 | ||
1655 | while(humanres.moves) { | 1655 | while(humanres.moves) { |
1656 | switch(rb->do_menu(&menu, &selection, NULL, false)) { | 1656 | switch(rb->do_menu(&menu, &selection, NULL, false)) { |
1657 | case 0: | 1657 | case 0: |
1658 | switch(select_square()) { | 1658 | switch(select_square()) { |
1659 | case RET_VAL_OK: | 1659 | case RET_VAL_OK: |
1660 | if(attack_territory(COLOUR_LIGHT, cursor.x, cursor.y) | 1660 | if(attack_territory(COLOUR_LIGHT, cursor.x, cursor.y) |
1661 | >= 0) | 1661 | >= 0) |
1662 | humanres.moves--; | 1662 | humanres.moves--; |
1663 | break; | ||
1664 | case RET_VAL_USB: | ||
1665 | return RET_VAL_USB; | ||
1666 | break; | ||
1667 | } | ||
1668 | break; | ||
1669 | case 1: | ||
1670 | return RET_VAL_OK; | ||
1671 | break; | 1663 | break; |
1672 | case 2: | 1664 | case RET_VAL_USB: |
1673 | if((temp = ingame_menu()) != RET_VAL_OK) | 1665 | return RET_VAL_USB; |
1674 | return temp; | ||
1675 | break; | 1666 | break; |
1667 | } | ||
1668 | break; | ||
1669 | case 1: | ||
1670 | return RET_VAL_OK; | ||
1671 | break; | ||
1672 | case 2: | ||
1673 | if((temp = ingame_menu()) != RET_VAL_OK) | ||
1674 | return temp; | ||
1675 | break; | ||
1676 | } | 1676 | } |
1677 | } | 1677 | } |
1678 | return RET_VAL_OK; | 1678 | return RET_VAL_OK; |
@@ -1705,11 +1705,11 @@ static bool place_adjacent(bool tank, int x, int y) { | |||
1705 | } | 1705 | } |
1706 | 1706 | ||
1707 | static bool has_adjacent(int x, int y) { | 1707 | static bool has_adjacent(int x, int y) { |
1708 | if((board[x][y].colour == COLOUR_LIGHT) && | 1708 | if((board[x][y].colour == COLOUR_LIGHT) && |
1709 | ((board[x-1][y].colour == COLOUR_DARK) || | 1709 | ((board[x-1][y].colour == COLOUR_DARK) || |
1710 | (board[x+1][y].colour == COLOUR_DARK) || | 1710 | (board[x+1][y].colour == COLOUR_DARK) || |
1711 | (board[x][y+1].colour == COLOUR_DARK) || | 1711 | (board[x][y+1].colour == COLOUR_DARK) || |
1712 | (board[x][y-1].colour == COLOUR_DARK))) | 1712 | (board[x][y-1].colour == COLOUR_DARK))) |
1713 | return 1; | 1713 | return 1; |
1714 | else | 1714 | else |
1715 | return 0; | 1715 | return 0; |
@@ -1763,7 +1763,7 @@ static void computer_allocate(void) { | |||
1763 | if(board[i][j].colour == COLOUR_DARK) { | 1763 | if(board[i][j].colour == COLOUR_DARK) { |
1764 | numterritory++; | 1764 | numterritory++; |
1765 | str_diff = calc_strength(COLOUR_LIGHT,i,j) - | 1765 | str_diff = calc_strength(COLOUR_LIGHT,i,j) - |
1766 | calc_strength(COLOUR_DARK,i,j); | 1766 | calc_strength(COLOUR_DARK,i,j); |
1767 | if(str_diff > 0 && (board[i][j].ind || board[i][j].farm)) { | 1767 | if(str_diff > 0 && (board[i][j].ind || board[i][j].farm)) { |
1768 | if(numthreats < 3) { | 1768 | if(numthreats < 3) { |
1769 | offensive = false; | 1769 | offensive = false; |
@@ -1799,8 +1799,8 @@ static void computer_allocate(void) { | |||
1799 | targets[k].x = i; | 1799 | targets[k].x = i; |
1800 | targets[k].y = j; | 1800 | targets[k].y = j; |
1801 | targets[k].str_diff = | 1801 | targets[k].str_diff = |
1802 | calc_strength(COLOUR_LIGHT, i, j) - | 1802 | calc_strength(COLOUR_LIGHT, i, j) - |
1803 | calc_strength(COLOUR_DARK, i, j); | 1803 | calc_strength(COLOUR_DARK, i, j); |
1804 | k++; | 1804 | k++; |
1805 | } | 1805 | } |
1806 | } | 1806 | } |
@@ -1808,17 +1808,17 @@ static void computer_allocate(void) { | |||
1808 | } | 1808 | } |
1809 | } | 1809 | } |
1810 | if(k == 0) { | 1810 | if(k == 0) { |
1811 | /* No targets found! Randomly pick squares and if they're owned | 1811 | /* No targets found! Randomly pick squares and if they're owned |
1812 | * by the computer then stick a tank on it. */ | 1812 | * by the computer then stick a tank on it. */ |
1813 | rb->srand(*rb->current_tick); | 1813 | rb->srand(*rb->current_tick); |
1814 | while(compres.cash >= 300 && compres.tanks < numterritory) { | 1814 | while(compres.cash >= 300 && compres.tanks < numterritory) { |
1815 | i = rb->rand()%10 + 1; | 1815 | i = rb->rand()%10 + 1; |
1816 | j = rb->rand()%10 + 1; | 1816 | j = rb->rand()%10 + 1; |
1817 | if(board[i][j].colour == COLOUR_DARK) { | 1817 | if(board[i][j].colour == COLOUR_DARK) { |
1818 | buy_resources(COLOUR_DARK, 1, i, j, 0); | 1818 | buy_resources(COLOUR_DARK, 1, i, j, 0); |
1819 | } | ||
1820 | rb->yield(); | ||
1821 | } | 1819 | } |
1820 | rb->yield(); | ||
1821 | } | ||
1822 | } else { | 1822 | } else { |
1823 | for(i=0;i<k;i++) { | 1823 | for(i=0;i<k;i++) { |
1824 | str_diff = targets[i].str_diff; | 1824 | str_diff = targets[i].str_diff; |
@@ -1826,18 +1826,18 @@ static void computer_allocate(void) { | |||
1826 | /* While we still need them keep placing men */ | 1826 | /* While we still need them keep placing men */ |
1827 | if(!place_adjacent(true, targets[i].x, targets[i].y)) { | 1827 | if(!place_adjacent(true, targets[i].x, targets[i].y)) { |
1828 | find_adjacent(targets[i].x, targets[i].y, | 1828 | find_adjacent(targets[i].x, targets[i].y, |
1829 | &adj.x, &adj.y); | 1829 | &adj.x, &adj.y); |
1830 | men_needed = (str_diff + 20)*1000/133; | 1830 | men_needed = (str_diff + 20)*1000/133; |
1831 | if(compres.cash < men_needed) { | 1831 | if(compres.cash < men_needed) { |
1832 | men_needed = compres.cash; | 1832 | men_needed = compres.cash; |
1833 | } | 1833 | } |
1834 | buy_resources(COLOUR_DARK, 0, adj.x, adj.y, | 1834 | buy_resources(COLOUR_DARK, 0, adj.x, adj.y, |
1835 | men_needed); | 1835 | men_needed); |
1836 | break; | 1836 | break; |
1837 | } | 1837 | } |
1838 | str_diff = calc_strength(COLOUR_LIGHT, | 1838 | str_diff = calc_strength(COLOUR_LIGHT, |
1839 | targets[i].x, targets[i].y) - | 1839 | targets[i].x, targets[i].y) - |
1840 | calc_strength(COLOUR_DARK, | 1840 | calc_strength(COLOUR_DARK, |
1841 | targets[i].x, targets[i].y); | 1841 | targets[i].x, targets[i].y); |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
@@ -1862,7 +1862,7 @@ static void computer_allocate(void) { | |||
1862 | men_needed = compres.cash; | 1862 | men_needed = compres.cash; |
1863 | } | 1863 | } |
1864 | buy_resources(COLOUR_DARK, 0, threats[i].x, threats[i].y, | 1864 | buy_resources(COLOUR_DARK, 0, threats[i].x, threats[i].y, |
1865 | men_needed); | 1865 | men_needed); |
1866 | } | 1866 | } |
1867 | } else { | 1867 | } else { |
1868 | /* Tanks it is */ | 1868 | /* Tanks it is */ |
@@ -1875,18 +1875,18 @@ static void computer_allocate(void) { | |||
1875 | /* No room for any more planes or tanks, revert to | 1875 | /* No room for any more planes or tanks, revert to |
1876 | * men */ | 1876 | * men */ |
1877 | find_adjacent(threats[i].x, threats[i].y, | 1877 | find_adjacent(threats[i].x, threats[i].y, |
1878 | &adj.x, &adj.y); | 1878 | &adj.x, &adj.y); |
1879 | men_needed = (str_diff + 20)*1000/133; | 1879 | men_needed = (str_diff + 20)*1000/133; |
1880 | if(compres.cash < men_needed) { | 1880 | if(compres.cash < men_needed) { |
1881 | men_needed = compres.cash; | 1881 | men_needed = compres.cash; |
1882 | } | 1882 | } |
1883 | buy_resources(COLOUR_DARK, 0, threats[i].x, | 1883 | buy_resources(COLOUR_DARK, 0, threats[i].x, |
1884 | threats[i].y, men_needed); | 1884 | threats[i].y, men_needed); |
1885 | break; | 1885 | break; |
1886 | } | 1886 | } |
1887 | str_diff = calc_strength(COLOUR_LIGHT, | 1887 | str_diff = calc_strength(COLOUR_LIGHT, |
1888 | threats[i].x, threats[i].y) - | 1888 | threats[i].x, threats[i].y) - |
1889 | calc_strength(COLOUR_DARK, | 1889 | calc_strength(COLOUR_DARK, |
1890 | threats[i].x, threats[i].y); | 1890 | threats[i].x, threats[i].y); |
1891 | } | 1891 | } |
1892 | } | 1892 | } |
@@ -1899,26 +1899,26 @@ static void computer_allocate(void) { | |||
1899 | static int find_adj_target(int x, int y, struct cursor* adj) { | 1899 | static int find_adj_target(int x, int y, struct cursor* adj) { |
1900 | /* Find a square next to a computer's farm or factory owned by the player | 1900 | /* Find a square next to a computer's farm or factory owned by the player |
1901 | * that is vulnerable. Return 1 on success, 0 otherwise */ | 1901 | * that is vulnerable. Return 1 on success, 0 otherwise */ |
1902 | if(board[x+1][y].colour == COLOUR_LIGHT && | 1902 | if(board[x+1][y].colour == COLOUR_LIGHT && |
1903 | calc_strength(COLOUR_LIGHT,x+1,y)<=calc_strength(COLOUR_DARK,x+1,y)) { | 1903 | calc_strength(COLOUR_LIGHT,x+1,y)<=calc_strength(COLOUR_DARK,x+1,y)) { |
1904 | adj->x = x+1; | 1904 | adj->x = x+1; |
1905 | adj->y = y; | 1905 | adj->y = y; |
1906 | return 1; | 1906 | return 1; |
1907 | } | 1907 | } |
1908 | if(board[x-1][y].colour == COLOUR_LIGHT && | 1908 | if(board[x-1][y].colour == COLOUR_LIGHT && |
1909 | calc_strength(COLOUR_LIGHT,x-1,y)<=calc_strength(COLOUR_DARK,x-1,y)) { | 1909 | calc_strength(COLOUR_LIGHT,x-1,y)<=calc_strength(COLOUR_DARK,x-1,y)) { |
1910 | adj->x = x-1; | 1910 | adj->x = x-1; |
1911 | adj->y = y; | 1911 | adj->y = y; |
1912 | return 1; | 1912 | return 1; |
1913 | } | 1913 | } |
1914 | if(board[x][y+1].colour == COLOUR_LIGHT && | 1914 | if(board[x][y+1].colour == COLOUR_LIGHT && |
1915 | calc_strength(COLOUR_LIGHT,x,y+1)<=calc_strength(COLOUR_DARK,x,y+1)) { | 1915 | calc_strength(COLOUR_LIGHT,x,y+1)<=calc_strength(COLOUR_DARK,x,y+1)) { |
1916 | adj->x = x; | 1916 | adj->x = x; |
1917 | adj->y = y+1; | 1917 | adj->y = y+1; |
1918 | return 1; | 1918 | return 1; |
1919 | } | 1919 | } |
1920 | if(board[x][y-1].colour == COLOUR_LIGHT && | 1920 | if(board[x][y-1].colour == COLOUR_LIGHT && |
1921 | calc_strength(COLOUR_LIGHT,x,y-1)<=calc_strength(COLOUR_DARK,x,y-1)) { | 1921 | calc_strength(COLOUR_LIGHT,x,y-1)<=calc_strength(COLOUR_DARK,x,y-1)) { |
1922 | adj->x = x; | 1922 | adj->x = x; |
1923 | adj->y = y-1; | 1923 | adj->y = y-1; |
1924 | return 1; | 1924 | return 1; |
@@ -1957,9 +1957,9 @@ static void computer_war(void) { | |||
1957 | for(i=1;i<11;i++) { | 1957 | for(i=1;i<11;i++) { |
1958 | for(j=1;j<11;j++) { | 1958 | for(j=1;j<11;j++) { |
1959 | if(board[i][j].colour == COLOUR_LIGHT && | 1959 | if(board[i][j].colour == COLOUR_LIGHT && |
1960 | (board[i][j].ind || board[i][j].farm) && | 1960 | (board[i][j].ind || board[i][j].farm) && |
1961 | (calc_strength(COLOUR_DARK, i, j) >= | 1961 | (calc_strength(COLOUR_DARK, i, j) >= |
1962 | calc_strength(COLOUR_LIGHT, i, j))) { | 1962 | calc_strength(COLOUR_LIGHT, i, j))) { |
1963 | found_target = true; | 1963 | found_target = true; |
1964 | if(attack_territory(COLOUR_DARK, i, j) >= 0) { | 1964 | if(attack_territory(COLOUR_DARK, i, j) >= 0) { |
1965 | compres.moves--; | 1965 | compres.moves--; |
@@ -1977,9 +1977,9 @@ static void computer_war(void) { | |||
1977 | found_target = false; | 1977 | found_target = false; |
1978 | for(i=1;i<11;i++) { | 1978 | for(i=1;i<11;i++) { |
1979 | for(j=1;j<11;j++) { | 1979 | for(j=1;j<11;j++) { |
1980 | if(board[i][j].colour == COLOUR_LIGHT && | 1980 | if(board[i][j].colour == COLOUR_LIGHT && |
1981 | (calc_strength(COLOUR_DARK, i, j) >= | 1981 | (calc_strength(COLOUR_DARK, i, j) >= |
1982 | calc_strength(COLOUR_LIGHT, i, j))) { | 1982 | calc_strength(COLOUR_LIGHT, i, j))) { |
1983 | found_target = true; | 1983 | found_target = true; |
1984 | if(attack_territory(COLOUR_DARK, i, j) >= 0) { | 1984 | if(attack_territory(COLOUR_DARK, i, j) >= 0) { |
1985 | compres.moves--; | 1985 | compres.moves--; |
@@ -2080,31 +2080,31 @@ enum plugin_status plugin_start(const void* parameter) | |||
2080 | DEBUGF("Loading failed, generating new game\n"); | 2080 | DEBUGF("Loading failed, generating new game\n"); |
2081 | } else { | 2081 | } else { |
2082 | switch(gamestate) { | 2082 | switch(gamestate) { |
2083 | case GS_PROD: | 2083 | case GS_PROD: |
2084 | goto startprod; | 2084 | goto startprod; |
2085 | break; | 2085 | break; |
2086 | case GS_MOVE: | 2086 | case GS_MOVE: |
2087 | goto startmove; | 2087 | goto startmove; |
2088 | break; | 2088 | break; |
2089 | case GS_WAR: | 2089 | case GS_WAR: |
2090 | goto startwar; | 2090 | goto startwar; |
2091 | break; | 2091 | break; |
2092 | default: | 2092 | default: |
2093 | goto startyear; | 2093 | goto startyear; |
2094 | break; | 2094 | break; |
2095 | } | 2095 | } |
2096 | } | 2096 | } |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | switch(start_menu()) { | 2099 | switch(start_menu()) { |
2100 | case RET_VAL_OK: /* start playing */ | 2100 | case RET_VAL_OK: /* start playing */ |
2101 | break; | 2101 | break; |
2102 | case RET_VAL_QUIT_ERR: /* quit */ | 2102 | case RET_VAL_QUIT_ERR: /* quit */ |
2103 | return PLUGIN_OK; | 2103 | return PLUGIN_OK; |
2104 | break; | 2104 | break; |
2105 | case RET_VAL_USB: | 2105 | case RET_VAL_USB: |
2106 | return PLUGIN_USB_CONNECTED; | 2106 | return PLUGIN_USB_CONNECTED; |
2107 | break; | 2107 | break; |
2108 | } | 2108 | } |
2109 | 2109 | ||
2110 | init_resources(); | 2110 | init_resources(); |
@@ -2120,45 +2120,45 @@ startyear: | |||
2120 | } | 2120 | } |
2121 | if(-avg_str_diff > 15) { | 2121 | if(-avg_str_diff > 15) { |
2122 | rb->splash(HZ*4, "Your army have suffered terrible morale from" | 2122 | rb->splash(HZ*4, "Your army have suffered terrible morale from" |
2123 | " the bleak prospects of winning. You lose."); | 2123 | " the bleak prospects of winning. You lose."); |
2124 | return PLUGIN_OK; | 2124 | return PLUGIN_OK; |
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | /* production */ | 2127 | /* production */ |
2128 | startprod: | 2128 | startprod: |
2129 | gamestate = GS_PROD; | 2129 | gamestate = GS_PROD; |
2130 | switch(production_menu()) { | 2130 | switch(production_menu()) { |
2131 | case RET_VAL_USB: | 2131 | case RET_VAL_USB: |
2132 | return PLUGIN_USB_CONNECTED; | 2132 | return PLUGIN_USB_CONNECTED; |
2133 | break; | 2133 | break; |
2134 | case RET_VAL_QUIT_ERR: | 2134 | case RET_VAL_QUIT_ERR: |
2135 | return PLUGIN_OK; | 2135 | return PLUGIN_OK; |
2136 | break; | 2136 | break; |
2137 | } | 2137 | } |
2138 | computer_allocate(); | 2138 | computer_allocate(); |
2139 | 2139 | ||
2140 | /* movement */ | 2140 | /* movement */ |
2141 | humanres.moves = superdom_settings.movesperturn; | 2141 | humanres.moves = superdom_settings.movesperturn; |
2142 | startmove: | 2142 | startmove: |
2143 | gamestate = GS_MOVE; | 2143 | gamestate = GS_MOVE; |
2144 | switch(movement_menu()) { | 2144 | switch(movement_menu()) { |
2145 | case RET_VAL_USB: | 2145 | case RET_VAL_USB: |
2146 | return PLUGIN_USB_CONNECTED; | 2146 | return PLUGIN_USB_CONNECTED; |
2147 | break; | 2147 | break; |
2148 | case RET_VAL_QUIT_ERR: | 2148 | case RET_VAL_QUIT_ERR: |
2149 | return PLUGIN_OK; | 2149 | return PLUGIN_OK; |
2150 | break; | 2150 | break; |
2151 | } | 2151 | } |
2152 | /* feed men */ | 2152 | /* feed men */ |
2153 | if(humanres.men) { | 2153 | if(humanres.men) { |
2154 | if(humanres.food > humanres.men) { | 2154 | if(humanres.food > humanres.men) { |
2155 | rb->snprintf(buf, sizeof(buf), "Your men ate %d units of food", | 2155 | rb->snprintf(buf, sizeof(buf), "Your men ate %d units of food", |
2156 | humanres.men); | 2156 | humanres.men); |
2157 | humanres.food -= humanres.men; | 2157 | humanres.food -= humanres.men; |
2158 | } else { | 2158 | } else { |
2159 | rb->snprintf(buf, sizeof(buf), "There was not enough food" | 2159 | rb->snprintf(buf, sizeof(buf), "There was not enough food" |
2160 | " to feed all your men, %d men have died of starvation", | 2160 | " to feed all your men, %d men have died of starvation", |
2161 | killmen(COLOUR_LIGHT)); | 2161 | killmen(COLOUR_LIGHT)); |
2162 | } | 2162 | } |
2163 | rb->splash(HZ*2, buf); | 2163 | rb->splash(HZ*2, buf); |
2164 | } | 2164 | } |
@@ -2167,22 +2167,22 @@ startmove: | |||
2167 | compres.food -= compres.men; | 2167 | compres.food -= compres.men; |
2168 | } else { | 2168 | } else { |
2169 | rb->snprintf(buf, sizeof(buf), "The computer does not have" | 2169 | rb->snprintf(buf, sizeof(buf), "The computer does not have" |
2170 | " enough food to feed its men. %d have died of starvation", | 2170 | " enough food to feed its men. %d have died of starvation", |
2171 | killmen(COLOUR_DARK)); | 2171 | killmen(COLOUR_DARK)); |
2172 | rb->splash(HZ, buf); | 2172 | rb->splash(HZ, buf); |
2173 | } | 2173 | } |
2174 | } | 2174 | } |
2175 | /* war */ | 2175 | /* war */ |
2176 | humanres.moves = superdom_settings.movesperturn; | 2176 | humanres.moves = superdom_settings.movesperturn; |
2177 | startwar: | 2177 | startwar: |
2178 | gamestate = GS_WAR; | 2178 | gamestate = GS_WAR; |
2179 | switch(war_menu()) { | 2179 | switch(war_menu()) { |
2180 | case RET_VAL_USB: | 2180 | case RET_VAL_USB: |
2181 | return PLUGIN_USB_CONNECTED; | 2181 | return PLUGIN_USB_CONNECTED; |
2182 | break; | 2182 | break; |
2183 | case RET_VAL_QUIT_ERR: | 2183 | case RET_VAL_QUIT_ERR: |
2184 | return PLUGIN_OK; | 2184 | return PLUGIN_OK; |
2185 | break; | 2185 | break; |
2186 | } | 2186 | } |
2187 | compres.moves = superdom_settings.movesperturn; | 2187 | compres.moves = superdom_settings.movesperturn; |
2188 | computer_war(); | 2188 | computer_war(); |