Index: apps/plugins/superdom.c =================================================================== --- apps/plugins/superdom.c (revision 14180) +++ apps/plugins/superdom.c (working copy) @@ -132,6 +132,7 @@ void draw_cursor(void); int calc_strength(bool colour, int x, int y); void draw_board(void); +void superdom_sleep(int ticks); struct tile{ signed int colour; /* -1 = Unset */ @@ -176,6 +177,16 @@ struct tile board[12][12]; +void superdom_sleep(int ticks) { + /* Note that this probably won't be very accurate in terms of timing - + * a yield() probably won't take 1 tick - so we lose some resolution, but + * it should be fairly close */ + int newtick = *rb->current_tick + ticks; + while(*rb->current_tick < newtick) { + rb->yield(); + } +} + void init_board(void) { rb->srand(*rb->current_tick); int i,j; @@ -1601,7 +1612,7 @@ board[cursor.x][cursor.y].plane = 0; board[cursor.x][cursor.y].nuke = 0; draw_board(); - rb->sleep(HZ*2); + superdom_sleep(HZ*2); humanres.moves--; } else if(calc_strength(COLOUR_LIGHT, cursor.x, cursor.y)== calc_strength(COLOUR_DARK, cursor.x, cursor.y)) { @@ -1612,7 +1623,7 @@ board[cursor.x][cursor.y].plane = 0; board[cursor.x][cursor.y].nuke = 0; draw_board(); - rb->sleep(HZ*2); + superdom_sleep(HZ*2); humanres.moves--; } else { rb->splash(HZ, "Your troops were unable to" @@ -1854,7 +1865,7 @@ compres.tanks++; compres.cash -= 300; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } } } @@ -1878,7 +1889,7 @@ compres.tanks++; compres.cash -= 300; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } } else { men_needed = (calc_strength(COLOUR_LIGHT, targets[i].x, @@ -1897,7 +1908,7 @@ compres.cash = 0; } draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } } } @@ -1925,13 +1936,13 @@ compres.cash -= men_needed; compres.men += men_needed; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } else { board[threats[i].x][threats[i].y].men += compres.cash; compres.men += compres.cash; compres.cash = 0; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } } } else if((total_str_diff+20)*15 < compres.cash) { @@ -1953,7 +1964,7 @@ board[threats[i].x][threats[i].y].men += men_needed; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } } } else { @@ -1962,7 +1973,7 @@ compres.cash -= 600; compres.planes++; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } } } @@ -1986,7 +1997,7 @@ board[threats[i].x][threats[i].y].men += men_needed; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } } } else { @@ -1995,7 +2006,7 @@ compres.tanks++; compres.cash -= 300; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); } } } @@ -2058,7 +2069,7 @@ humanres.men -= board[adj.x][adj.y].men; board[adj.x][adj.y].men = 0; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); compres.moves--; } else { rb->splash(HZ*2, "The computer attempted" @@ -2076,7 +2087,7 @@ humanres.men -= board[adj.x][adj.y].men; board[adj.x][adj.y].men = 0; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); compres.moves--; } } @@ -2101,7 +2112,7 @@ board[i][j].nuke = false; board[i][j].men = 0; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); compres.moves--; } else { rb->splash(HZ*2, "The computer attempted to " @@ -2116,7 +2127,7 @@ board[i][j].nuke = false; board[i][j].men = 0; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); compres.moves--; } } @@ -2139,7 +2150,7 @@ board[i][j].nuke = false; board[i][j].men = 0; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); compres.moves--; } else { rb->splash(HZ*2, "The computer attempted to" @@ -2154,7 +2165,7 @@ board[i][j].nuke = false; board[i][j].men = 0; draw_board(); - rb->sleep(HZ); + superdom_sleep(HZ); compres.moves--; } }