void rate_civs(void)
{
int champ, i, j, mask, rate[8];
champ = 0;
for (i = 1; i < 8; i++) {
rate[i] = money[i] / 32 + (citizens[i] << 3) + tech_count[i];
for (j = 0; j < 28; j++)
rate[i] += utypes[j].cost * forces_present[i][j];
if (!(players & (1 << i)))
rate[i] = 0;
if (i != civnow && champ < rate[i])
champ = rate[i];
if (turn_tick < 600)
power_history[turn_tick / 4 % 150 * 8 + i] = clamp(rate[i] / 8, 0, 255);
mask = 0;
for (j = 0; j < 8; j++)
if ((treaties[i][j].a & 3) == 1)
mask |= 1 << j;
if (turn_tick < 600)
war_record[turn_tick / 4 % 150 * 8 + i] = (char) mask;
}
for (j = 1; j < 8; j++) {
int rank;
champ = -1;
for (i = 1; i < 8; i++)
if (champ < rate[i]) {
rank = i;
champ = rate[i];
}
nation_ratings[rank] = 8 - j;
rate[rank] = -1;
}
gangmode = 0;
if (nation_ratings[civnow] == 7 && city_count[civnow] > 4 && forces_present[civnow][25] == 0 && turn_tick > 200) {
gangmode = 1;
for (j = 1; j < 8; j++) {
if (j == civnow)
continue;
if (city_count[j] <= 1)
continue;
{
register struct relation *p = &treaties[j][civnow];
if (p->a & 2) {
p->b |= 1;
continue;
}
}
treaties[j][civnow].a |= 1;
}
}
}
void draw_banner(void)
{
rect_fill(scrbuf, 0, 0, 320, 8, 0);
draw_string("G\207AME", 8, 1, 15);
draw_string("O\207RDERS", 64, 1, 15);
draw_string("A\207DVISORS", 128, 1, 15);
draw_string("W\207ORLD", 192, 1, 15);
draw_string("C\207IVILOPEDIA", 240, 1, 15);
}
void status_draw(void)
{
register int unit;
int a, last, pop;
if (still == 1)
return;
panel_prep(0, 58, 80, 39);
rect_fill(scrbuf, 3, 60, 74, 11, 11);
if (player_peace_run > 1)
rect_fill(scrbuf, 3, 60, clamp(player_peace_run * 2, 0, 60), 2, 15);
draw_palace(civnow, palace_stage, 8, 58);
if (xray_on) {
a = free_paragraphs();
msgtext[0] = 0;
strcat(msgtext, itoa(a, nstr, 10));
draw_string(msgtext, 2, 59, 0);
}
msgtext[0] = 0;
pop = count_weighted_units(civnow);
strcat(msgtext, "#");
if (pop)
draw_string(msgtext, 2, 73, 0);
msgtext[0] = 0;
format_year();
draw_string(msgtext, 2, 81, 0);
unit = civnow * 2;
a = *(int *) ((char *) civ_research_tally + unit) * 4 / ((cur_tier * 2 + cost_penalty + 6) * *(int *) ((char *) tech_count + unit) * (year < 0 ? 1 : 2) + 1);
blit(tile_page, clamp(a, 0, 3) * 8 + 160, 120, 8, 8, scrbuf, 48, 80);
if (warm_levels) {
a = clamp(warm_levels / 4, 0, 3);
blit(tile_page, a * 8 + 160, 128, 8, 8, scrbuf, 56, 80);
}
msgtext[0] = 0;
strcat(msgtext, itoa(money[civnow], nstr, 10));
strcat(msgtext, "$");
strcat(msgtext, " ");
unit = civnow * 2;
strcat(msgtext, itoa(-(*(int *) ((char *) civ_toll + unit) + *(int *) ((char *) sci + unit) - 10), nstr, 10));
strcat(msgtext, ".");
strcat(msgtext, itoa(civ_toll[civnow], nstr, 10));
strcat(msgtext, ".");
strcat(msgtext, itoa(sci[civnow], nstr, 10));
draw_string(msgtext, 2, 89, 0);
if (player_screen_flag)
return;
last = pop_milestone;
strcpy(msgtext, "The population of the\nfertile ");
strcat(msgtext, civ_adjectives[civnow]);
strcat(msgtext, " empire now\nexceeds ");
if (pop < 100) {
if (10 * pop_milestone < pop) {
unit = pop / 10;
strcat(msgtext, itoa(unit, nstr, 10));
pop_milestone = unit;
}
} else {
a = pop_milestone - 9;
if (100 * a < pop) {
unit = pop / 100;
strcat(msgtext, itoa(unit, nstr, 10));
strcat(msgtext, ",0");
pop_milestone = unit + 9;
}
}
if (last < pop_milestone && load_state >= -1) {
strcat(msgtext, "00,000 citizens.\n");
message_mode = 4;
show_msg(msgtext, 100, 80);
}
}
int unused_flag = -1;
void draw_palace(int civ, int count, int x, int y)
{
int dummy;
int heights[9], levels[9];
int n, max, rnd, t, height, good, i, where;
draw_line(x - 5, y + 13, x + 68, y + 13, 2);
if (city_count[civ]) {
n = clamp(count + 3, 3, 36);
max = n / 5;
for (i = 0; i < 9; i++)
heights[i] = -1;
for (i = 3; i <= 5; i++)
heights[i] = 0;
rnd = civ * map_rng_state;
if (civ == civnow) {
for (i = 0; i < 9; i++) {
heights[i] = floors_palace[i];
levels[i] = section_grades[i];
}
} else {
for (i = 0; i < n; i++) {
t = 0;
do {
good = 1;
rnd = rnd * 5 + 1;
where = (unsigned int) (unsigned char) rnd % 9;
height = heights[where] + 1;
if (where < 4)
if (heights[where + 1] < height || heights[7 - where] == -1)
good = 0;
if (where > 4)
if (heights[where - 1] < height || heights[9 - where] == -1)
good = 0;
if (height > max || height > 3)
good = 0;
} while (!good && ++t < 999);
heights[where] = height;
levels[where] = civ % 3;
}
}
for (i = 0; i < 9; i++) {
if (heights[i] > 0) {
height = 2;
if (i < 4) {
height = 1;
if (heights[i - 1] == -1 || i == 1)
height = 0;
}
if (i > 4) {
height = 3;
if (heights[i + 1] == -1 || i == 7)
height = 4;
}
sprite_draw(scrbuf, x + 7 * i, y - 1, bar_set[levels[i]][clamp(heights[i] - 1, 0, 3) * 5 + height]);
}
}
}
}
int cost_sum(int n)
{
int sum, i;
sum = 0;
for (i = 0; i <= n; i++)
sum += i * (7 - cur_tier);
return sum / 2 + 1;
}
void format_year(void)
{
strcat(msgtext, itoa(abs(year), nstr, 10));
strcat(msgtext, year < 0 ? " BC" : " AD");
}