diff options
Diffstat (limited to 'apps/plugins/superdom.c')
-rw-r--r-- | apps/plugins/superdom.c | 1630 |
1 files changed, 740 insertions, 890 deletions
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index a3e671cd8b..80dd4f518b 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c | |||
@@ -30,6 +30,12 @@ char buf[255]; | |||
30 | 30 | ||
31 | #define MARGIN 5 | 31 | #define MARGIN 5 |
32 | 32 | ||
33 | #if (LCD_DEPTH == 16) | ||
34 | #define MY_BITMAP_PART rb->lcd_bitmap_transparent_part | ||
35 | #else | ||
36 | #define MY_BITMAP_PART rb->lcd_mono_bitmap_part | ||
37 | #endif | ||
38 | |||
33 | #if LCD_WIDTH > LCD_HEIGHT | 39 | #if LCD_WIDTH > LCD_HEIGHT |
34 | #define BOX_WIDTH ((LCD_WIDTH-(MARGIN*2))/10) | 40 | #define BOX_WIDTH ((LCD_WIDTH-(MARGIN*2))/10) |
35 | #define BOX_HEIGHT ((BOX_WIDTH*2)/3) | 41 | #define BOX_HEIGHT ((BOX_WIDTH*2)/3) |
@@ -183,7 +189,7 @@ int select_square(void); | |||
183 | void update_score(void); | 189 | void update_score(void); |
184 | void gen_resources(void); | 190 | void gen_resources(void); |
185 | void draw_cursor(void); | 191 | void draw_cursor(void); |
186 | int calc_strength(bool colour, int x, int y); | 192 | int calc_strength(int colour, int x, int y); |
187 | void draw_board(void); | 193 | void draw_board(void); |
188 | 194 | ||
189 | struct tile{ | 195 | struct tile{ |
@@ -221,6 +227,7 @@ struct settings { | |||
221 | 227 | ||
222 | struct resources humanres; | 228 | struct resources humanres; |
223 | struct resources compres; | 229 | struct resources compres; |
230 | enum { GS_PROD, GS_MOVE, GS_WAR } gamestate; | ||
224 | 231 | ||
225 | struct cursor{ | 232 | struct cursor{ |
226 | int x; | 233 | int x; |
@@ -230,8 +237,8 @@ struct cursor{ | |||
230 | struct tile board[12][12]; | 237 | struct tile board[12][12]; |
231 | 238 | ||
232 | void init_board(void) { | 239 | void init_board(void) { |
233 | rb->srand(*rb->current_tick); | ||
234 | int i,j; | 240 | int i,j; |
241 | rb->srand(*rb->current_tick); | ||
235 | for(i=0;i<12;i++) { /* Hopefully about 50% each colour */ | 242 | for(i=0;i<12;i++) { /* Hopefully about 50% each colour */ |
236 | for(j=0;j<12;j++) { | 243 | for(j=0;j<12;j++) { |
237 | if((i<1)||(j<1)||(i>10)||(j>10)) | 244 | if((i<1)||(j<1)||(i>10)||(j>10)) |
@@ -253,7 +260,6 @@ void init_board(void) { | |||
253 | if((board[i][j].colour == COLOUR_DARK) && (board[i][j].farm == false)) { | 260 | if((board[i][j].colour == COLOUR_DARK) && (board[i][j].farm == false)) { |
254 | board[i][j].farm = true; | 261 | board[i][j].farm = true; |
255 | compres.farms++; | 262 | compres.farms++; |
256 | break; | ||
257 | } | 263 | } |
258 | } | 264 | } |
259 | while(compres.inds < superdom_settings.compstartinds) { | 265 | while(compres.inds < superdom_settings.compstartinds) { |
@@ -262,7 +268,6 @@ void init_board(void) { | |||
262 | if((board[i][j].colour == COLOUR_DARK) && (board[i][j].ind == false)) { | 268 | if((board[i][j].colour == COLOUR_DARK) && (board[i][j].ind == false)) { |
263 | board[i][j].ind = true; | 269 | board[i][j].ind = true; |
264 | compres.inds++; | 270 | compres.inds++; |
265 | break; | ||
266 | } | 271 | } |
267 | } | 272 | } |
268 | while(humanres.farms<superdom_settings.humanstartfarms) { | 273 | while(humanres.farms<superdom_settings.humanstartfarms) { |
@@ -284,8 +289,8 @@ void init_board(void) { | |||
284 | } | 289 | } |
285 | 290 | ||
286 | void draw_board(void) { | 291 | void draw_board(void) { |
287 | rb->lcd_clear_display(); | ||
288 | int i,j; | 292 | int i,j; |
293 | rb->lcd_clear_display(); | ||
289 | for(i=1;i<11;i++) { | 294 | for(i=1;i<11;i++) { |
290 | for(j=1;j<11;j++) { | 295 | for(j=1;j<11;j++) { |
291 | if(board[i][j].colour == COLOUR_DARK) { | 296 | if(board[i][j].colour == COLOUR_DARK) { |
@@ -300,11 +305,7 @@ void draw_board(void) { | |||
300 | rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); | 305 | rb->lcd_set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); |
301 | #endif | 306 | #endif |
302 | if(board[i][j].ind) { | 307 | if(board[i][j].ind) { |
303 | #if (LCD_DEPTH == 16) | 308 | MY_BITMAP_PART(superdom_boarditems, |
304 | rb->lcd_bitmap_transparent_part(superdom_boarditems, | ||
305 | #else | ||
306 | rb->lcd_mono_bitmap_part(superdom_boarditems, | ||
307 | #endif | ||
308 | board[i][j].colour?ICON_WIDTH:0, 0, STRIDE, | 309 | board[i][j].colour?ICON_WIDTH:0, 0, STRIDE, |
309 | #if LCD_WIDTH > LCD_HEIGHT | 310 | #if LCD_WIDTH > LCD_HEIGHT |
310 | MARGIN+(BOX_WIDTH*(i-1))+1, | 311 | MARGIN+(BOX_WIDTH*(i-1))+1, |
@@ -316,33 +317,21 @@ void draw_board(void) { | |||
316 | ICON_WIDTH, ICON_HEIGHT); | 317 | ICON_WIDTH, ICON_HEIGHT); |
317 | } | 318 | } |
318 | if(board[i][j].farm) { | 319 | if(board[i][j].farm) { |
319 | #if (LCD_DEPTH == 16) | 320 | MY_BITMAP_PART(superdom_boarditems, |
320 | rb->lcd_bitmap_transparent_part(superdom_boarditems, | ||
321 | #else | ||
322 | rb->lcd_mono_bitmap_part(superdom_boarditems, | ||
323 | #endif | ||
324 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT, | 321 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT, |
325 | STRIDE, MARGIN+(BOX_WIDTH*(i-1))+1, | 322 | STRIDE, MARGIN+(BOX_WIDTH*(i-1))+1, |
326 | MARGIN+(BOX_HEIGHT*(j-1))+1, | 323 | MARGIN+(BOX_HEIGHT*(j-1))+1, |
327 | ICON_WIDTH, ICON_HEIGHT); | 324 | ICON_WIDTH, ICON_HEIGHT); |
328 | } | 325 | } |
329 | if(board[i][j].tank) { | 326 | if(board[i][j].tank) { |
330 | #if (LCD_DEPTH == 16) | 327 | MY_BITMAP_PART(superdom_boarditems, |
331 | rb->lcd_bitmap_transparent_part(superdom_boarditems, | ||
332 | #else | ||
333 | rb->lcd_mono_bitmap_part(superdom_boarditems, | ||
334 | #endif | ||
335 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*2, | 328 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*2, |
336 | STRIDE, MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, | 329 | STRIDE, MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, |
337 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT+1, | 330 | MARGIN+(BOX_HEIGHT*(j-1))+ICON_HEIGHT+1, |
338 | ICON_WIDTH, ICON_HEIGHT); | 331 | ICON_WIDTH, ICON_HEIGHT); |
339 | } | 332 | } |
340 | if(board[i][j].men) { | 333 | if(board[i][j].men) { |
341 | #if (LCD_DEPTH == 16) | 334 | MY_BITMAP_PART(superdom_boarditems, |
342 | rb->lcd_bitmap_transparent_part(superdom_boarditems, | ||
343 | #else | ||
344 | rb->lcd_mono_bitmap_part(superdom_boarditems, | ||
345 | #endif | ||
346 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*3, | 335 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*3, |
347 | #if LCD_WIDTH > LCD_HEIGHT | 336 | #if LCD_WIDTH > LCD_HEIGHT |
348 | STRIDE, MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, | 337 | STRIDE, MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH+1, |
@@ -354,11 +343,7 @@ void draw_board(void) { | |||
354 | ICON_WIDTH, ICON_HEIGHT); | 343 | ICON_WIDTH, ICON_HEIGHT); |
355 | } | 344 | } |
356 | if(board[i][j].plane) { | 345 | if(board[i][j].plane) { |
357 | #if (LCD_DEPTH == 16) | 346 | MY_BITMAP_PART(superdom_boarditems, |
358 | rb->lcd_bitmap_transparent_part(superdom_boarditems, | ||
359 | #else | ||
360 | rb->lcd_mono_bitmap_part(superdom_boarditems, | ||
361 | #endif | ||
362 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*4, | 347 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*4, |
363 | #if LCD_WIDTH > LCD_HEIGHT | 348 | #if LCD_WIDTH > LCD_HEIGHT |
364 | STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH*2+1, | 349 | STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH*2+1, |
@@ -370,11 +355,7 @@ void draw_board(void) { | |||
370 | ICON_WIDTH, ICON_HEIGHT); | 355 | ICON_WIDTH, ICON_HEIGHT); |
371 | } | 356 | } |
372 | if(board[i][j].nuke) { | 357 | if(board[i][j].nuke) { |
373 | #if (LCD_DEPTH == 16) | 358 | MY_BITMAP_PART(superdom_boarditems, |
374 | rb->lcd_bitmap_transparent_part(superdom_boarditems, | ||
375 | #else | ||
376 | rb->lcd_mono_bitmap_part(superdom_boarditems, | ||
377 | #endif | ||
378 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*5, | 359 | board[i][j].colour?ICON_WIDTH:0, ICON_HEIGHT*5, |
379 | #if LCD_WIDTH > LCD_HEIGHT | 360 | #if LCD_WIDTH > LCD_HEIGHT |
380 | STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH*2+1, | 361 | STRIDE,MARGIN+(BOX_WIDTH*(i-1))+ICON_WIDTH*2+1, |
@@ -400,34 +381,23 @@ void draw_board(void) { | |||
400 | rb->lcd_update(); | 381 | rb->lcd_update(); |
401 | } | 382 | } |
402 | 383 | ||
403 | int calc_strength(bool colour, int x, int y) { | 384 | int calc_strength(int colour, int x, int y) { |
404 | int a, b, score=0; | 385 | int a, b, score=0; |
405 | for (a = -1; a < 2; a++){ | 386 | for (a = -1; a < 2; a++) { |
406 | for (b = -1; b < 2; b++){ | 387 | for (b = -1; b < 2; b++) { |
407 | if (b == 0){ | 388 | if ((b == 0 || a == 0) && |
408 | if(board[x + a][y].colour == colour) | 389 | (board[x + a][y + b].colour == colour)) { |
409 | score+=10; | 390 | score += 10; |
410 | if(((board[x + a][y].colour == colour) && board[x + a][y].tank) || ((board[x + a][y].colour == colour) && board[x + a][y].farm)) | 391 | if(board[x + a][y + b].tank || board[x + a][y + b].farm) |
411 | score+=30; | 392 | score += 30; |
412 | if(((board[x + a][y].colour == colour) && board[x + a][y].plane) || ((board[x + a][y].colour == colour) && board[x + a][y].ind)) | 393 | if(board[x + a][y + b].plane || board[x + a][y + b].ind) |
413 | score+=40; | 394 | score += 40; |
414 | if((board[x + a][y].colour == colour) && board[x + a][y].nuke) | 395 | if(board[x + a][y + b].nuke) |
415 | score+=20; | 396 | score += 20; |
416 | if((board[x + a][y].colour == colour) && board[x + a][y].men) | 397 | if(board[x + a][y + b].men) |
417 | score+=(board[x + a][y].men*133/1000); | 398 | score += (board[x + a][y + b].men*133/1000); |
418 | } else if (a == 0){ | 399 | } |
419 | if(board[x][y + b].colour == colour) | 400 | } |
420 | score+=10; | ||
421 | if(((board[x][y + b].colour == colour) && board[x][y + b].tank) || ((board[x][y + b].colour == colour) && board[x][y + b].farm)) | ||
422 | score+=30; | ||
423 | if(((board[x][y + b].colour == colour) && board[x][y + b].plane) || ((board[x][y + b].colour == colour) && board[x][y + b].ind)) | ||
424 | score+=40; | ||
425 | if((board[x][y + b].colour == colour) && board[x][y + b].nuke) | ||
426 | score+=20; | ||
427 | if((board[x][y + b].colour == colour) && board[x][y + b].men) | ||
428 | score+=(board[x][y + b].men*133/1000); | ||
429 | } | ||
430 | } | ||
431 | } | 401 | } |
432 | return score; | 402 | return score; |
433 | } | 403 | } |
@@ -437,6 +407,7 @@ void gen_interest(void) { | |||
437 | rb->srand(*rb->current_tick); | 407 | rb->srand(*rb->current_tick); |
438 | int interest = 7+rb->rand()%6; | 408 | int interest = 7+rb->rand()%6; |
439 | humanres.bank = humanres.bank+(interest*humanres.bank/100); | 409 | humanres.bank = humanres.bank+(interest*humanres.bank/100); |
410 | compres.bank = compres.bank+(interest*compres.bank/100); | ||
440 | } | 411 | } |
441 | 412 | ||
442 | void draw_cursor(void) { | 413 | void draw_cursor(void) { |
@@ -448,10 +419,12 @@ void draw_cursor(void) { | |||
448 | } | 419 | } |
449 | 420 | ||
450 | void gen_resources(void) { | 421 | void gen_resources(void) { |
451 | gen_interest(); | ||
452 | int inccash = 0; | 422 | int inccash = 0; |
453 | int incfood = 0; | 423 | int incfood = 0; |
424 | int ratecash = 0; | ||
425 | int ratefood = 0; | ||
454 | int i; | 426 | int i; |
427 | gen_interest(); | ||
455 | rb->srand(*rb->current_tick); | 428 | rb->srand(*rb->current_tick); |
456 | /* Generate Human's resources */ | 429 | /* Generate Human's resources */ |
457 | for(i=0;i<humanres.inds;i++) { | 430 | for(i=0;i<humanres.inds;i++) { |
@@ -460,29 +433,31 @@ void gen_resources(void) { | |||
460 | for(i=0;i<humanres.farms;i++) { | 433 | for(i=0;i<humanres.farms;i++) { |
461 | incfood += (200+rb->rand()%200); | 434 | incfood += (200+rb->rand()%200); |
462 | } | 435 | } |
463 | if(inccash/humanres.inds > 450) { | 436 | if(humanres.inds) |
464 | if(incfood/humanres.farms > 350) { | 437 | ratecash = inccash/humanres.inds; |
438 | if(humanres.farms) | ||
439 | ratefood = incfood/humanres.farms; | ||
440 | if(ratecash > 450) { | ||
441 | if(ratefood > 350) { | ||
465 | rb->splash(HZ*2, "Patriotism sweeps the land, all production" | 442 | rb->splash(HZ*2, "Patriotism sweeps the land, all production" |
466 | " is up this year!"); | 443 | " is up this year!"); |
467 | } else { | 444 | } else { |
468 | rb->splash(HZ*2, "Factories working at maximum efficiency," | 445 | rb->splash(HZ*2, "Factories working at maximum efficiency," |
469 | " cash production up this year!"); | 446 | " cash production up this year!"); |
470 | } | 447 | } |
471 | } else if((inccash/humanres.inds>350)&&(inccash/humanres.inds<=450)) { | 448 | } else if(ratecash > 350) { |
472 | if(incfood/humanres.farms > 350) { | 449 | if(ratefood > 350) { |
473 | rb->splash(HZ*2, "Record crop harvest this year!"); | 450 | rb->splash(HZ*2, "Record crop harvest this year!"); |
474 | } else if((incfood/humanres.farms > 250) && | 451 | } else if(ratefood > 250) { |
475 | (incfood/humanres.farms <= 350)) { | ||
476 | rb->splash(HZ*2, "Production continues as normal"); | 452 | rb->splash(HZ*2, "Production continues as normal"); |
477 | } else { | 453 | } else { |
478 | rb->splash(HZ*2, "Spoilage of crops leads to reduced farm" | 454 | rb->splash(HZ*2, "Spoilage of crops leads to reduced farm" |
479 | " output this year"); | 455 | " output this year"); |
480 | } | 456 | } |
481 | } else { | 457 | } else { |
482 | if(incfood/humanres.farms > 350) { | 458 | if(ratefood > 350) { |
483 | rb->splash(HZ*2, "Record crop harvest this year!"); | 459 | rb->splash(HZ*2, "Record crop harvest this year!"); |
484 | } else if((incfood/humanres.farms > 250) && | 460 | } else if(ratefood > 250) { |
485 | (incfood/humanres.farms <= 350)) { | ||
486 | rb->splash(HZ*2, "Factory unions introduced. Industrial" | 461 | rb->splash(HZ*2, "Factory unions introduced. Industrial" |
487 | " production is down this year."); | 462 | " production is down this year."); |
488 | } else { | 463 | } else { |
@@ -507,17 +482,20 @@ void gen_resources(void) { | |||
507 | } | 482 | } |
508 | 483 | ||
509 | void update_score(void) { | 484 | void update_score(void) { |
485 | int strength; | ||
486 | rb->lcd_setfont(FONT_SYSFIXED); | ||
510 | rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); | 487 | rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); |
511 | rb->lcd_fillrect(5,LCD_HEIGHT-20,105,20); | 488 | rb->lcd_fillrect(5,LCD_HEIGHT-20,105,20); |
512 | rb->lcd_set_drawmode(DRMODE_SOLID); | 489 | rb->lcd_set_drawmode(DRMODE_SOLID); |
490 | strength = calc_strength(COLOUR_LIGHT, cursor.x, cursor.y); | ||
513 | rb->snprintf(buf, sizeof(buf), "Your power: %d.%d", | 491 | rb->snprintf(buf, sizeof(buf), "Your power: %d.%d", |
514 | calc_strength(COLOUR_LIGHT, cursor.x, cursor.y)/10, | 492 | strength/10, strength%10); |
515 | calc_strength(COLOUR_LIGHT, cursor.x, cursor.y)%10); | ||
516 | rb->lcd_putsxy(5,LCD_HEIGHT-20, buf); | 493 | rb->lcd_putsxy(5,LCD_HEIGHT-20, buf); |
494 | strength = calc_strength(COLOUR_DARK, cursor.x, cursor.y); | ||
517 | rb->snprintf(buf, sizeof(buf), "Comp power: %d.%d", | 495 | rb->snprintf(buf, sizeof(buf), "Comp power: %d.%d", |
518 | calc_strength(COLOUR_DARK, cursor.x, cursor.y)/10, | 496 | strength/10, strength%10); |
519 | calc_strength(COLOUR_DARK, cursor.x, cursor.y)%10); | ||
520 | rb->lcd_putsxy(5,LCD_HEIGHT-10, buf); | 497 | rb->lcd_putsxy(5,LCD_HEIGHT-10, buf); |
498 | rb->lcd_setfont(FONT_UI); | ||
521 | } | 499 | } |
522 | 500 | ||
523 | int settings_menu_function(void) { | 501 | int settings_menu_function(void) { |
@@ -527,55 +505,52 @@ int settings_menu_function(void) { | |||
527 | "Computer starting farms","Computer starting factories", | 505 | "Computer starting farms","Computer starting factories", |
528 | "Human starting farms","Human starting factories", | 506 | "Human starting farms","Human starting factories", |
529 | "Starting cash","Starting food","Moves per turn"); | 507 | "Starting cash","Starting food","Moves per turn"); |
530 | settings_menu: | 508 | |
531 | selection=rb->do_menu(&settings_menu,&selection, NULL, false); | 509 | while(1) { |
532 | switch(selection) { | 510 | selection=rb->do_menu(&settings_menu,&selection, NULL, false); |
511 | switch(selection) { | ||
533 | case 0: | 512 | case 0: |
534 | rb->set_int("Computer starting farms", "", UNIT_INT, | 513 | rb->set_int("Computer starting farms", "", UNIT_INT, |
535 | &superdom_settings.compstartfarms, NULL, | 514 | &superdom_settings.compstartfarms, NULL, |
536 | 1, 0, 5, NULL); | 515 | 1, 0, 5, NULL); |
537 | goto settings_menu; | ||
538 | break; | 516 | break; |
539 | case 1: | 517 | case 1: |
540 | rb->set_int("Computer starting factories", "", UNIT_INT, | 518 | rb->set_int("Computer starting factories", "", UNIT_INT, |
541 | &superdom_settings.compstartinds, NULL, | 519 | &superdom_settings.compstartinds, NULL, |
542 | 1, 0, 5, NULL); | 520 | 1, 0, 5, NULL); |
543 | goto settings_menu; | ||
544 | break; | 521 | break; |
545 | case 2: | 522 | case 2: |
546 | rb->set_int("Human starting farms", "", UNIT_INT, | 523 | rb->set_int("Human starting farms", "", UNIT_INT, |
547 | &superdom_settings.humanstartfarms, NULL, | 524 | &superdom_settings.humanstartfarms, NULL, |
548 | 1, 0, 5, NULL); | 525 | 1, 0, 5, NULL); |
549 | goto settings_menu; | ||
550 | break; | 526 | break; |
551 | case 3: | 527 | case 3: |
552 | superdom_settings.humanstartinds = | 528 | rb->set_int("Human starting factories", "", UNIT_INT, |
553 | rb->set_int("Human starting factories", "", UNIT_INT, | 529 | &superdom_settings.humanstartinds, NULL, |
554 | &superdom_settings.humanstartinds, NULL, | 530 | 1, 0, 5, NULL); |
555 | 1, 0, 5, NULL); | ||
556 | goto settings_menu; | ||
557 | break; | 531 | break; |
558 | case 4: | 532 | case 4: |
559 | rb->set_int("Starting cash", "", UNIT_INT, | 533 | rb->set_int("Starting cash", "", UNIT_INT, |
560 | &superdom_settings.startcash, NULL, | 534 | &superdom_settings.startcash, NULL, |
561 | 250, 0, 5000, NULL); | 535 | 250, 0, 5000, NULL); |
562 | goto settings_menu; | ||
563 | break; | 536 | break; |
564 | case 5: | 537 | case 5: |
565 | rb->set_int("Starting food", "", UNIT_INT, | 538 | rb->set_int("Starting food", "", UNIT_INT, |
566 | &superdom_settings.startfood, NULL, | 539 | &superdom_settings.startfood, NULL, |
567 | 250, 0, 5000, NULL); | 540 | 250, 0, 5000, NULL); |
568 | goto settings_menu; | ||
569 | break; | 541 | break; |
570 | case 6: | 542 | case 6: |
571 | rb->set_int("Moves per turn", "", UNIT_INT, | 543 | rb->set_int("Moves per turn", "", UNIT_INT, |
572 | &superdom_settings.movesperturn, NULL, | 544 | &superdom_settings.movesperturn, NULL, |
573 | 1, 1, 5, NULL); | 545 | 1, 1, 5, NULL); |
574 | goto settings_menu; | ||
575 | break; | 546 | break; |
576 | case MENU_ATTACHED_USB: | 547 | case MENU_ATTACHED_USB: |
577 | return PLUGIN_USB_CONNECTED; | 548 | return PLUGIN_USB_CONNECTED; |
578 | break; | 549 | break; |
550 | case GO_TO_PREVIOUS: | ||
551 | return 0; | ||
552 | break; | ||
553 | } | ||
579 | } | 554 | } |
580 | return 0; | 555 | return 0; |
581 | } | 556 | } |
@@ -688,7 +663,8 @@ int save_game(void) { | |||
688 | return -1; | 663 | return -1; |
689 | } | 664 | } |
690 | 665 | ||
691 | rb->write(fd, "SSGv2", 5); | 666 | rb->write(fd, "SSGv3", 5); |
667 | rb->write(fd, &gamestate, sizeof(gamestate)); | ||
692 | rb->write(fd, &humanres.cash, sizeof(humanres.cash)); | 668 | rb->write(fd, &humanres.cash, sizeof(humanres.cash)); |
693 | rb->write(fd, &humanres.food, sizeof(humanres.food)); | 669 | rb->write(fd, &humanres.food, sizeof(humanres.food)); |
694 | rb->write(fd, &humanres.bank, sizeof(humanres.bank)); | 670 | rb->write(fd, &humanres.bank, sizeof(humanres.bank)); |
@@ -747,6 +723,9 @@ int ingame_menu(void) { | |||
747 | case MENU_ATTACHED_USB: | 723 | case MENU_ATTACHED_USB: |
748 | return PLUGIN_USB_CONNECTED; | 724 | return PLUGIN_USB_CONNECTED; |
749 | break; | 725 | break; |
726 | case GO_TO_PREVIOUS: | ||
727 | return 0; | ||
728 | break; | ||
750 | } | 729 | } |
751 | return 0; | 730 | return 0; |
752 | } | 731 | } |
@@ -754,6 +733,9 @@ int ingame_menu(void) { | |||
754 | int get_number(char* param, int* value) { | 733 | int get_number(char* param, int* value) { |
755 | //int numbers[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; | 734 | //int numbers[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; |
756 | int numbers[3][3]; | 735 | int numbers[3][3]; |
736 | int i,j,x=0,y=0; | ||
737 | int height, width; | ||
738 | int button = 0; | ||
757 | numbers[0][0] = 1; | 739 | numbers[0][0] = 1; |
758 | numbers[0][1] = 2; | 740 | numbers[0][1] = 2; |
759 | numbers[0][2] = 3; | 741 | numbers[0][2] = 3; |
@@ -765,7 +747,6 @@ int get_number(char* param, int* value) { | |||
765 | numbers[2][2] = 9; | 747 | numbers[2][2] = 9; |
766 | rb->lcd_clear_display(); | 748 | rb->lcd_clear_display(); |
767 | /* Draw a 3x4 grid */ | 749 | /* Draw a 3x4 grid */ |
768 | int i,j,x=0,y=0; | ||
769 | for(i=0;i<=3;i++) { /* Vertical lines */ | 750 | for(i=0;i<=3;i++) { /* Vertical lines */ |
770 | rb->lcd_vline(NUM_MARGIN_X+(NUM_BOX_WIDTH*i), NUM_MARGIN_Y, | 751 | rb->lcd_vline(NUM_MARGIN_X+(NUM_BOX_WIDTH*i), NUM_MARGIN_Y, |
771 | NUM_MARGIN_Y+(4*NUM_BOX_HEIGHT)); | 752 | NUM_MARGIN_Y+(4*NUM_BOX_HEIGHT)); |
@@ -774,13 +755,11 @@ int get_number(char* param, int* value) { | |||
774 | rb->lcd_hline(NUM_MARGIN_X, NUM_MARGIN_X+(3*NUM_BOX_WIDTH), | 755 | rb->lcd_hline(NUM_MARGIN_X, NUM_MARGIN_X+(3*NUM_BOX_WIDTH), |
775 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*i)); | 756 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*i)); |
776 | } | 757 | } |
777 | int temp = 1; | ||
778 | for(i=0;i<3;i++) { | 758 | for(i=0;i<3;i++) { |
779 | for(j=0;j<3;j++) { | 759 | for(j=0;j<3;j++) { |
780 | rb->snprintf(buf, sizeof(buf), "%d", temp); | 760 | rb->snprintf(buf, sizeof(buf), "%d", numbers[i][j]); |
781 | rb->lcd_putsxy(NUM_MARGIN_X+(j*NUM_BOX_WIDTH)+10, | 761 | rb->lcd_putsxy(NUM_MARGIN_X+(j*NUM_BOX_WIDTH)+10, |
782 | NUM_MARGIN_Y+(i*NUM_BOX_HEIGHT)+8, buf); | 762 | NUM_MARGIN_Y+(i*NUM_BOX_HEIGHT)+8, buf); |
783 | temp++; | ||
784 | } | 763 | } |
785 | } | 764 | } |
786 | rb->lcd_putsxy(NUM_MARGIN_X+5, NUM_MARGIN_Y+(3*NUM_BOX_HEIGHT)+8, "CLR"); | 765 | rb->lcd_putsxy(NUM_MARGIN_X+5, NUM_MARGIN_Y+(3*NUM_BOX_HEIGHT)+8, "CLR"); |
@@ -790,7 +769,6 @@ int get_number(char* param, int* value) { | |||
790 | NUM_MARGIN_Y+(3*NUM_BOX_HEIGHT)+8, "OK"); | 769 | NUM_MARGIN_Y+(3*NUM_BOX_HEIGHT)+8, "OK"); |
791 | rb->snprintf(buf,sizeof(buf), "%d", *value); | 770 | rb->snprintf(buf,sizeof(buf), "%d", *value); |
792 | rb->lcd_putsxy(NUM_MARGIN_X+10, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, buf); | 771 | rb->lcd_putsxy(NUM_MARGIN_X+10, NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, buf); |
793 | int height, width; | ||
794 | rb->lcd_getstringsize(param, &width, &height); | 772 | rb->lcd_getstringsize(param, &width, &height); |
795 | rb->lcd_putsxy((LCD_WIDTH-width)/2, (NUM_MARGIN_Y-height)/2, param); | 773 | rb->lcd_putsxy((LCD_WIDTH-width)/2, (NUM_MARGIN_Y-height)/2, param); |
796 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); | 774 | rb->lcd_set_drawmode(DRMODE_COMPLEMENT); |
@@ -798,19 +776,19 @@ int get_number(char* param, int* value) { | |||
798 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*y), NUM_BOX_WIDTH+1, | 776 | NUM_MARGIN_Y+(NUM_BOX_HEIGHT*y), NUM_BOX_WIDTH+1, |
799 | NUM_BOX_HEIGHT+1); | 777 | NUM_BOX_HEIGHT+1); |
800 | rb->lcd_set_drawmode(DRMODE_SOLID); | 778 | rb->lcd_set_drawmode(DRMODE_SOLID); |
801 | int button = 0; | ||
802 | rb->lcd_update(); | 779 | rb->lcd_update(); |
803 | while(1) { | 780 | while(1) { |
804 | button = rb->button_get(true); | 781 | button = rb->button_get(true); |
805 | switch(button) { | 782 | switch(button) { |
806 | case SUPERDOM_OK: | 783 | case SUPERDOM_OK: |
807 | *value *= 10; | ||
808 | if(y!=3) { | 784 | if(y!=3) { |
785 | *value *= 10; | ||
809 | *value += numbers[y][x]; | 786 | *value += numbers[y][x]; |
810 | } else if(y==3 && x==0) { | 787 | } else if(x==0) { |
811 | *value /= 100; | ||
812 | } else if(y==3 && x==2) { | ||
813 | *value /= 10; | 788 | *value /= 10; |
789 | } else if(x==1) { | ||
790 | *value *= 10; | ||
791 | } else if(x==2) { | ||
814 | return 0; | 792 | return 0; |
815 | } | 793 | } |
816 | rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); | 794 | rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); |
@@ -822,7 +800,9 @@ int get_number(char* param, int* value) { | |||
822 | NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, buf); | 800 | NUM_MARGIN_Y+4*NUM_BOX_HEIGHT+10, buf); |
823 | break; | 801 | break; |
824 | case SUPERDOM_CANCEL: | 802 | case SUPERDOM_CANCEL: |
825 | return 0; | 803 | *value = 0; |
804 | rb->splash(HZ, "Cancelled"); | ||
805 | return 2; | ||
826 | break; | 806 | break; |
827 | #if CONFIG_KEYPAD != IRIVER_H10_PAD | 807 | #if CONFIG_KEYPAD != IRIVER_H10_PAD |
828 | case SUPERDOM_LEFT: | 808 | case SUPERDOM_LEFT: |
@@ -932,329 +912,387 @@ int get_number(char* param, int* value) { | |||
932 | return 0; | 912 | return 0; |
933 | } | 913 | } |
934 | 914 | ||
935 | int buy_resources_menu(void) { | 915 | bool tile_has_item(int type, int x, int y) { |
936 | int selection,tempmenu,nummen; | 916 | switch(type) { |
917 | case 0: | ||
918 | return (board[x][y].men > 0); | ||
919 | break; | ||
920 | case 1: | ||
921 | return board[x][y].tank; | ||
922 | break; | ||
923 | case 2: | ||
924 | return board[x][y].plane; | ||
925 | break; | ||
926 | case 3: | ||
927 | return board[x][y].farm; | ||
928 | break; | ||
929 | case 4: | ||
930 | return board[x][y].ind; | ||
931 | break; | ||
932 | case 5: | ||
933 | return board[x][y].nuke; | ||
934 | break; | ||
935 | } | ||
936 | return false; | ||
937 | } | ||
937 | 938 | ||
938 | MENUITEM_STRINGLIST(res_menu, "Buy Resources", NULL, "Buy men ($1)", | 939 | int buy_resources(int colour, int type, int x, int y, int nummen) { |
939 | "Buy tank ($300)", "Buy plane ($600)", "Buy Farm ($1150)", | 940 | const char *itemnames[][6] = { |
940 | "Buy Factory ($1300)", "Buy Nuke ($2000)", | 941 | { |
941 | "Finish buying", "Game menu"); | 942 | "them", |
943 | "the tank", | ||
944 | "the plane", | ||
945 | "the farm", | ||
946 | "the industrial plant", | ||
947 | "the nuke", | ||
948 | }, { | ||
949 | "place men", | ||
950 | "place a tank", | ||
951 | "place a plane", | ||
952 | "build a farm", | ||
953 | "build an industrial plant", | ||
954 | "place a nuke", | ||
955 | }, { | ||
956 | NULL, | ||
957 | "a tank", | ||
958 | "a plane", | ||
959 | "a farm", | ||
960 | "an industrial plant", | ||
961 | "a nuke", | ||
962 | }, | ||
963 | }; | ||
942 | 964 | ||
943 | resources_menu: | 965 | bool human = (colour == COLOUR_LIGHT); |
944 | selection=rb->do_menu(&res_menu,&selection, NULL, false); | 966 | int price = 0; |
945 | switch(selection) { | 967 | struct resources *res; |
946 | case 0: | 968 | |
947 | nummen = 0; | 969 | if(human) { |
948 | if(get_number("How many men would you like?", &nummen) | 970 | res = &humanres; |
949 | == PLUGIN_USB_CONNECTED) | 971 | } else { |
972 | res = &compres; | ||
973 | } | ||
974 | switch(type) { | ||
975 | case 0: /* men */ | ||
976 | price = 1*nummen; | ||
977 | break; | ||
978 | case 1: /* tank */ | ||
979 | price = 300; | ||
980 | break; | ||
981 | case 2: /* plane */ | ||
982 | price = 600; | ||
983 | break; | ||
984 | case 3: /* Farm */ | ||
985 | price = 1150; | ||
986 | break; | ||
987 | case 4: /* Factory */ | ||
988 | price = 1300; | ||
989 | break; | ||
990 | case 5: /* nuke */ | ||
991 | price = 2000; | ||
992 | break; | ||
993 | } | ||
994 | if(res->cash < price) { | ||
995 | if(human) | ||
996 | rb->splash(HZ, "Not enough money!"); | ||
997 | return 2; | ||
998 | } | ||
999 | if(human) { | ||
1000 | rb->splashf(HZ, "Where do you want to place %s?", itemnames[0][type]); | ||
1001 | switch(select_square()) { | ||
1002 | case 2: | ||
1003 | return 2; | ||
1004 | break; | ||
1005 | case PLUGIN_USB_CONNECTED: | ||
950 | return PLUGIN_USB_CONNECTED; | 1006 | return PLUGIN_USB_CONNECTED; |
951 | if(humanres.cash>=nummen) { | 1007 | break; |
952 | rb->splash(HZ, "Where do you want to place them?"); | 1008 | } |
953 | tempmenu = select_square(); | 1009 | x = cursor.x; |
954 | switch(tempmenu) { | 1010 | y = cursor.y; |
955 | case 0: | 1011 | } |
956 | rb->splash(HZ, "Cancelled"); | 1012 | if(board[x][y].colour != colour) { |
957 | break; | 1013 | if(human) |
958 | case 2: | 1014 | rb->splashf(HZ, "Can't %s on enemy territory", itemnames[1][type]); |
959 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | 1015 | return 2; |
960 | humanres.men += nummen; | 1016 | } |
961 | board[cursor.x][cursor.y].men += nummen; | 1017 | if(type != 0 && tile_has_item(type, x, y)) { |
962 | humanres.cash -= nummen; | 1018 | if(human) |
963 | } else { | 1019 | rb->splashf(HZ, "There is already %s there", itemnames[2][type]); |
964 | rb->splash(HZ,"Can't place men on enemy territory"); | 1020 | return 2; |
965 | } | 1021 | } |
966 | break; | 1022 | switch(type) { |
967 | case PLUGIN_USB_CONNECTED: | 1023 | case 0: |
968 | return PLUGIN_USB_CONNECTED; | 1024 | board[x][y].men += nummen; |
969 | break; | 1025 | res->men += nummen; |
970 | } | ||
971 | } else { | ||
972 | rb->splash(HZ, "Not enough money!"); | ||
973 | } | ||
974 | goto resources_menu; | ||
975 | break; | 1026 | break; |
976 | case 1: | 1027 | case 1: |
977 | if(humanres.cash>=300) { | 1028 | board[x][y].tank = true; |
978 | rb->splash(HZ, "Where do you want to place the tank?"); | 1029 | res->tanks++; |
979 | tempmenu = select_square(); | ||
980 | switch(tempmenu) { | ||
981 | case 0: | ||
982 | rb->splash(HZ, "Cancelled"); | ||
983 | goto resources_menu; | ||
984 | break; | ||
985 | case PLUGIN_USB_CONNECTED: | ||
986 | return PLUGIN_USB_CONNECTED; | ||
987 | break; | ||
988 | } | ||
989 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | ||
990 | if(board[cursor.x][cursor.y].tank) { | ||
991 | rb->splash(HZ, "There is already a tank there"); | ||
992 | } else { | ||
993 | board[cursor.x][cursor.y].tank = true; | ||
994 | humanres.cash -= 300; | ||
995 | humanres.tanks++; | ||
996 | } | ||
997 | } else { | ||
998 | rb->splash(HZ, "Can't place men on enemy territory"); | ||
999 | } | ||
1000 | } else { | ||
1001 | rb->splash(HZ, "Not enough money!"); | ||
1002 | } | ||
1003 | goto resources_menu; | ||
1004 | break; | 1030 | break; |
1005 | case 2: | 1031 | case 2: |
1006 | if(humanres.cash>=600) { | 1032 | board[x][y].plane = true; |
1007 | rb->splash(HZ, "Where do you want to place the plane?"); | 1033 | res->planes++; |
1008 | tempmenu = select_square(); | ||
1009 | switch(tempmenu) { | ||
1010 | case 0: | ||
1011 | rb->splash(HZ, "Cancelled"); | ||
1012 | goto resources_menu; | ||
1013 | break; | ||
1014 | case PLUGIN_USB_CONNECTED: | ||
1015 | return PLUGIN_USB_CONNECTED; | ||
1016 | break; | ||
1017 | } | ||
1018 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | ||
1019 | if(board[cursor.x][cursor.y].plane) { | ||
1020 | rb->splash(HZ, "There is already a plane there"); | ||
1021 | } else { | ||
1022 | board[cursor.x][cursor.y].plane = true; | ||
1023 | humanres.cash -= 600; | ||
1024 | humanres.planes++; | ||
1025 | } | ||
1026 | } else { | ||
1027 | rb->splash(HZ, "Can't place men on enemy territory"); | ||
1028 | } | ||
1029 | } else { | ||
1030 | rb->splash(HZ, "Not enough money!"); | ||
1031 | } | ||
1032 | goto resources_menu; | ||
1033 | break; | 1034 | break; |
1034 | case 3: | 1035 | case 3: |
1035 | if(humanres.cash>=1150) { | 1036 | board[x][y].farm = true; |
1036 | rb->splash(HZ, "Where do you want to place the farm?"); | 1037 | res->farms++; |
1037 | tempmenu = select_square(); | ||
1038 | switch(tempmenu) { | ||
1039 | case 0: | ||
1040 | rb->splash(HZ, "Cancelled"); | ||
1041 | goto resources_menu; | ||
1042 | break; | ||
1043 | case PLUGIN_USB_CONNECTED: | ||
1044 | return PLUGIN_USB_CONNECTED; | ||
1045 | break; | ||
1046 | } | ||
1047 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | ||
1048 | if(board[cursor.x][cursor.y].farm) { | ||
1049 | rb->splash(HZ, "There is already a farm there"); | ||
1050 | } else { | ||
1051 | board[cursor.x][cursor.y].farm = true; | ||
1052 | humanres.cash -= 1150; | ||
1053 | humanres.farms++; | ||
1054 | } | ||
1055 | } else { | ||
1056 | rb->splash(HZ, "Can't build on enemy territory"); | ||
1057 | } | ||
1058 | } else { | ||
1059 | rb->splash(HZ, "Not enough money!"); | ||
1060 | } | ||
1061 | goto resources_menu; | ||
1062 | break; | 1038 | break; |
1063 | case 4: | 1039 | case 4: |
1064 | if(humanres.cash>=1300) { | 1040 | board[x][y].ind = true; |
1065 | rb->splash(HZ, "Where do you want to place the industrial" | 1041 | res->inds++; |
1066 | " plant?"); | ||
1067 | tempmenu = select_square(); | ||
1068 | switch(tempmenu) { | ||
1069 | case 0: | ||
1070 | rb->splash(HZ, "Cancelled"); | ||
1071 | goto resources_menu; | ||
1072 | break; | ||
1073 | case PLUGIN_USB_CONNECTED: | ||
1074 | return PLUGIN_USB_CONNECTED; | ||
1075 | break; | ||
1076 | } | ||
1077 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | ||
1078 | if(board[cursor.x][cursor.y].ind) { | ||
1079 | rb->splash(HZ, "There is already an industrial" | ||
1080 | " plant there"); | ||
1081 | } else { | ||
1082 | board[cursor.x][cursor.y].ind = true; | ||
1083 | humanres.cash -= 1300; | ||
1084 | humanres.inds++; | ||
1085 | } | ||
1086 | } else { | ||
1087 | rb->splash(HZ, "Can't build on enemy territory"); | ||
1088 | } | ||
1089 | } else { | ||
1090 | rb->splash(HZ, "Not enough money!"); | ||
1091 | } | ||
1092 | goto resources_menu; | ||
1093 | break; | 1042 | break; |
1094 | case 5: | 1043 | case 5: |
1095 | if(humanres.cash>=2000) { | 1044 | board[x][y].nuke = true; |
1096 | rb->splash(HZ, "Where do you want to place the nuke?"); | 1045 | res->nukes++; |
1097 | tempmenu = select_square(); | 1046 | break; |
1098 | switch(tempmenu) { | 1047 | } |
1099 | case 0: | 1048 | res->cash -= price; |
1100 | rb->splash(HZ, "Cancelled"); | 1049 | |
1101 | goto resources_menu; | 1050 | draw_board(); |
1102 | break; | 1051 | rb->sleep(HZ); |
1103 | case PLUGIN_USB_CONNECTED: | 1052 | |
1104 | return PLUGIN_USB_CONNECTED; | 1053 | return 0; |
1105 | break; | 1054 | } |
1106 | } | 1055 | |
1107 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | 1056 | int buy_resources_menu(void) { |
1108 | if(board[cursor.x][cursor.y].nuke) { | 1057 | int selection,nummen; |
1109 | rb->splash(HZ, "There is already a nuke there"); | 1058 | |
1110 | } else { | 1059 | MENUITEM_STRINGLIST(res_menu, "Buy Resources", NULL, "Buy men ($1)", |
1111 | board[cursor.x][cursor.y].nuke = true; | 1060 | "Buy tank ($300)", "Buy plane ($600)", "Buy Farm ($1150)", |
1112 | humanres.cash -= 2000; | 1061 | "Buy Factory ($1300)", "Buy Nuke ($2000)", |
1113 | humanres.nukes++; | 1062 | "Finish buying"); |
1114 | } | 1063 | |
1115 | } else { | 1064 | while(1) { |
1116 | rb->splash(HZ, "Can't place a nuke on enemy territory"); | 1065 | selection=rb->do_menu(&res_menu,&selection, NULL, false); |
1117 | } | 1066 | switch(selection) { |
1118 | } else { | 1067 | case 0: |
1119 | rb->splash(HZ, "Not enough money!"); | 1068 | nummen = 0; |
1069 | if(get_number("How many men would you like?", &nummen) | ||
1070 | == PLUGIN_USB_CONNECTED) | ||
1071 | return PLUGIN_USB_CONNECTED; | ||
1072 | if(!nummen) | ||
1073 | break; | ||
1074 | /* fall through */ | ||
1075 | case 1: | ||
1076 | case 2: | ||
1077 | case 3: | ||
1078 | case 4: | ||
1079 | case 5: | ||
1080 | if(buy_resources(COLOUR_LIGHT, selection, 0, 0, nummen) | ||
1081 | == PLUGIN_USB_CONNECTED) | ||
1082 | return PLUGIN_USB_CONNECTED; | ||
1083 | break; | ||
1084 | case 6: | ||
1085 | return 0; | ||
1086 | break; | ||
1087 | case MENU_ATTACHED_USB: | ||
1088 | return PLUGIN_USB_CONNECTED; | ||
1089 | break; | ||
1090 | case GO_TO_PREVIOUS: | ||
1091 | return 0; | ||
1092 | break; | ||
1093 | } | ||
1094 | } | ||
1095 | return 0; | ||
1096 | } | ||
1097 | |||
1098 | int move_unit(int colour, int type, int fromx, int fromy, | ||
1099 | int tox, int toy, int nummen) { | ||
1100 | const char *itemnames[][3] = { | ||
1101 | { | ||
1102 | "troops", | ||
1103 | "the tank", | ||
1104 | "the plane", | ||
1105 | }, { | ||
1106 | "any troops", | ||
1107 | "a tank", | ||
1108 | "a plane", | ||
1109 | }, { | ||
1110 | "the troops", | ||
1111 | "the tank", | ||
1112 | "the plane", | ||
1113 | } | ||
1114 | }; | ||
1115 | bool human = (colour == COLOUR_LIGHT); | ||
1116 | |||
1117 | if(human) { | ||
1118 | rb->splashf(HZ, "Select where you want to move %s from", | ||
1119 | itemnames[0][type]); | ||
1120 | switch(select_square()) { | ||
1121 | case 2: | ||
1122 | return 2; | ||
1123 | break; | ||
1124 | case PLUGIN_USB_CONNECTED: | ||
1125 | return PLUGIN_USB_CONNECTED; | ||
1126 | break; | ||
1127 | } | ||
1128 | fromx = cursor.x; | ||
1129 | fromy = cursor.y; | ||
1130 | } | ||
1131 | if(board[fromx][fromy].colour != colour) { | ||
1132 | if(human) | ||
1133 | rb->splash(HZ, "That isn't your territory"); | ||
1134 | return 2; | ||
1135 | } | ||
1136 | if(!tile_has_item(type, fromx, fromy)) { | ||
1137 | if(human) | ||
1138 | rb->splashf(HZ, "You don't have %s there", itemnames[1][type]); | ||
1139 | return 2; | ||
1140 | } | ||
1141 | if(type == 0) { | ||
1142 | if(human) { | ||
1143 | nummen = board[fromx][fromy].men; | ||
1144 | switch(get_number("How many men do you want to move?", &nummen)) { | ||
1145 | case 2: | ||
1146 | return 2; | ||
1147 | break; | ||
1148 | case PLUGIN_USB_CONNECTED: | ||
1149 | return PLUGIN_USB_CONNECTED; | ||
1150 | break; | ||
1120 | } | 1151 | } |
1121 | goto resources_menu; | 1152 | } |
1153 | if(nummen > board[fromx][fromy].men) { | ||
1154 | if(human) | ||
1155 | rb->splash(HZ, "You don't have that many troops."); | ||
1156 | return 2; | ||
1157 | } | ||
1158 | } | ||
1159 | if(human) { | ||
1160 | rb->splashf(HZ, "Select where you want to move %s to", | ||
1161 | itemnames[2][type]); | ||
1162 | switch(select_square()) { | ||
1163 | case 2: | ||
1164 | return 2; | ||
1165 | break; | ||
1166 | case PLUGIN_USB_CONNECTED: | ||
1167 | return PLUGIN_USB_CONNECTED; | ||
1168 | break; | ||
1169 | } | ||
1170 | tox = cursor.x; | ||
1171 | toy = cursor.y; | ||
1172 | } | ||
1173 | if((tox == fromx && toy == fromy) || | ||
1174 | board[tox][toy].colour != colour || | ||
1175 | (type != 2 && (abs(tox - fromx) > 1 || abs(toy - fromy) > 1))) { | ||
1176 | if(human) | ||
1177 | rb->splash(HZ, "Invalid move"); | ||
1178 | return 2; | ||
1179 | } | ||
1180 | if(type != 0 && tile_has_item(type, tox, toy)) { | ||
1181 | if(human) | ||
1182 | rb->splashf(HZ, "There is already %s there", itemnames[1][type]); | ||
1183 | return 2; | ||
1184 | } | ||
1185 | switch(type) { | ||
1186 | case 0: | ||
1187 | board[fromx][fromy].men -= nummen; | ||
1188 | board[tox][toy].men += nummen; | ||
1122 | break; | 1189 | break; |
1123 | case 6: | 1190 | case 1: |
1124 | return 0; | 1191 | board[fromx][fromy].tank = false; |
1192 | board[tox][toy].tank = true; | ||
1125 | break; | 1193 | break; |
1126 | case MENU_ATTACHED_USB: | 1194 | case 2: |
1127 | return PLUGIN_USB_CONNECTED; | 1195 | board[fromx][fromy].plane = false; |
1196 | board[tox][toy].plane = true; | ||
1128 | break; | 1197 | break; |
1129 | } | 1198 | } |
1130 | return 0; | 1199 | return 0; |
1131 | } | 1200 | } |
1132 | 1201 | ||
1133 | int move_unit(void) { | 1202 | int move_unit_menu(void) { |
1134 | int selection, nummen; | 1203 | int selection; |
1135 | struct cursor from; | ||
1136 | 1204 | ||
1137 | MENUITEM_STRINGLIST(move_unit_menu, "Move unit", NULL, "Move men", | 1205 | MENUITEM_STRINGLIST(move_unit_menu, "Move unit", NULL, "Move men", |
1138 | "Move tank", "Move plane"); | 1206 | "Move tank", "Move plane"); |
1139 | selection=rb->do_menu(&move_unit_menu,&selection, NULL, false); | 1207 | selection=rb->do_menu(&move_unit_menu,&selection, NULL, false); |
1140 | switch(selection) { | 1208 | switch(selection) { |
1141 | case 0: | 1209 | case 0: |
1142 | rb->splash(HZ, "Select where to move troops from"); | ||
1143 | if(select_square() == PLUGIN_USB_CONNECTED) | ||
1144 | return PLUGIN_USB_CONNECTED; | ||
1145 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | ||
1146 | if(board[cursor.x][cursor.y].men) { | ||
1147 | from.x = cursor.x; | ||
1148 | from.y = cursor.y; | ||
1149 | nummen = board[from.x][from.y].men; | ||
1150 | if(get_number("How many men do you want to move?", | ||
1151 | &nummen) == PLUGIN_USB_CONNECTED) | ||
1152 | return PLUGIN_USB_CONNECTED; | ||
1153 | if(nummen > board[from.x][from.y].men) { | ||
1154 | rb->splash(HZ, "You don't have that many troops."); | ||
1155 | } else { | ||
1156 | rb->splash(HZ,"Select where to move the troops to"); | ||
1157 | if(select_square() == PLUGIN_USB_CONNECTED) | ||
1158 | return PLUGIN_USB_CONNECTED; | ||
1159 | if((board[cursor.x][cursor.y].colour == COLOUR_LIGHT) && | ||
1160 | (abs(cursor.x - from.x) <= 1) && | ||
1161 | abs(cursor.y - from.y) <= 1) { | ||
1162 | board[from.x][from.y].men -= nummen; | ||
1163 | board[cursor.x][cursor.y].men += nummen; | ||
1164 | humanres.moves--; | ||
1165 | return 0; | ||
1166 | } | ||
1167 | } | ||
1168 | } else { | ||
1169 | rb->splash(HZ, "You don't have any troops there"); | ||
1170 | } | ||
1171 | } else { | ||
1172 | rb->splash(HZ, "Can't move enemy troops"); | ||
1173 | } | ||
1174 | break; | ||
1175 | case 1: | 1210 | case 1: |
1176 | rb->splash(HZ, "Select where you want to move the tank from"); | ||
1177 | if(select_square() == PLUGIN_USB_CONNECTED) | ||
1178 | return PLUGIN_USB_CONNECTED; | ||
1179 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | ||
1180 | if(board[cursor.x][cursor.y].tank) { | ||
1181 | from.x = cursor.x; | ||
1182 | from.y = cursor.y; | ||
1183 | rb->splash(HZ, "Select where you want" | ||
1184 | " to move the tank to"); | ||
1185 | if(select_square() == PLUGIN_USB_CONNECTED) | ||
1186 | return PLUGIN_USB_CONNECTED; | ||
1187 | if((board[cursor.x][cursor.y].colour == COLOUR_LIGHT)&& | ||
1188 | (abs(cursor.x-from.x) <= 1) && | ||
1189 | (abs(cursor.y-from.y) <= 1)) { | ||
1190 | if(board[cursor.x][cursor.y].tank) { | ||
1191 | rb->splash(HZ, "There is already a tank there"); | ||
1192 | } else { | ||
1193 | board[from.x][from.y].tank = false; | ||
1194 | board[cursor.x][cursor.y].tank = true; | ||
1195 | humanres.moves--; | ||
1196 | return 0; | ||
1197 | } | ||
1198 | } else { | ||
1199 | rb->splash(HZ, "Invalid move"); | ||
1200 | } | ||
1201 | } else { | ||
1202 | rb->splash(HZ, "You don't have a tank there"); | ||
1203 | } | ||
1204 | } else { | ||
1205 | rb->splash(HZ, "That isn't your territory"); | ||
1206 | } | ||
1207 | break; | ||
1208 | case 2: | 1211 | case 2: |
1209 | rb->splash(HZ, "Select where you want" | 1212 | switch(move_unit(COLOUR_LIGHT, selection, 0, 0, 0, 0, 0)) { |
1210 | " to move the plane from"); | 1213 | case 0: |
1211 | if(select_square() == PLUGIN_USB_CONNECTED) | 1214 | humanres.moves--; |
1212 | return PLUGIN_USB_CONNECTED; | 1215 | break; |
1213 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | 1216 | case PLUGIN_USB_CONNECTED: |
1214 | if(board[cursor.x][cursor.y].plane) { | 1217 | return PLUGIN_USB_CONNECTED; |
1215 | from.x = cursor.x; | 1218 | break; |
1216 | from.y = cursor.y; | ||
1217 | rb->splash(HZ, "Select where you want" | ||
1218 | " to move the plane to"); | ||
1219 | if(select_square() == PLUGIN_USB_CONNECTED) | ||
1220 | return PLUGIN_USB_CONNECTED; | ||
1221 | if(board[cursor.x][cursor.y].colour == COLOUR_LIGHT) { | ||
1222 | if(board[cursor.x][cursor.y].plane) { | ||
1223 | rb->splash(HZ,"There is already a plane there"); | ||
1224 | } else { | ||
1225 | board[from.x][from.y].plane = false; | ||
1226 | board[cursor.x][cursor.y].plane = true; | ||
1227 | humanres.moves--; | ||
1228 | return 0; | ||
1229 | } | ||
1230 | } else { | ||
1231 | rb->splash(HZ, "Invalid move"); | ||
1232 | } | ||
1233 | } else { | ||
1234 | rb->splash(HZ, "You don't have a plane there"); | ||
1235 | } | ||
1236 | } else { | ||
1237 | rb->splash(HZ, "That isn't your territory"); | ||
1238 | } | 1219 | } |
1239 | break; | 1220 | break; |
1221 | case MENU_ATTACHED_USB: | ||
1222 | return PLUGIN_USB_CONNECTED; | ||
1240 | } | 1223 | } |
1241 | return 0; | 1224 | return 0; |
1242 | } | 1225 | } |
1243 | 1226 | ||
1227 | int launch_nuke(int colour, int nukex, int nukey, int targetx, int targety) { | ||
1228 | bool human = (colour == COLOUR_LIGHT); | ||
1229 | struct resources *res; | ||
1230 | |||
1231 | if(board[nukex][nukey].colour != colour) { | ||
1232 | if(human) | ||
1233 | rb->splash(HZ, "That isn't your territory"); | ||
1234 | return 2; | ||
1235 | } | ||
1236 | if(! board[nukex][nukey].nuke) { | ||
1237 | if(human) | ||
1238 | rb->splashf(HZ, "You don't have %s there", "a nuke"); | ||
1239 | return 2; | ||
1240 | } | ||
1241 | if(human) { | ||
1242 | rb->splash(HZ, "Select place to target with nuke"); | ||
1243 | switch(select_square()) { | ||
1244 | case 2: | ||
1245 | return 2; | ||
1246 | break; | ||
1247 | case PLUGIN_USB_CONNECTED: | ||
1248 | return PLUGIN_USB_CONNECTED; | ||
1249 | break; | ||
1250 | } | ||
1251 | targetx = cursor.x; | ||
1252 | targety = cursor.y; | ||
1253 | } | ||
1254 | if(human) { | ||
1255 | humanres.nukes--; | ||
1256 | } else { | ||
1257 | compres.nukes--; | ||
1258 | } | ||
1259 | board[nukex][nukey].nuke = false; | ||
1260 | |||
1261 | if(board[targetx][targety].colour == COLOUR_LIGHT) { | ||
1262 | res = &humanres; | ||
1263 | } else { | ||
1264 | res = &compres; | ||
1265 | } | ||
1266 | res->men -= board[targetx][targety].men; | ||
1267 | res->tanks -= board[targetx][targety].tank; | ||
1268 | res->planes -= board[targetx][targety].plane; | ||
1269 | res->nukes -= board[targetx][targety].nuke; | ||
1270 | res->farms -= board[targetx][targety].farm; | ||
1271 | res->inds -= board[targetx][targety].ind; | ||
1272 | board[targetx][targety].men = 0; | ||
1273 | board[targetx][targety].tank = false; | ||
1274 | board[targetx][targety].plane = false; | ||
1275 | board[targetx][targety].ind = false; | ||
1276 | board[targetx][targety].nuke = false; | ||
1277 | board[targetx][targety].farm = false; | ||
1278 | /* TODO: Fallout carried by wind */ | ||
1279 | |||
1280 | return 0; | ||
1281 | } | ||
1282 | |||
1244 | int movement_menu(void) { | 1283 | int movement_menu(void) { |
1245 | int selection, tempmenu; | 1284 | int selection, tempmenu; |
1246 | bool menu_quit = false; | ||
1247 | 1285 | ||
1248 | MENUITEM_STRINGLIST(move_menu, "Movement", NULL, "Move unit", | 1286 | MENUITEM_STRINGLIST(move_menu, "Movement", NULL, "Move unit", |
1249 | "Buy additional moves ($100)", "Launch nuclear missile", | 1287 | "Buy additional moves ($100)", "Launch nuclear missile", |
1250 | "Check map", "Finish moving", "Game menu"); | 1288 | "Check map", "Finish moving", "Game menu"); |
1251 | 1289 | ||
1252 | while(!menu_quit) { | 1290 | while(1) { |
1253 | selection=rb->do_menu(&move_menu,&selection, NULL, false); | 1291 | selection=rb->do_menu(&move_menu,&selection, NULL, false); |
1254 | switch(selection) { | 1292 | switch(selection) { |
1255 | case 0: | 1293 | case 0: |
1256 | if(humanres.moves) { | 1294 | if(humanres.moves) { |
1257 | if(move_unit()==PLUGIN_USB_CONNECTED) | 1295 | if(move_unit_menu()==PLUGIN_USB_CONNECTED) |
1258 | return PLUGIN_USB_CONNECTED; | 1296 | return PLUGIN_USB_CONNECTED; |
1259 | } else { | 1297 | } else { |
1260 | rb->splash(HZ, "You have no more moves left." | 1298 | rb->splash(HZ, "You have no more moves left." |
@@ -1275,21 +1313,15 @@ int movement_menu(void) { | |||
1275 | rb->splash(HZ, "You do not have any nukes to launch"); | 1313 | rb->splash(HZ, "You do not have any nukes to launch"); |
1276 | } else { | 1314 | } else { |
1277 | rb->splash(HZ, "Select place to launch nuke from"); | 1315 | rb->splash(HZ, "Select place to launch nuke from"); |
1278 | if(select_square() == PLUGIN_USB_CONNECTED) { | 1316 | switch(select_square()) { |
1279 | return PLUGIN_USB_CONNECTED; | 1317 | case 0: |
1280 | } | 1318 | if(launch_nuke(COLOUR_LIGHT, cursor.x, cursor.y, |
1281 | if(board[cursor.x][cursor.y].nuke) { | 1319 | 0, 0) == PLUGIN_USB_CONNECTED) |
1282 | rb->splash(HZ, "Select place to target with nuke"); | 1320 | return PLUGIN_USB_CONNECTED; |
1283 | if(select_square() == PLUGIN_USB_CONNECTED) { | 1321 | break; |
1322 | case PLUGIN_USB_CONNECTED: | ||
1284 | return PLUGIN_USB_CONNECTED; | 1323 | return PLUGIN_USB_CONNECTED; |
1285 | } | 1324 | break; |
1286 | board[cursor.x][cursor.y].men = 0; | ||
1287 | board[cursor.x][cursor.y].tank = 0; | ||
1288 | board[cursor.x][cursor.y].plane = 0; | ||
1289 | board[cursor.x][cursor.y].ind = 0; | ||
1290 | board[cursor.x][cursor.y].nuke = 0; | ||
1291 | board[cursor.x][cursor.y].farm = 0; | ||
1292 | /* TODO: Fallout carried by wind */ | ||
1293 | } | 1325 | } |
1294 | } | 1326 | } |
1295 | break; | 1327 | break; |
@@ -1320,8 +1352,6 @@ int movement_menu(void) { | |||
1320 | } | 1352 | } |
1321 | 1353 | ||
1322 | int show_inventory(void) { | 1354 | int show_inventory(void) { |
1323 | rb->lcd_clear_display(); | ||
1324 | rb->lcd_puts(1, 0, "Inventory"); | ||
1325 | char men[20], tanks[20], planes[20], inds[20], farms[20], nukes[20], | 1355 | char men[20], tanks[20], planes[20], inds[20], farms[20], nukes[20], |
1326 | cash[20], food[20], bank[20]; | 1356 | cash[20], food[20], bank[20]; |
1327 | rb->snprintf(men, sizeof(men), "Men: %d", humanres.men); | 1357 | rb->snprintf(men, sizeof(men), "Men: %d", humanres.men); |
@@ -1333,6 +1363,8 @@ int show_inventory(void) { | |||
1333 | rb->snprintf(cash, sizeof(cash), "Cash: %d", humanres.cash); | 1363 | rb->snprintf(cash, sizeof(cash), "Cash: %d", humanres.cash); |
1334 | rb->snprintf(food, sizeof(food), "Food: %d", humanres.food); | 1364 | rb->snprintf(food, sizeof(food), "Food: %d", humanres.food); |
1335 | rb->snprintf(bank, sizeof(bank), "Bank: %d", humanres.bank); | 1365 | rb->snprintf(bank, sizeof(bank), "Bank: %d", humanres.bank); |
1366 | rb->lcd_clear_display(); | ||
1367 | rb->lcd_puts(1, 0, "Inventory"); | ||
1336 | rb->lcd_puts(2, 1, men); | 1368 | rb->lcd_puts(2, 1, men); |
1337 | rb->lcd_puts(2, 2, tanks); | 1369 | rb->lcd_puts(2, 2, tanks); |
1338 | rb->lcd_puts(2, 3, planes); | 1370 | rb->lcd_puts(2, 3, planes); |
@@ -1361,38 +1393,16 @@ int production_menu(void) { | |||
1361 | selection=rb->do_menu(&prod_menu,&selection, NULL, false); | 1393 | selection=rb->do_menu(&prod_menu,&selection, NULL, false); |
1362 | switch(selection) { | 1394 | switch(selection) { |
1363 | case 0: | 1395 | case 0: |
1364 | tempmenu = buy_resources_menu(); | 1396 | if(buy_resources_menu() == PLUGIN_USB_CONNECTED) |
1365 | switch(tempmenu) { | 1397 | return PLUGIN_USB_CONNECTED; |
1366 | case PLUGIN_USB_CONNECTED: | ||
1367 | return PLUGIN_USB_CONNECTED; | ||
1368 | break; | ||
1369 | case SUPERDOM_QUIT: | ||
1370 | return SUPERDOM_QUIT; | ||
1371 | break; | ||
1372 | } | ||
1373 | break; | 1398 | break; |
1374 | case 1: | 1399 | case 1: |
1375 | tempmenu = show_inventory(); | 1400 | if(show_inventory() == PLUGIN_USB_CONNECTED) |
1376 | switch(tempmenu) { | 1401 | return PLUGIN_USB_CONNECTED; |
1377 | case 0: | ||
1378 | break; | ||
1379 | case PLUGIN_USB_CONNECTED: | ||
1380 | return PLUGIN_USB_CONNECTED; | ||
1381 | break; | ||
1382 | } | ||
1383 | break; | 1402 | break; |
1384 | case 2: | 1403 | case 2: |
1385 | tempmenu = select_square(); | 1404 | if(select_square() == PLUGIN_USB_CONNECTED) |
1386 | switch(tempmenu) { | 1405 | return PLUGIN_USB_CONNECTED; |
1387 | case PLUGIN_USB_CONNECTED: | ||
1388 | return PLUGIN_USB_CONNECTED; | ||
1389 | break; | ||
1390 | case SUPERDOM_QUIT: | ||
1391 | return SUPERDOM_QUIT; | ||
1392 | break; | ||
1393 | case 0: | ||
1394 | break; | ||
1395 | } | ||
1396 | break; | 1406 | break; |
1397 | case 3: | 1407 | case 3: |
1398 | tempbank = humanres.cash; | 1408 | tempbank = humanres.cash; |
@@ -1464,25 +1474,28 @@ void init_resources(void) { | |||
1464 | } | 1474 | } |
1465 | 1475 | ||
1466 | int select_square(void) { | 1476 | int select_square(void) { |
1477 | int button = 0; | ||
1467 | draw_board(); | 1478 | draw_board(); |
1468 | draw_cursor(); | 1479 | draw_cursor(); |
1469 | update_score(); | 1480 | update_score(); |
1470 | #if LCD_WIDTH >= 220 | 1481 | #if LCD_WIDTH >= 220 |
1482 | rb->lcd_setfont(FONT_SYSFIXED); | ||
1471 | rb->snprintf(buf, sizeof(buf), "Cash: %d", humanres.cash); | 1483 | rb->snprintf(buf, sizeof(buf), "Cash: %d", humanres.cash); |
1472 | rb->lcd_putsxy(125, LCD_HEIGHT-20, buf); | 1484 | rb->lcd_putsxy(125, LCD_HEIGHT-20, buf); |
1473 | rb->snprintf(buf, sizeof(buf), "Food: %d", humanres.food); | 1485 | rb->snprintf(buf, sizeof(buf), "Food: %d", humanres.food); |
1474 | rb->lcd_putsxy(125, LCD_HEIGHT-10, buf); | 1486 | rb->lcd_putsxy(125, LCD_HEIGHT-10, buf); |
1487 | rb->lcd_setfont(FONT_UI); | ||
1475 | #endif | 1488 | #endif |
1476 | rb->lcd_update(); | 1489 | rb->lcd_update(); |
1477 | int button = 0; | ||
1478 | while(1) { | 1490 | while(1) { |
1479 | button = rb->button_get(true); | 1491 | button = rb->button_get(true); |
1480 | switch(button) { | 1492 | switch(button) { |
1481 | case SUPERDOM_CANCEL: | 1493 | case SUPERDOM_CANCEL: |
1482 | return 0; | 1494 | rb->splash(HZ, "Cancelled"); |
1495 | return 2; | ||
1483 | break; | 1496 | break; |
1484 | case SUPERDOM_OK: | 1497 | case SUPERDOM_OK: |
1485 | return 2; | 1498 | return 0; |
1486 | break; | 1499 | break; |
1487 | #if CONFIG_KEYPAD != IRIVER_H10_PAD | 1500 | #if CONFIG_KEYPAD != IRIVER_H10_PAD |
1488 | case SUPERDOM_LEFT: | 1501 | case SUPERDOM_LEFT: |
@@ -1565,7 +1578,8 @@ int select_square(void) { | |||
1565 | } | 1578 | } |
1566 | } | 1579 | } |
1567 | 1580 | ||
1568 | int killmen(bool human) { | 1581 | int killmen(int colour) { |
1582 | bool human = (colour == COLOUR_LIGHT); | ||
1569 | int menkilled,i,j; | 1583 | int menkilled,i,j; |
1570 | int percent; | 1584 | int percent; |
1571 | if(human) { | 1585 | if(human) { |
@@ -1576,11 +1590,12 @@ int killmen(bool human) { | |||
1576 | compres.food = 0; | 1590 | compres.food = 0; |
1577 | } | 1591 | } |
1578 | menkilled = 0; | 1592 | menkilled = 0; |
1579 | for(i=1;i<12;i++) { | 1593 | for(i=1;i<11;i++) { |
1580 | for(j=1;j<12;j++) { | 1594 | for(j=1;j<11;j++) { |
1581 | if(board[i][j].colour == human) { | 1595 | if(board[i][j].colour == colour) { |
1582 | menkilled += ((board[i][j].men * percent)/1000); | 1596 | int nummen = ((board[i][j].men * percent)/1000); |
1583 | board[i][j].men = (board[i][j].men * percent)/1000; | 1597 | menkilled += board[i][j].men - nummen; |
1598 | board[i][j].men = nummen; | ||
1584 | } | 1599 | } |
1585 | } | 1600 | } |
1586 | } | 1601 | } |
@@ -1592,54 +1607,82 @@ int killmen(bool human) { | |||
1592 | return menkilled; | 1607 | return menkilled; |
1593 | } | 1608 | } |
1594 | 1609 | ||
1610 | /* return -1 if error, 1 if attack is succeeded, 0 otherwise */ | ||
1611 | int attack_territory(int colour, int x, int y) { | ||
1612 | bool human = (colour == COLOUR_LIGHT); | ||
1613 | int str_diff; | ||
1614 | |||
1615 | if(board[x][y].colour == colour) { | ||
1616 | if(human) | ||
1617 | rb->splash(HZ, "You can't attack your own territory"); | ||
1618 | return -1; | ||
1619 | } | ||
1620 | str_diff = calc_strength(COLOUR_DARK, x, y) - | ||
1621 | calc_strength(COLOUR_LIGHT, x, y); | ||
1622 | if(human) { | ||
1623 | str_diff = -str_diff; | ||
1624 | } | ||
1625 | rb->srand(*rb->current_tick); | ||
1626 | if(str_diff > 0 || (str_diff == 0 && rb->rand()%2)) { | ||
1627 | struct resources *offres, *defres; | ||
1628 | if(human) { | ||
1629 | offres = &humanres; | ||
1630 | defres = &compres; | ||
1631 | } else { | ||
1632 | offres = &compres; | ||
1633 | defres = &humanres; | ||
1634 | } | ||
1635 | defres->men -= board[x][y].men; | ||
1636 | defres->tanks -= board[x][y].tank; | ||
1637 | defres->planes -= board[x][y].plane; | ||
1638 | defres->nukes -= board[x][y].nuke; | ||
1639 | defres->farms -= board[x][y].farm; | ||
1640 | defres->inds -= board[x][y].ind; | ||
1641 | offres->farms += board[x][y].farm; | ||
1642 | offres->inds += board[x][y].ind; | ||
1643 | board[x][y].colour = colour; | ||
1644 | board[x][y].men = 0; | ||
1645 | board[x][y].tank = false; | ||
1646 | board[x][y].plane = false; | ||
1647 | board[x][y].nuke = false; | ||
1648 | draw_board(); | ||
1649 | if(human) | ||
1650 | rb->sleep(HZ*2); | ||
1651 | else | ||
1652 | rb->sleep(HZ); | ||
1653 | return 1; | ||
1654 | } else { | ||
1655 | if(human) | ||
1656 | rb->splash(HZ, "Your troops were unable to overcome" | ||
1657 | " the enemy troops"); | ||
1658 | else | ||
1659 | rb->splash(HZ*2, "The computer attempted to " | ||
1660 | "attack, but the invasion was" | ||
1661 | " pushed back"); | ||
1662 | return 0; | ||
1663 | } | ||
1664 | return 0; | ||
1665 | } | ||
1666 | |||
1595 | int war_menu(void) { | 1667 | int war_menu(void) { |
1596 | int selection, tempmenu; | 1668 | int selection, tempmenu; |
1597 | 1669 | ||
1598 | MENUITEM_STRINGLIST(wartime_menu, "War!", NULL, | 1670 | MENUITEM_STRINGLIST(wartime_menu, "War!", NULL, |
1599 | "Select territory to attack", "Finish turn", "Game menu"); | 1671 | "Select territory to attack", "Finish turn", "Game menu"); |
1600 | 1672 | ||
1601 | humanres.moves = superdom_settings.movesperturn; | ||
1602 | while(humanres.moves) { | 1673 | while(humanres.moves) { |
1603 | selection=rb->do_menu(&wartime_menu,&selection, NULL, false); | 1674 | selection=rb->do_menu(&wartime_menu,&selection, NULL, false); |
1604 | switch(selection) { | 1675 | switch(selection) { |
1605 | case 0: | 1676 | case 0: |
1606 | if(select_square() == PLUGIN_USB_CONNECTED) | 1677 | switch(select_square()) { |
1607 | return PLUGIN_USB_CONNECTED; | 1678 | case 0: |
1608 | if(board[cursor.x][cursor.y].colour == COLOUR_DARK) { | 1679 | if(attack_territory(COLOUR_LIGHT, cursor.x, cursor.y) |
1609 | if(calc_strength(COLOUR_LIGHT, cursor.x, | 1680 | >= 0) |
1610 | cursor.y) > calc_strength(COLOUR_DARK, | ||
1611 | cursor.x, cursor.y)) { | ||
1612 | board[cursor.x][cursor.y].colour = COLOUR_LIGHT; | ||
1613 | board[cursor.x][cursor.y].tank = 0; | ||
1614 | board[cursor.x][cursor.y].men = 0; | ||
1615 | board[cursor.x][cursor.y].plane = 0; | ||
1616 | board[cursor.x][cursor.y].nuke = 0; | ||
1617 | draw_board(); | ||
1618 | rb->sleep(HZ*2); | ||
1619 | humanres.moves--; | ||
1620 | } else if(calc_strength(COLOUR_LIGHT, cursor.x, cursor.y)== | ||
1621 | calc_strength(COLOUR_DARK, cursor.x, cursor.y)) { | ||
1622 | if(rb->rand()%2) { | ||
1623 | board[cursor.x][cursor.y].colour = COLOUR_LIGHT; | ||
1624 | board[cursor.x][cursor.y].tank = 0; | ||
1625 | board[cursor.x][cursor.y].men = 0; | ||
1626 | board[cursor.x][cursor.y].plane = 0; | ||
1627 | board[cursor.x][cursor.y].nuke = 0; | ||
1628 | draw_board(); | ||
1629 | rb->sleep(HZ*2); | ||
1630 | humanres.moves--; | ||
1631 | } else { | ||
1632 | rb->splash(HZ, "Your troops were unable to" | ||
1633 | " overcome the enemy troops"); | ||
1634 | humanres.moves--; | 1681 | humanres.moves--; |
1635 | } | 1682 | break; |
1636 | } else { | 1683 | case PLUGIN_USB_CONNECTED: |
1637 | rb->splash(HZ, "Your troops were unable to overcome" | 1684 | return PLUGIN_USB_CONNECTED; |
1638 | " the enemy troops"); | 1685 | break; |
1639 | humanres.moves--; | ||
1640 | } | ||
1641 | } else { | ||
1642 | rb->splash(HZ, "You can't attack your own territory"); | ||
1643 | } | 1686 | } |
1644 | break; | 1687 | break; |
1645 | case 1: | 1688 | case 1: |
@@ -1668,58 +1711,23 @@ struct threat { | |||
1668 | }; | 1711 | }; |
1669 | 1712 | ||
1670 | bool place_adjacent(bool tank, int x, int y) { | 1713 | bool place_adjacent(bool tank, int x, int y) { |
1671 | if(tank) { | 1714 | int type = (tank? 1: 2); |
1672 | if(!board[x-1][y].tank && (board[x][y].colour==board[x-1][y].colour)) { | 1715 | if(!buy_resources(COLOUR_DARK, type, x, y, 0)) { |
1673 | compres.cash -= 300; | 1716 | return true; |
1674 | board[x-1][y].tank = true; | 1717 | } |
1675 | compres.tanks++; | 1718 | if(!buy_resources(COLOUR_DARK, type, x-1, y, 0)) { |
1676 | return 0; | 1719 | return true; |
1677 | } | 1720 | } |
1678 | if(!board[x+1][y].tank && (board[x][y].colour==board[x+1][y].colour)) { | 1721 | if(!buy_resources(COLOUR_DARK, type, x+1, y, 0)) { |
1679 | compres.cash -= 300; | 1722 | return true; |
1680 | board[x+1][y].tank = true; | ||
1681 | compres.tanks++; | ||
1682 | return 0; | ||
1683 | } | ||
1684 | if(!board[x][y-1].tank && (board[x][y].colour==board[x][y-1].colour)) { | ||
1685 | compres.cash -= 300; | ||
1686 | board[x][y-1].tank = true; | ||
1687 | compres.tanks++; | ||
1688 | return 0; | ||
1689 | } | ||
1690 | if(!board[x][y+1].tank && (board[x][y].colour==board[x][y+1].colour)) { | ||
1691 | compres.cash -= 300; | ||
1692 | board[x][y+1].tank = true; | ||
1693 | compres.tanks++; | ||
1694 | return 0; | ||
1695 | } | ||
1696 | } else { | ||
1697 | if(!board[x-1][y].plane && (board[x][y].colour==board[x-1][y].colour)) { | ||
1698 | compres.cash -= 600; | ||
1699 | board[x-1][y].plane = true; | ||
1700 | compres.planes++; | ||
1701 | return 0; | ||
1702 | } | ||
1703 | if(!board[x+1][y].plane && (board[x][y].colour==board[x+1][y].colour)) { | ||
1704 | compres.cash -= 600; | ||
1705 | board[x+1][y].plane = true; | ||
1706 | compres.planes++; | ||
1707 | return 0; | ||
1708 | } | ||
1709 | if(!board[x][y-1].plane && (board[x][y].colour==board[x][y-1].colour)) { | ||
1710 | compres.cash -= 600; | ||
1711 | board[x][y-1].plane = true; | ||
1712 | compres.planes++; | ||
1713 | return 0; | ||
1714 | } | ||
1715 | if(!board[x][y+1].plane && (board[x][y].colour==board[x][y+1].colour)) { | ||
1716 | compres.cash -= 600; | ||
1717 | board[x][y+1].plane = true; | ||
1718 | compres.planes++; | ||
1719 | return 0; | ||
1720 | } | ||
1721 | } | 1723 | } |
1722 | return 1; | 1724 | if(!buy_resources(COLOUR_DARK, type, x, y-1, 0)) { |
1725 | return true; | ||
1726 | } | ||
1727 | if(!buy_resources(COLOUR_DARK, type, x, y+1, 0)) { | ||
1728 | return true; | ||
1729 | } | ||
1730 | return false; | ||
1723 | } | 1731 | } |
1724 | 1732 | ||
1725 | bool has_adjacent(int x, int y) { | 1733 | bool has_adjacent(int x, int y) { |
@@ -1733,61 +1741,28 @@ bool has_adjacent(int x, int y) { | |||
1733 | return 0; | 1741 | return 0; |
1734 | } | 1742 | } |
1735 | 1743 | ||
1736 | void find_adjacent(int x, int y, int* adj_x, int* adj_y, bool* full) { | 1744 | void find_adjacent(int x, int y, int* adj_x, int* adj_y) { |
1737 | /* Finds adjacent squares, returning squares without tanks on them | 1745 | /* Finds adjacent squares, returning squares without tanks on them |
1738 | * in preference to those with them */ | 1746 | * in preference to those with them */ |
1739 | if(((board[x-1][y].tank && (board[x-1][y].colour == COLOUR_DARK)) || | ||
1740 | board[x-1][y].colour != COLOUR_DARK) && | ||
1741 | ((board[x+1][y].tank && (board[x+1][y].colour == COLOUR_DARK)) || | ||
1742 | board[x+1][y].colour != COLOUR_DARK) && | ||
1743 | ((board[x][y-1].tank && (board[x][y-1].colour == COLOUR_DARK)) || | ||
1744 | board[x][y-1].colour != COLOUR_DARK) && | ||
1745 | ((board[x][y+1].tank && (board[x][y+1].colour == COLOUR_DARK)) || | ||
1746 | board[x][y+1].colour != COLOUR_DARK)) { | ||
1747 | *full = true; | ||
1748 | } else { | ||
1749 | *full = false; | ||
1750 | } | ||
1751 | |||
1752 | if(board[x-1][y].colour == COLOUR_DARK) { | 1747 | if(board[x-1][y].colour == COLOUR_DARK) { |
1753 | *adj_x = x-1; | 1748 | *adj_x = x-1; |
1754 | *adj_y = y; | 1749 | *adj_y = y; |
1755 | if(board[x-1][y].tank) { | 1750 | return; |
1756 | if(*full) | ||
1757 | return; | ||
1758 | } else { | ||
1759 | return; | ||
1760 | } | ||
1761 | } | 1751 | } |
1762 | if(board[x+1][y].colour == COLOUR_DARK) { | 1752 | if(board[x+1][y].colour == COLOUR_DARK) { |
1763 | *adj_x = x+1; | 1753 | *adj_x = x+1; |
1764 | *adj_y = y; | 1754 | *adj_y = y; |
1765 | if(board[x+1][y].tank) { | 1755 | return; |
1766 | if(*full) | ||
1767 | return; | ||
1768 | } else { | ||
1769 | return; | ||
1770 | } | ||
1771 | } | 1756 | } |
1772 | if(board[x][y-1].colour == COLOUR_DARK) { | 1757 | if(board[x][y-1].colour == COLOUR_DARK) { |
1773 | *adj_x = x; | 1758 | *adj_x = x; |
1774 | *adj_y = y-1; | 1759 | *adj_y = y-1; |
1775 | if(board[x][y-1].tank) { | 1760 | return; |
1776 | if(*full) | ||
1777 | return; | ||
1778 | } else { | ||
1779 | return; | ||
1780 | } | ||
1781 | } | 1761 | } |
1782 | if(board[x][y+1].colour == COLOUR_DARK) { | 1762 | if(board[x][y+1].colour == COLOUR_DARK) { |
1783 | *adj_x = x; | 1763 | *adj_x = x; |
1784 | *adj_y = y+1; | 1764 | *adj_y = y+1; |
1785 | if(board[x][y+1].tank) { | 1765 | return; |
1786 | if(*full) | ||
1787 | return; | ||
1788 | } else { | ||
1789 | return; | ||
1790 | } | ||
1791 | } | 1766 | } |
1792 | } | 1767 | } |
1793 | 1768 | ||
@@ -1800,24 +1775,27 @@ void computer_allocate(void) { | |||
1800 | struct threat threats[4]; | 1775 | struct threat threats[4]; |
1801 | int numthreats = 0; | 1776 | int numthreats = 0; |
1802 | int total_str_diff = 0; | 1777 | int total_str_diff = 0; |
1778 | int numterritory = 0; | ||
1779 | int str_diff; | ||
1803 | int men_needed; | 1780 | int men_needed; |
1804 | struct threat targets[2]; | 1781 | struct threat targets[2]; |
1805 | int numtargets; | 1782 | int numtargets; |
1806 | struct cursor adj; | 1783 | struct cursor adj; |
1807 | bool full = false; | 1784 | |
1808 | for(i=1;i<12;i++) { | 1785 | compres.cash += compres.bank; |
1809 | for(j=1;j<12;j++) { | 1786 | compres.bank = 0; |
1810 | if((board[i][j].colour == COLOUR_DARK) && | 1787 | for(i=1;i<11;i++) { |
1811 | (calc_strength(COLOUR_DARK,i,j) < | 1788 | for(j=1;j<11;j++) { |
1812 | calc_strength(COLOUR_LIGHT,i,j))) { | 1789 | if(board[i][j].colour == COLOUR_DARK) { |
1813 | if(board[i][j].ind || board[i][j].farm) { | 1790 | numterritory++; |
1791 | str_diff = calc_strength(COLOUR_LIGHT,i,j) - | ||
1792 | calc_strength(COLOUR_DARK,i,j); | ||
1793 | if(str_diff > 0 && (board[i][j].ind || board[i][j].farm)) { | ||
1814 | if(numthreats < 3) { | 1794 | if(numthreats < 3) { |
1815 | offensive = false; | 1795 | offensive = false; |
1816 | threats[numthreats].x = i; | 1796 | threats[numthreats].x = i; |
1817 | threats[numthreats].y = j; | 1797 | threats[numthreats].y = j; |
1818 | threats[numthreats].str_diff = | 1798 | threats[numthreats].str_diff = str_diff; |
1819 | calc_strength(COLOUR_LIGHT,i,j) - | ||
1820 | calc_strength(COLOUR_DARK,i,j); | ||
1821 | numthreats++; | 1799 | numthreats++; |
1822 | } | 1800 | } |
1823 | } | 1801 | } |
@@ -1839,87 +1817,56 @@ void computer_allocate(void) { | |||
1839 | * owned by the computer. If none are found just place troops in | 1817 | * owned by the computer. If none are found just place troops in |
1840 | * random places around the map until we run out of money */ | 1818 | * random places around the map until we run out of money */ |
1841 | k = 0; | 1819 | k = 0; |
1842 | while(k<numtargets) { | 1820 | for(i=1;i<11;i++) { |
1843 | for(i=1;i<12;i++) { | 1821 | for(j=1;j<11;j++) { |
1844 | for(j=1;j<12;j++) { | 1822 | if(has_adjacent(i,j) && |
1845 | if((board[i][j].colour == COLOUR_LIGHT) && | 1823 | (board[i][j].ind || board[i][j].farm)) { |
1846 | (board[i][j].ind || board[i][j].farm) && | 1824 | if(k<numtargets) { |
1847 | has_adjacent(i,j)) { | ||
1848 | targets[k].x = i; | 1825 | targets[k].x = i; |
1849 | targets[k].y = j; | 1826 | targets[k].y = j; |
1850 | targets[k].str_diff = abs(calc_strength(COLOUR_LIGHT, | 1827 | targets[k].str_diff = |
1851 | i, j) - calc_strength(COLOUR_DARK, | 1828 | calc_strength(COLOUR_LIGHT, i, j) - |
1852 | i, j)); | 1829 | calc_strength(COLOUR_DARK, i, j); |
1853 | k++; | 1830 | k++; |
1854 | } | 1831 | } |
1855 | rb->yield(); | ||
1856 | } | 1832 | } |
1833 | rb->yield(); | ||
1857 | } | 1834 | } |
1858 | } | 1835 | } |
1859 | if(k == 0) { | 1836 | if(k == 0) { |
1860 | /* No targets found! Randomly pick squares and if they're owned | 1837 | /* No targets found! Randomly pick squares and if they're owned |
1861 | * by the computer then stick a tank on it. */ | 1838 | * by the computer then stick a tank on it. */ |
1862 | rb->srand(*rb->current_tick); | 1839 | rb->srand(*rb->current_tick); |
1863 | while(compres.cash >= 300) { | 1840 | while(compres.cash >= 300 && compres.tanks < numterritory) { |
1864 | i = rb->rand()%11 + 1; | 1841 | i = rb->rand()%10 + 1; |
1865 | j = rb->rand()%11 + 1; | 1842 | j = rb->rand()%10 + 1; |
1866 | if(board[i][j].colour == COLOUR_DARK) { | 1843 | if(board[i][j].colour == COLOUR_DARK) { |
1867 | if(compres.cash >= 300) { | 1844 | buy_resources(COLOUR_DARK, 1, i, j, 0); |
1868 | if(!board[i][j].tank) { | ||
1869 | board[i][j].tank = true; | ||
1870 | compres.tanks++; | ||
1871 | compres.cash -= 300; | ||
1872 | draw_board(); | ||
1873 | rb->sleep(HZ); | ||
1874 | } | ||
1875 | } | ||
1876 | } | 1845 | } |
1846 | rb->yield(); | ||
1877 | } | 1847 | } |
1878 | compres.bank += compres.cash; | ||
1879 | compres.cash = 0; | ||
1880 | } else { | 1848 | } else { |
1881 | for(i=0;i<k;i++) { | 1849 | for(i=0;i<k;i++) { |
1882 | men_needed = targets[i].str_diff + 20; | 1850 | str_diff = targets[i].str_diff; |
1883 | find_adjacent(targets[i].x,targets[i].y, &adj.x, &adj.y, &full); | 1851 | while(str_diff + 20 > 0 && compres.cash > 0) { |
1884 | while(((calc_strength(COLOUR_LIGHT, targets[i].x, targets[i].y) | ||
1885 | + 20) > calc_strength(COLOUR_DARK, targets[i].x, | ||
1886 | targets[i].y)) && compres.cash > 0) { | ||
1887 | /* While we still need them keep placing men */ | 1852 | /* While we still need them keep placing men */ |
1888 | if(compres.cash >= 300 && !full) { | 1853 | if(!place_adjacent(true, targets[i].x, targets[i].y)) { |
1889 | if(board[adj.x][adj.y].tank) { | 1854 | find_adjacent(targets[i].x, targets[i].y, |
1890 | find_adjacent(targets[i].x, targets[i].y, | 1855 | &adj.x, &adj.y); |
1891 | &adj.x, &adj.y, &full); | 1856 | men_needed = (str_diff + 20)*1000/133; |
1892 | } else { | 1857 | if(compres.cash < men_needed) { |
1893 | board[adj.x][adj.y].tank = true; | 1858 | men_needed = compres.cash; |
1894 | compres.tanks++; | ||
1895 | compres.cash -= 300; | ||
1896 | draw_board(); | ||
1897 | rb->sleep(HZ); | ||
1898 | } | ||
1899 | } else { | ||
1900 | men_needed = (calc_strength(COLOUR_LIGHT, targets[i].x, | ||
1901 | targets[i].y) + 20 - | ||
1902 | calc_strength(COLOUR_DARK, targets[i].x, | ||
1903 | targets[i].y))*1000/133; | ||
1904 | if(compres.cash >= men_needed) { | ||
1905 | board[adj.x][adj.y].men += men_needed; | ||
1906 | compres.men += men_needed; | ||
1907 | compres.cash -= men_needed; | ||
1908 | compres.bank += compres.cash; | ||
1909 | compres.cash = 0; | ||
1910 | } else { | ||
1911 | board[adj.x][adj.y].men += compres.cash; | ||
1912 | compres.men += compres.cash; | ||
1913 | compres.cash = 0; | ||
1914 | } | 1859 | } |
1915 | draw_board(); | 1860 | buy_resources(COLOUR_DARK, 0, adj.x, adj.y, |
1916 | rb->sleep(HZ); | 1861 | men_needed); |
1862 | break; | ||
1917 | } | 1863 | } |
1864 | str_diff = calc_strength(COLOUR_LIGHT, | ||
1865 | targets[i].x, targets[i].y) - | ||
1866 | calc_strength(COLOUR_DARK, | ||
1867 | targets[i].x, targets[i].y); | ||
1918 | } | 1868 | } |
1919 | } | 1869 | } |
1920 | compres.bank += compres.cash; | ||
1921 | compres.cash = 0; | ||
1922 | rb->yield(); | ||
1923 | } | 1870 | } |
1924 | } else { | 1871 | } else { |
1925 | /* Work out what to place on each square to defend it. | 1872 | /* Work out what to place on each square to defend it. |
@@ -1937,93 +1884,42 @@ void computer_allocate(void) { | |||
1937 | * use men as a backup */ | 1884 | * use men as a backup */ |
1938 | for(i=0;i<numthreats;i++) { | 1885 | for(i=0;i<numthreats;i++) { |
1939 | men_needed = ((threats[i].str_diff + 20)*1000)/133; | 1886 | men_needed = ((threats[i].str_diff + 20)*1000)/133; |
1940 | if(compres.cash >= men_needed) { | 1887 | if(compres.cash < men_needed) { |
1941 | board[threats[i].x][threats[i].y].men += men_needed; | 1888 | men_needed = compres.cash; |
1942 | compres.cash -= men_needed; | ||
1943 | compres.men += men_needed; | ||
1944 | draw_board(); | ||
1945 | rb->sleep(HZ); | ||
1946 | } else { | ||
1947 | board[threats[i].x][threats[i].y].men += compres.cash; | ||
1948 | compres.men += compres.cash; | ||
1949 | compres.cash = 0; | ||
1950 | draw_board(); | ||
1951 | rb->sleep(HZ); | ||
1952 | } | ||
1953 | rb->yield(); | ||
1954 | } | ||
1955 | } else if((total_str_diff+20)*15 < compres.cash) { | ||
1956 | /* Enough money to pay their way by planes */ | ||
1957 | for(i=0;i<numthreats;i++) { | ||
1958 | while(calc_strength(COLOUR_DARK,threats[i].x, threats[i].y) < | ||
1959 | (calc_strength(COLOUR_LIGHT,threats[i].x, threats[i].y) + | ||
1960 | 20)) { | ||
1961 | if(board[threats[i].x][threats[i].y].plane) { | ||
1962 | if(place_adjacent(0, threats[i].x, threats[i].y)) { | ||
1963 | /* No room for any more planes, revert to men */ | ||
1964 | men_needed = (calc_strength(COLOUR_LIGHT, | ||
1965 | threats[i].x, threats[i].y) + 20 - | ||
1966 | calc_strength(COLOUR_DARK, | ||
1967 | threats[i].x, threats[i].y)*1000/133); | ||
1968 | if(compres.cash >= men_needed) { | ||
1969 | compres.cash -= men_needed; | ||
1970 | compres.men += men_needed; | ||
1971 | board[threats[i].x][threats[i].y].men += | ||
1972 | men_needed; | ||
1973 | draw_board(); | ||
1974 | rb->sleep(HZ); | ||
1975 | } | ||
1976 | } | ||
1977 | } else { | ||
1978 | if(compres.cash >= 600) { | ||
1979 | board[threats[i].x][threats[i].y].plane = true; | ||
1980 | compres.cash -= 600; | ||
1981 | compres.planes++; | ||
1982 | draw_board(); | ||
1983 | rb->sleep(HZ); | ||
1984 | } | ||
1985 | } | ||
1986 | } | 1889 | } |
1987 | rb->yield(); | 1890 | buy_resources(COLOUR_DARK, 0, threats[i].x, threats[i].y, |
1891 | men_needed); | ||
1988 | } | 1892 | } |
1989 | } else { | 1893 | } else { |
1990 | /* Tanks it is */ | 1894 | /* Tanks it is */ |
1895 | /* Enough money to pay their way by planes? */ | ||
1896 | bool tank = ((total_str_diff+20)*15 >= compres.cash); | ||
1991 | for(i=0;i<numthreats;i++) { | 1897 | for(i=0;i<numthreats;i++) { |
1992 | while(calc_strength(COLOUR_DARK,threats[i].x, threats[i].y) < | 1898 | str_diff = threats[i].str_diff; |
1993 | (calc_strength(COLOUR_LIGHT,threats[i].x, threats[i].y) + | 1899 | while(str_diff + 20 > 0) { |
1994 | 20) && compres.cash > 0) { | 1900 | if(!place_adjacent(tank, threats[i].x, threats[i].y)) { |
1995 | if(board[threats[i].x][threats[i].y].tank) { | 1901 | /* No room for any more planes or tanks, revert to |
1996 | if(place_adjacent(1, threats[i].x, threats[i].y)) { | 1902 | * men */ |
1997 | /* No room for any more tanks, revert to men */ | 1903 | find_adjacent(threats[i].x, threats[i].y, |
1998 | men_needed = (calc_strength(COLOUR_LIGHT, | 1904 | &adj.x, &adj.y); |
1999 | threats[i].x, threats[i].y) + 20 - | 1905 | men_needed = (str_diff + 20)*1000/133; |
2000 | calc_strength(COLOUR_DARK, | 1906 | if(compres.cash < men_needed) { |
2001 | threats[i].x, threats[i].y)*1000/133); | 1907 | men_needed = compres.cash; |
2002 | if(compres.cash >= men_needed) { | ||
2003 | compres.cash -= men_needed; | ||
2004 | compres.men += men_needed; | ||
2005 | board[threats[i].x][threats[i].y].men += | ||
2006 | men_needed; | ||
2007 | draw_board(); | ||
2008 | rb->sleep(HZ); | ||
2009 | } | ||
2010 | } | ||
2011 | } else { | ||
2012 | if(compres.cash >= 300) { | ||
2013 | board[threats[i].x][threats[i].y].tank = true; | ||
2014 | compres.tanks++; | ||
2015 | compres.cash -= 300; | ||
2016 | draw_board(); | ||
2017 | rb->sleep(HZ); | ||
2018 | } | 1908 | } |
1909 | buy_resources(COLOUR_DARK, 0, threats[i].x, | ||
1910 | threats[i].y, men_needed); | ||
1911 | break; | ||
2019 | } | 1912 | } |
1913 | str_diff = calc_strength(COLOUR_LIGHT, | ||
1914 | threats[i].x, threats[i].y) - | ||
1915 | calc_strength(COLOUR_DARK, | ||
1916 | threats[i].x, threats[i].y); | ||
2020 | } | 1917 | } |
2021 | rb->yield(); | ||
2022 | } | 1918 | } |
2023 | } | 1919 | } |
2024 | compres.bank += compres.cash; | ||
2025 | compres.cash = 0; | ||
2026 | } | 1920 | } |
1921 | compres.bank += compres.cash; | ||
1922 | compres.cash = 0; | ||
2027 | } | 1923 | } |
2028 | 1924 | ||
2029 | int find_adj_target(int x, int y, struct cursor* adj) { | 1925 | int find_adj_target(int x, int y, struct cursor* adj) { |
@@ -2059,127 +1955,65 @@ int find_adj_target(int x, int y, struct cursor* adj) { | |||
2059 | void computer_war(void) { | 1955 | void computer_war(void) { |
2060 | /* Work out where to attack - prioritise the defence of buildings */ | 1956 | /* Work out where to attack - prioritise the defence of buildings */ |
2061 | int i, j; | 1957 | int i, j; |
1958 | bool found_target = true; | ||
2062 | struct cursor adj; | 1959 | struct cursor adj; |
2063 | 1960 | ||
2064 | while(compres.moves) { | 1961 | while(found_target) { |
2065 | for(i=1;i<12;i++) { | 1962 | found_target = false; |
2066 | for(j=1;j<12;j++) { | 1963 | for(i=1;i<11;i++) { |
1964 | for(j=1;j<11;j++) { | ||
2067 | if((board[i][j].colour == COLOUR_DARK) && | 1965 | if((board[i][j].colour == COLOUR_DARK) && |
2068 | (board[i][j].farm || board[i][j].ind)) { | 1966 | (board[i][j].farm || board[i][j].ind) && |
2069 | if(find_adj_target(i, j, &adj) && compres.moves) { | 1967 | find_adj_target(i, j, &adj)) { |
2070 | if(calc_strength(COLOUR_LIGHT, adj.x, adj.y) == | 1968 | found_target = true; |
2071 | calc_strength(COLOUR_DARK, adj.x, adj.y)) { | 1969 | if(attack_territory(COLOUR_DARK, adj.x, adj.y) >= 0) { |
2072 | rb->srand(*rb->current_tick); | 1970 | compres.moves--; |
2073 | if(rb->rand()%2) { | 1971 | if(!compres.moves) |
2074 | board[adj.x][adj.y].colour = COLOUR_DARK; | 1972 | return; |
2075 | board[adj.x][adj.y].tank = false; | ||
2076 | board[adj.x][adj.y].plane = false; | ||
2077 | board[adj.x][adj.y].nuke = false; | ||
2078 | humanres.men -= board[adj.x][adj.y].men; | ||
2079 | board[adj.x][adj.y].men = 0; | ||
2080 | draw_board(); | ||
2081 | rb->sleep(HZ); | ||
2082 | compres.moves--; | ||
2083 | } else { | ||
2084 | rb->splash(HZ*2, "The computer attempted" | ||
2085 | " to attack, but the" | ||
2086 | " invasion was pushed" | ||
2087 | " back"); | ||
2088 | compres.moves--; | ||
2089 | } | ||
2090 | } else { | ||
2091 | if(compres.moves) { | ||
2092 | board[adj.x][adj.y].colour = COLOUR_DARK; | ||
2093 | board[adj.x][adj.y].tank = false; | ||
2094 | board[adj.x][adj.y].plane = false; | ||
2095 | board[adj.x][adj.y].nuke = false; | ||
2096 | humanres.men -= board[adj.x][adj.y].men; | ||
2097 | board[adj.x][adj.y].men = 0; | ||
2098 | draw_board(); | ||
2099 | rb->sleep(HZ); | ||
2100 | compres.moves--; | ||
2101 | } | ||
2102 | } | ||
2103 | } | 1973 | } |
2104 | } | 1974 | } |
2105 | rb->yield(); | 1975 | rb->yield(); |
2106 | } | 1976 | } |
2107 | } | 1977 | } |
2108 | if(compres.moves) { | 1978 | } |
2109 | /* Defence stage done, move on to OFFENCE */ | 1979 | /* Defence stage done, move on to OFFENCE */ |
2110 | for(i=1;i<12;i++) { | 1980 | found_target = true; |
2111 | for(j=1;j<12;j++) { | 1981 | while(found_target) { |
2112 | if(board[i][j].colour == COLOUR_LIGHT && compres.moves && | 1982 | found_target = false; |
2113 | (board[i][j].ind || board[i][j].farm) && | 1983 | for(i=1;i<11;i++) { |
2114 | (calc_strength(COLOUR_DARK, i, j) >= | 1984 | for(j=1;j<11;j++) { |
2115 | calc_strength(COLOUR_LIGHT, i, j))) { | 1985 | if(board[i][j].colour == COLOUR_LIGHT && |
2116 | if(calc_strength(COLOUR_DARK, i, j) == | 1986 | (board[i][j].ind || board[i][j].farm) && |
2117 | calc_strength(COLOUR_LIGHT, i, j)) { | 1987 | (calc_strength(COLOUR_DARK, i, j) >= |
2118 | if(rb->rand()%2) { | 1988 | calc_strength(COLOUR_LIGHT, i, j))) { |
2119 | board[i][j].colour = COLOUR_DARK; | 1989 | found_target = true; |
2120 | board[i][j].tank = false; | 1990 | if(attack_territory(COLOUR_DARK, i, j) >= 0) { |
2121 | board[i][j].plane = false; | 1991 | compres.moves--; |
2122 | board[i][j].nuke = false; | 1992 | if(!compres.moves) |
2123 | board[i][j].men = 0; | 1993 | return; |
2124 | draw_board(); | ||
2125 | rb->sleep(HZ); | ||
2126 | compres.moves--; | ||
2127 | } else { | ||
2128 | rb->splash(HZ*2, "The computer attempted to " | ||
2129 | "attack, but the invasion was" | ||
2130 | " pushed back"); | ||
2131 | compres.moves--; | ||
2132 | } | ||
2133 | } else { | ||
2134 | board[i][j].colour = COLOUR_DARK; | ||
2135 | board[i][j].tank = false; | ||
2136 | board[i][j].plane = false; | ||
2137 | board[i][j].nuke = false; | ||
2138 | board[i][j].men = 0; | ||
2139 | draw_board(); | ||
2140 | rb->sleep(HZ); | ||
2141 | compres.moves--; | ||
2142 | } | ||
2143 | } | 1994 | } |
2144 | rb->yield(); | ||
2145 | } | 1995 | } |
1996 | rb->yield(); | ||
2146 | } | 1997 | } |
2147 | while(compres.moves > 0) { | 1998 | } |
2148 | /* Spend leftover moves wherever attacking randomly */ | 1999 | } |
2149 | rb->srand(*rb->current_tick); | 2000 | /* Spend leftover moves wherever attacking randomly */ |
2150 | i = (rb->rand()%10)+1; | 2001 | found_target = true; |
2151 | j = (rb->rand()%10)+1; | 2002 | while(found_target) { |
2003 | found_target = false; | ||
2004 | for(i=1;i<11;i++) { | ||
2005 | for(j=1;j<11;j++) { | ||
2152 | if(board[i][j].colour == COLOUR_LIGHT && | 2006 | if(board[i][j].colour == COLOUR_LIGHT && |
2153 | (calc_strength(COLOUR_DARK, i, j) >= | 2007 | (calc_strength(COLOUR_DARK, i, j) >= |
2154 | calc_strength(COLOUR_LIGHT, i, j))) { | 2008 | calc_strength(COLOUR_LIGHT, i, j))) { |
2155 | if(calc_strength(COLOUR_DARK, i, j) == | 2009 | found_target = true; |
2156 | calc_strength(COLOUR_LIGHT, i, j)) { | 2010 | if(attack_territory(COLOUR_DARK, i, j) >= 0) { |
2157 | if(rb->rand()%2) { | ||
2158 | board[i][j].colour = COLOUR_DARK; | ||
2159 | board[i][j].tank = false; | ||
2160 | board[i][j].plane = false; | ||
2161 | board[i][j].nuke = false; | ||
2162 | board[i][j].men = 0; | ||
2163 | draw_board(); | ||
2164 | rb->sleep(HZ); | ||
2165 | compres.moves--; | ||
2166 | } else { | ||
2167 | rb->splash(HZ*2, "The computer attempted to" | ||
2168 | " attack, but the invasion was" | ||
2169 | " pushed back"); | ||
2170 | compres.moves--; | ||
2171 | } | ||
2172 | } else { | ||
2173 | board[i][j].colour = COLOUR_DARK; | ||
2174 | board[i][j].tank = false; | ||
2175 | board[i][j].plane = false; | ||
2176 | board[i][j].nuke = false; | ||
2177 | board[i][j].men = 0; | ||
2178 | draw_board(); | ||
2179 | rb->sleep(HZ); | ||
2180 | compres.moves--; | 2011 | compres.moves--; |
2012 | if(!compres.moves) | ||
2013 | return; | ||
2181 | } | 2014 | } |
2182 | } | 2015 | } |
2016 | rb->yield(); | ||
2183 | } | 2017 | } |
2184 | } | 2018 | } |
2185 | } | 2019 | } |
@@ -2194,10 +2028,11 @@ static int load_game(const char* file) { | |||
2194 | return -1; | 2028 | return -1; |
2195 | } | 2029 | } |
2196 | rb->read(fd, buf, 5); | 2030 | rb->read(fd, buf, 5); |
2197 | if(rb->strcmp(buf, "SSGv2")) { | 2031 | if(rb->strcmp(buf, "SSGv3")) { |
2198 | rb->splash(HZ, "Invalid/incompatible savegame\n"); | 2032 | rb->splash(HZ, "Invalid/incompatible savegame"); |
2199 | return -1; | 2033 | return -1; |
2200 | } | 2034 | } |
2035 | rb->read(fd, &gamestate, sizeof(gamestate)); | ||
2201 | rb->read(fd, &humanres.cash, sizeof(humanres.cash)); | 2036 | rb->read(fd, &humanres.cash, sizeof(humanres.cash)); |
2202 | rb->read(fd, &humanres.food, sizeof(humanres.food)); | 2037 | rb->read(fd, &humanres.food, sizeof(humanres.food)); |
2203 | rb->read(fd, &humanres.bank, sizeof(humanres.bank)); | 2038 | rb->read(fd, &humanres.bank, sizeof(humanres.bank)); |
@@ -2226,6 +2061,7 @@ static int load_game(const char* file) { | |||
2226 | rb->read(fd, &superdom_settings.startcash, sizeof(int)); | 2061 | rb->read(fd, &superdom_settings.startcash, sizeof(int)); |
2227 | rb->read(fd, &superdom_settings.startfood, sizeof(int)); | 2062 | rb->read(fd, &superdom_settings.startfood, sizeof(int)); |
2228 | rb->read(fd, &superdom_settings.movesperturn, sizeof(int)); | 2063 | rb->read(fd, &superdom_settings.movesperturn, sizeof(int)); |
2064 | rb->close(fd); | ||
2229 | return 0; | 2065 | return 0; |
2230 | } | 2066 | } |
2231 | 2067 | ||
@@ -2239,13 +2075,13 @@ void default_settings(void) { | |||
2239 | superdom_settings.movesperturn = 2; | 2075 | superdom_settings.movesperturn = 2; |
2240 | } | 2076 | } |
2241 | 2077 | ||
2242 | int average_strength(bool colour) { | 2078 | int average_strength(int colour) { |
2243 | /* This function calculates the average strength of the given player, | 2079 | /* This function calculates the average strength of the given player, |
2244 | * used to determine when the computer wins or loses. */ | 2080 | * used to determine when the computer wins or loses. */ |
2245 | int i,j; | 2081 | int i,j; |
2246 | int totalpower = 0; | 2082 | int totalpower = 0; |
2247 | for(i=0;i<12;i++) { | 2083 | for(i=1;i<11;i++) { |
2248 | for(j=0;j<12;j++) { | 2084 | for(j=1;j<11;j++) { |
2249 | if(board[i][j].colour != -1) { | 2085 | if(board[i][j].colour != -1) { |
2250 | totalpower += calc_strength(colour, i, j); | 2086 | totalpower += calc_strength(colour, i, j); |
2251 | } | 2087 | } |
@@ -2256,31 +2092,34 @@ int average_strength(bool colour) { | |||
2256 | 2092 | ||
2257 | enum plugin_status plugin_start(const void* parameter) | 2093 | enum plugin_status plugin_start(const void* parameter) |
2258 | { | 2094 | { |
2259 | int tempmenu; | ||
2260 | bool statusbar_setting; | ||
2261 | |||
2262 | #if LCD_DEPTH > 1 | 2095 | #if LCD_DEPTH > 1 |
2263 | rb->lcd_set_backdrop(NULL); | 2096 | rb->lcd_set_backdrop(NULL); |
2264 | rb->lcd_set_foreground(LCD_BLACK); | 2097 | rb->lcd_set_foreground(LCD_BLACK); |
2265 | rb->lcd_set_background(LCD_WHITE); | 2098 | rb->lcd_set_background(LCD_WHITE); |
2266 | #endif | 2099 | #endif |
2267 | 2100 | ||
2268 | statusbar_setting = rb->global_settings->statusbar; | ||
2269 | rb->global_settings->statusbar = false; | ||
2270 | cursor.x = 1; | 2101 | cursor.x = 1; |
2271 | cursor.y = 1; | 2102 | cursor.y = 1; |
2272 | default_settings(); | 2103 | default_settings(); |
2273 | if(parameter) { | 2104 | if(parameter) { |
2274 | if(load_game(parameter) != 0) { | 2105 | if(load_game(parameter) != 0) { |
2275 | DEBUGF("Loading failed, generating new game\n"); | 2106 | DEBUGF("Loading failed, generating new game\n"); |
2276 | init_resources(); | ||
2277 | init_board(); | ||
2278 | } else { | 2107 | } else { |
2279 | goto startyear; | 2108 | switch(gamestate) { |
2109 | case GS_PROD: | ||
2110 | goto startprod; | ||
2111 | break; | ||
2112 | case GS_MOVE: | ||
2113 | goto startmove; | ||
2114 | break; | ||
2115 | case GS_WAR: | ||
2116 | goto startwar; | ||
2117 | break; | ||
2118 | default: | ||
2119 | goto startyear; | ||
2120 | break; | ||
2121 | } | ||
2280 | } | 2122 | } |
2281 | } else { | ||
2282 | init_resources(); | ||
2283 | init_board(); | ||
2284 | } | 2123 | } |
2285 | 2124 | ||
2286 | bool play = false; | 2125 | bool play = false; |
@@ -2290,82 +2129,93 @@ enum plugin_status plugin_start(const void* parameter) | |||
2290 | play = true; | 2129 | play = true; |
2291 | break; | 2130 | break; |
2292 | case 2: | 2131 | case 2: |
2293 | rb->global_settings->statusbar = statusbar_setting; | ||
2294 | return PLUGIN_OK; | 2132 | return PLUGIN_OK; |
2295 | break; | 2133 | break; |
2134 | case PLUGIN_USB_CONNECTED: | ||
2135 | return PLUGIN_USB_CONNECTED; | ||
2136 | break; | ||
2296 | } | 2137 | } |
2297 | } | 2138 | } |
2139 | init_resources(); | ||
2140 | init_board(); | ||
2298 | gen_resources(); | 2141 | gen_resources(); |
2299 | startyear: | 2142 | startyear: |
2300 | if((average_strength(COLOUR_LIGHT) - average_strength(COLOUR_DARK)) > 15) { | 2143 | while(1) { |
2301 | rb->splash(HZ*4, "The computer has surrendered. You win."); | 2144 | int avg_str_diff = (average_strength(COLOUR_LIGHT) - |
2302 | rb->global_settings->statusbar = statusbar_setting; | 2145 | average_strength(COLOUR_DARK)); |
2303 | return PLUGIN_OK; | 2146 | if(avg_str_diff > 15) { |
2304 | } | 2147 | rb->splash(HZ*4, "The computer has surrendered. You win."); |
2305 | if((average_strength(COLOUR_DARK) - average_strength(COLOUR_LIGHT)) > 15) { | ||
2306 | rb->splash(HZ*4, "Your army have suffered terrible morale from the bleak prospects of winning. You lose"); | ||
2307 | rb->global_settings->statusbar = statusbar_setting; | ||
2308 | return PLUGIN_OK; | ||
2309 | } | ||
2310 | tempmenu = production_menu(); | ||
2311 | switch(tempmenu) { | ||
2312 | case PLUGIN_USB_CONNECTED: | ||
2313 | rb->global_settings->statusbar = statusbar_setting; | ||
2314 | return PLUGIN_USB_CONNECTED; | ||
2315 | break; | ||
2316 | case SUPERDOM_QUIT: | ||
2317 | rb->global_settings->statusbar = statusbar_setting; | ||
2318 | return PLUGIN_OK; | 2148 | return PLUGIN_OK; |
2319 | break; | 2149 | } |
2320 | } | 2150 | if(-avg_str_diff > 15) { |
2321 | computer_allocate(); | 2151 | rb->splash(HZ*4, "Your army have suffered terrible morale from" |
2322 | humanres.moves += superdom_settings.movesperturn; | 2152 | " the bleak prospects of winning. You lose."); |
2323 | tempmenu = movement_menu(); | ||
2324 | switch(tempmenu) { | ||
2325 | case PLUGIN_USB_CONNECTED: | ||
2326 | rb->global_settings->statusbar = statusbar_setting; | ||
2327 | return PLUGIN_USB_CONNECTED; | ||
2328 | break; | ||
2329 | case SUPERDOM_QUIT: | ||
2330 | rb->global_settings->statusbar = statusbar_setting; | ||
2331 | return PLUGIN_OK; | 2153 | return PLUGIN_OK; |
2332 | break; | ||
2333 | } | ||
2334 | if(humanres.men) { | ||
2335 | if(humanres.food > humanres.men) { | ||
2336 | rb->snprintf(buf, sizeof(buf), "Your men ate %d units of food", | ||
2337 | humanres.men); | ||
2338 | humanres.food -= humanres.men; | ||
2339 | } else { | ||
2340 | rb->snprintf(buf, sizeof(buf), "There was not enough food to feed" | ||
2341 | " all your men, %d men have died of starvation", | ||
2342 | killmen(COLOUR_LIGHT)); | ||
2343 | } | 2154 | } |
2344 | rb->splash(HZ*2, buf); | 2155 | |
2345 | } | 2156 | /* production */ |
2346 | if(compres.men) { | 2157 | startprod: |
2347 | if(compres.food < compres.men) { | 2158 | gamestate = GS_PROD; |
2348 | rb->snprintf(buf, sizeof(buf), "The computer does not have enough" | 2159 | switch(production_menu()) { |
2349 | " food to feed its men. %d have ided of starvation", | 2160 | case PLUGIN_USB_CONNECTED: |
2350 | killmen(COLOUR_DARK)); | 2161 | return PLUGIN_USB_CONNECTED; |
2351 | rb->splash(HZ, buf); | 2162 | break; |
2163 | case SUPERDOM_QUIT: | ||
2164 | return PLUGIN_OK; | ||
2165 | break; | ||
2352 | } | 2166 | } |
2167 | computer_allocate(); | ||
2168 | |||
2169 | /* movement */ | ||
2170 | humanres.moves = superdom_settings.movesperturn; | ||
2171 | startmove: | ||
2172 | gamestate = GS_MOVE; | ||
2173 | switch(movement_menu()) { | ||
2174 | case PLUGIN_USB_CONNECTED: | ||
2175 | return PLUGIN_USB_CONNECTED; | ||
2176 | break; | ||
2177 | case SUPERDOM_QUIT: | ||
2178 | return PLUGIN_OK; | ||
2179 | break; | ||
2180 | } | ||
2181 | /* feed men */ | ||
2182 | if(humanres.men) { | ||
2183 | if(humanres.food > humanres.men) { | ||
2184 | rb->snprintf(buf, sizeof(buf), "Your men ate %d units of food", | ||
2185 | humanres.men); | ||
2186 | humanres.food -= humanres.men; | ||
2187 | } else { | ||
2188 | rb->snprintf(buf, sizeof(buf), "There was not enough food" | ||
2189 | " to feed all your men, %d men have died of starvation", | ||
2190 | killmen(COLOUR_LIGHT)); | ||
2191 | } | ||
2192 | rb->splash(HZ*2, buf); | ||
2193 | } | ||
2194 | if(compres.men) { | ||
2195 | if(compres.food > compres.men) { | ||
2196 | compres.food -= compres.men; | ||
2197 | } else { | ||
2198 | rb->snprintf(buf, sizeof(buf), "The computer does not have" | ||
2199 | " enough food to feed its men. %d have died of starvation", | ||
2200 | killmen(COLOUR_DARK)); | ||
2201 | rb->splash(HZ, buf); | ||
2202 | } | ||
2203 | } | ||
2204 | /* war */ | ||
2205 | humanres.moves = superdom_settings.movesperturn; | ||
2206 | startwar: | ||
2207 | gamestate = GS_WAR; | ||
2208 | switch(war_menu()) { | ||
2209 | case PLUGIN_USB_CONNECTED: | ||
2210 | return PLUGIN_USB_CONNECTED; | ||
2211 | break; | ||
2212 | case SUPERDOM_QUIT: | ||
2213 | return PLUGIN_OK; | ||
2214 | break; | ||
2215 | } | ||
2216 | compres.moves = superdom_settings.movesperturn; | ||
2217 | computer_war(); | ||
2218 | gen_resources(); | ||
2353 | } | 2219 | } |
2354 | tempmenu = war_menu(); | ||
2355 | switch(tempmenu) { | ||
2356 | case PLUGIN_USB_CONNECTED: | ||
2357 | rb->global_settings->statusbar = statusbar_setting; | ||
2358 | return PLUGIN_USB_CONNECTED; | ||
2359 | break; | ||
2360 | case SUPERDOM_QUIT: | ||
2361 | rb->global_settings->statusbar = statusbar_setting; | ||
2362 | return PLUGIN_OK; | ||
2363 | break; | ||
2364 | } | ||
2365 | compres.moves += superdom_settings.movesperturn; | ||
2366 | computer_war(); | ||
2367 | gen_resources(); | ||
2368 | goto startyear; | ||
2369 | rb->global_settings->statusbar = statusbar_setting; | ||
2370 | return PLUGIN_OK; | 2220 | return PLUGIN_OK; |
2371 | } | 2221 | } |