|
|
@ -18,6 +18,7 @@ static listhead activegeneric; |
|
|
|
static listhead detonatebombs; |
|
|
|
static listhead activeflames; |
|
|
|
static listhead activeplayers; |
|
|
|
static listhead allplayers; |
|
|
|
|
|
|
|
figure walking[MAXSETS][NUMWALKFRAMES]; |
|
|
|
solid background, backgroundoriginal; |
|
|
@ -26,7 +27,7 @@ solid background, backgroundoriginal; |
|
|
|
unsigned char field[32][32]; |
|
|
|
void *info[32][32]; |
|
|
|
|
|
|
|
char exitflag = 0; |
|
|
|
volatile char exitflag = 0; |
|
|
|
static int framecount = 0; |
|
|
|
|
|
|
|
char playername[16]; |
|
|
@ -46,8 +47,6 @@ TILE_NONE,160 |
|
|
|
|
|
|
|
static GameOptions gameoptions; |
|
|
|
|
|
|
|
static int host_kills, host_deaths; |
|
|
|
|
|
|
|
static const unsigned char playerpositions[MAXNETNODES*3] = { /* color, x, y */ |
|
|
|
2,0,0, |
|
|
|
3,14,10, |
|
|
@ -59,28 +58,41 @@ static const unsigned char playerpositions[MAXNETNODES*3] = { /* color, x, y */ |
|
|
|
8,14,4, |
|
|
|
}; |
|
|
|
|
|
|
|
static void initplayer(int color,int x,int y,int controller) { |
|
|
|
player *pl; |
|
|
|
|
|
|
|
pl = allocentry(player); |
|
|
|
if(!pl) |
|
|
|
nomem("Couldn't get player structure (allocentry())"); |
|
|
|
addtail(&activeplayers,pl); |
|
|
|
pl->xpos=arraytoscreenx(x); |
|
|
|
pl->ypos=arraytoscreeny(y); |
|
|
|
pl->color=color; |
|
|
|
static void resetplayer(player *pl, int color, int x, int y) { |
|
|
|
pl->speed=SPEEDSTART; |
|
|
|
pl->flags=0; |
|
|
|
pl->fixx=-4; |
|
|
|
pl->fixy=-40; |
|
|
|
pl->flamelength=gameoptions.flames+1; |
|
|
|
pl->bombsavailable=gameoptions.bombs+1; |
|
|
|
pl->controller=controller; |
|
|
|
|
|
|
|
pl->color=color; |
|
|
|
|
|
|
|
pl->xpos=arraytoscreenx(x); |
|
|
|
pl->ypos=arraytoscreeny(y); |
|
|
|
|
|
|
|
field[y][x]=FIELD_EMPTY; |
|
|
|
if(x) field[y][x-1]=FIELD_EMPTY; |
|
|
|
if(y) field[y-1][x]=FIELD_EMPTY; |
|
|
|
if(x<arraynumx-1) field[y][x+1]=FIELD_EMPTY; |
|
|
|
if(y<arraynumy-1) field[y+1][x]=FIELD_EMPTY; |
|
|
|
|
|
|
|
addtail(&activeplayers, pl); |
|
|
|
} |
|
|
|
|
|
|
|
static void initplayer(int color,int x,int y,int controller) { |
|
|
|
player *pl; |
|
|
|
|
|
|
|
pl = allocentry(player); |
|
|
|
if(!pl) |
|
|
|
nomem("Couldn't get player structure (allocentry())"); |
|
|
|
|
|
|
|
list_add_tail(&allplayers, &pl->list_all_players); |
|
|
|
|
|
|
|
pl->controller=controller; |
|
|
|
pl->fixx=-4; |
|
|
|
pl->fixy=-40; |
|
|
|
pl->kills = pl->deaths = 0; |
|
|
|
|
|
|
|
resetplayer(pl, color, x, y); |
|
|
|
} |
|
|
|
|
|
|
|
static void initplayers(void) { |
|
|
@ -102,22 +114,36 @@ static void initplayers(void) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void resetstats(void) { |
|
|
|
int i; |
|
|
|
static void resetplayers(void) { |
|
|
|
const unsigned char *p; |
|
|
|
int c,x,y; |
|
|
|
player *pl; |
|
|
|
|
|
|
|
host_deaths = host_kills = 0; |
|
|
|
for (i = 0; i < MAXNETNODES; i++) { |
|
|
|
netnodes[i].deaths = netnodes[i].kills = 0; |
|
|
|
p=playerpositions; |
|
|
|
list_for_each_entry(pl, &allplayers, list_all_players) { |
|
|
|
c=*p++; |
|
|
|
x=*p++; |
|
|
|
y=*p++; |
|
|
|
resetplayer(pl, c, x, y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void firstzero(void) { |
|
|
|
alloc_things(); |
|
|
|
list_init_head(&activebombs); |
|
|
|
list_init_head(&detonatebombs); |
|
|
|
list_init_head(&activeflames); |
|
|
|
list_init_head(&activedecays); |
|
|
|
list_init_head(&activebonus); |
|
|
|
list_init_head(&activeplayers); |
|
|
|
list_init_head(&activegeneric); |
|
|
|
list_init_head(&allplayers); |
|
|
|
|
|
|
|
mycount = mydatacount = 0; |
|
|
|
memset(latestactions,0,sizeof(latestactions)); |
|
|
|
memset(latestcounts,0,sizeof(latestcounts)); |
|
|
|
memset(actionblock,0,sizeof(actionblock)); |
|
|
|
actioncount = 0; |
|
|
|
resetstats(); |
|
|
|
} |
|
|
|
|
|
|
|
static void initgame() { |
|
|
@ -130,14 +156,14 @@ static void initgame() { |
|
|
|
if (network != NETWORK_SLAVE) |
|
|
|
set_game_options(&configopts); |
|
|
|
gameframe=0; |
|
|
|
allocthings(); |
|
|
|
list_init_head(&activebombs); |
|
|
|
list_init_head(&detonatebombs); |
|
|
|
list_init_head(&activeflames); |
|
|
|
list_init_head(&activedecays); |
|
|
|
list_init_head(&activebonus); |
|
|
|
|
|
|
|
things_list_clear(&activebombs); |
|
|
|
things_list_clear(&detonatebombs); |
|
|
|
things_list_clear(&activeflames); |
|
|
|
things_list_clear(&activedecays); |
|
|
|
things_list_clear(&activebonus); |
|
|
|
list_init_head(&activeplayers); |
|
|
|
list_init_head(&activegeneric); |
|
|
|
things_list_clear(&activegeneric); |
|
|
|
|
|
|
|
p=bonuschances; |
|
|
|
bonustotal=0; |
|
|
@ -160,7 +186,7 @@ static void initgame() { |
|
|
|
|
|
|
|
solidcopyany(&backgroundoriginal,&background,0,0,IXSIZE,IYSIZE); |
|
|
|
|
|
|
|
initplayers(); |
|
|
|
resetplayers(); |
|
|
|
|
|
|
|
for(j=0;j<arraynumy;++j) { |
|
|
|
y=arraystarty+j*arrayspacey; |
|
|
@ -532,11 +558,7 @@ static void adddeath(player *pl) { |
|
|
|
} |
|
|
|
|
|
|
|
static void killplayer(player *pl) { |
|
|
|
if (pl->controller == -1) { |
|
|
|
host_deaths++; |
|
|
|
} else { |
|
|
|
netnodes[pl->controller].deaths++; |
|
|
|
} |
|
|
|
pl->deaths++; |
|
|
|
pl->flags|=FLG_DEAD; |
|
|
|
playsound(2); |
|
|
|
adddeath(pl); |
|
|
@ -561,23 +583,19 @@ static void drawgenerics(void) { |
|
|
|
} |
|
|
|
|
|
|
|
static void drawstats(void) { |
|
|
|
int d, k, p = 0, i; |
|
|
|
player *pl; |
|
|
|
int p = 0; |
|
|
|
const char *n; |
|
|
|
char buf[16]; |
|
|
|
|
|
|
|
solidcopy(&background, 0, 0, IXSIZE, arraystarty); |
|
|
|
for (i = -1; i < MAXNETNODES; i++) { |
|
|
|
if (i >= 0) { |
|
|
|
if (!netnodes[i].used) continue; |
|
|
|
k = netnodes[i].kills; |
|
|
|
d = netnodes[i].deaths; |
|
|
|
n = netnodes[i].name; |
|
|
|
list_for_each_entry(pl, &allplayers, list_all_players) { |
|
|
|
if (pl->controller >= 0) { |
|
|
|
n = netnodes[pl->controller].name; |
|
|
|
} else { |
|
|
|
k = host_kills; |
|
|
|
d = host_deaths; |
|
|
|
n = playername; |
|
|
|
} |
|
|
|
snprintf(buf, sizeof(buf), "%-8.8s %2i/%2i", n, k % 100, d % 100); |
|
|
|
snprintf(buf, sizeof(buf), "%-8.8s %2i/%2i", n, pl->kills % 100, pl->deaths % 100); |
|
|
|
drawstring(11 + (p/2) * (15 * fontxsize + 7), 11 + (p%2) * (fontysize+2), buf); |
|
|
|
p++; |
|
|
|
} |
|
|
@ -754,6 +772,7 @@ static void doplayer(player *pl) { |
|
|
|
|
|
|
|
if(what==ACT_QUIT) { |
|
|
|
killplayer(pl); |
|
|
|
list_del(&pl->list_all_players); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -761,6 +780,12 @@ static void doplayer(player *pl) { |
|
|
|
playsound((myrand()&1) ? 1 : 5); |
|
|
|
applybonus(pl,info[py][px]); |
|
|
|
} else if(there==FIELD_FLAME) { |
|
|
|
flame *fl = info[py][px]; |
|
|
|
if (fl->owner == pl) { |
|
|
|
pl->kills--; |
|
|
|
} else { |
|
|
|
fl->owner->kills++; |
|
|
|
} |
|
|
|
killplayer(pl); |
|
|
|
return; |
|
|
|
} |
|
|
@ -935,6 +960,7 @@ void run_single_player(void) { |
|
|
|
network = NETWORK_NONE; |
|
|
|
|
|
|
|
firstzero(); |
|
|
|
initplayers(); |
|
|
|
do { |
|
|
|
initgame(); |
|
|
|
while(!(code=iterate()) && !exitflag) ++framecount; |
|
|
@ -945,6 +971,7 @@ void run_network_game(void) { |
|
|
|
int code; |
|
|
|
|
|
|
|
firstzero(); |
|
|
|
initplayers(); |
|
|
|
do { |
|
|
|
initgame(); |
|
|
|
while (!(code=iterate()) && !exitflag) ++framecount; |
|
|
|