diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 1d4cf879a..8353f7b70 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -125,7 +125,7 @@ typedef struct { }; } playerspawn_t; -typedef struct { +typedef struct STATUSBARTYPE { int16_t got_access, last_extra, inv_amount[GET_MAX], curr_weapon, holoduke_on; int16_t last_weapon, weapon_pos, kickback_pic; int16_t ammo_amount[MAX_WEAPONS], frag[MAXPLAYERS]; @@ -201,7 +201,6 @@ typedef struct player_struct { int32_t truefz, truecz, player_par; int32_t randomflamex, exitx, exity; int32_t runspeed; - int32_t autostep, autostep_sbw; uint32_t interface_toggle_flag; uint16_t max_actors_killed, actors_killed; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 2dfb48d4d..238ee4b2f 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -30,6 +30,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms BEGIN_DUKE_NS +int which_palookup = 9; //--------------------------------------------------------------------------- // @@ -497,5 +498,158 @@ void resetprestat(int snum,int g) } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void resetpspritevars(int g) +{ + short i, j, nexti, circ; + int firstx, firsty; + spritetype* s; + char aimmode[MAXPLAYERS], autoaim[MAXPLAYERS]; + STATUSBARTYPE tsbar[MAXPLAYERS]; + + EGS(ps[0].cursectnum, ps[0].posx, ps[0].posy, ps[0].posz, + TILE_APLAYER, 0, 0, 0, ps[0].getang(), 0, 0, 0, 10); + + if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++) + { + aimmode[i] = ps[i].aim_mode; + autoaim[i] = ps[i].auto_aim; + if (ud.multimode > 1 && ud.coop == 1 && ud.last_level >= 0) + { + for (j = 0; j < MAX_WEAPONS; j++) + { + tsbar[i].ammo_amount[j] = ps[i].ammo_amount[j]; + tsbar[i].gotweapon.Set(j, ps[i].gotweapon[j]); + } + + tsbar[i].shield_amount = ps[i].shield_amount; + tsbar[i].curr_weapon = ps[i].curr_weapon; + tsbar[i].inven_icon = ps[i].inven_icon; + + tsbar[i].firstaid_amount = ps[i].firstaid_amount; + tsbar[i].steroids_amount = ps[i].steroids_amount; + tsbar[i].holoduke_amount = ps[i].holoduke_amount; + tsbar[i].jetpack_amount = ps[i].jetpack_amount; + tsbar[i].heat_amount = ps[i].heat_amount; + tsbar[i].scuba_amount = ps[i].scuba_amount; + tsbar[i].boot_amount = ps[i].boot_amount; + } + } + + resetplayerstats(0); + + for (i = 1; i < MAXPLAYERS; i++) + memcpy(&ps[i], &ps[0], sizeof(ps[0])); + + if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++) + { + ps[i].aim_mode = aimmode[i]; + ps[i].auto_aim = autoaim[i]; + if (ud.multimode > 1 && ud.coop == 1 && ud.last_level >= 0) + { + for (j = 0; j < MAX_WEAPONS; j++) + { + ps[i].ammo_amount[j] = tsbar[i].ammo_amount[j]; + ps[i].gotweapon.Set(j, tsbar[i].gotweapon[j]); + } + ps[i].shield_amount = tsbar[i].shield_amount; + ps[i].curr_weapon = tsbar[i].curr_weapon; + ps[i].inven_icon = tsbar[i].inven_icon; + + ps[i].firstaid_amount = tsbar[i].firstaid_amount; + ps[i].steroids_amount = tsbar[i].steroids_amount; + ps[i].holoduke_amount = tsbar[i].holoduke_amount; + ps[i].jetpack_amount = tsbar[i].jetpack_amount; + ps[i].heat_amount = tsbar[i].heat_amount; + ps[i].scuba_amount = tsbar[i].scuba_amount; + ps[i].boot_amount = tsbar[i].boot_amount; + } + } + + numplayersprites = 0; + circ = 2048 / ud.multimode; + + which_palookup = 9; + j = connecthead; + i = headspritestat[10]; // 10 == players... + while (i >= 0) + { + nexti = nextspritestat[i]; + s = &sprite[i]; + + if (numplayersprites == MAXPLAYERS) + I_Error("Too many player sprites (max 16.)"); + + if (numplayersprites == 0) + { + firstx = ps[0].posx; + firsty = ps[0].posy; + } + + po[numplayersprites].ox = s->x; + po[numplayersprites].oy = s->y; + po[numplayersprites].oz = s->z; + po[numplayersprites].oa = s->ang; + po[numplayersprites].os = s->sectnum; + + numplayersprites++; + if (j >= 0) + { + s->owner = i; + s->shade = 0; + s->xrepeat = isRR() ? 24 : 42; + s->yrepeat = isRR() ? 17 : 36; + s->cstat = 1 + 256; + s->xoffset = 0; + s->clipdist = 64; + + if ((g & MODE_EOL) != MODE_EOL || ps[j].last_extra == 0) + { + ps[j].last_extra = max_player_health; + s->extra = max_player_health; + } + else s->extra = ps[j].last_extra; + + s->yvel = j; + + if (ud.last_level == -1) + { + if (s->pal == 0) + { + s->pal = ps[j].palookup = which_palookup; + //ud.user_pals[j] = which_palookup; + which_palookup++; + if (which_palookup == 17) which_palookup = 9; + } + else /*ud.user_pals[j] =*/ ps[j].palookup = s->pal; + } + else + s->pal = ps[j].palookup = g_player[j].pcolor;// ud.user_pals[j]; + + ps[j].i = i; + ps[j].frag_ps = j; + hittype[i].owner = i; + + hittype[i].bposx = ps[j].bobposx = ps[j].oposx = ps[j].posx = s->x; + hittype[i].bposy = ps[j].bobposy = ps[j].oposy = ps[j].posy = s->y; + hittype[i].bposz = ps[j].oposz = ps[j].posz = s->z; + ps[j].setang(s->ang); + ps[j].setoang(s->ang); + + updatesector(s->x, s->y, &ps[j].cursectnum); + + j = connectpoint2[j]; + + } + else deletesprite(i); + i = nexti; + } +} + END_DUKE_NS \ No newline at end of file diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index 5ca19b2fa..b4e10163b 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -44,7 +44,7 @@ void addtorch(int i); void addlightning(int i); -static int32_t g_whichPalForPlayer = 9; +extern int which_palookup; static uint8_t precachehightile[2][MAXTILES>>3]; static int32_t g_precacheCount; @@ -917,165 +917,7 @@ end_vol4a: display_mirror = 0; } -static void resetpspritevars(char gameMode) -{ - int16_t i, j; //circ; - - uint8_t aimmode[MAXPLAYERS],autoaim[MAXPLAYERS],weaponswitch[MAXPLAYERS]; - DukeStatus_t tsbar[MAXPLAYERS]; - - if (g_player[0].ps->cursectnum >= 0) // < 0 may happen if we start a map in void space (e.g. testing it) - { - A_InsertSprite(g_player[0].ps->cursectnum,g_player[0].ps->pos.x,g_player[0].ps->pos.y,g_player[0].ps->pos.z, - TILE_APLAYER,0,0,0,fix16_to_int(g_player[0].ps->q16ang),0,0,0,10); - } - - if (ud.recstat != 2) - for (TRAVERSE_CONNECT(i)) - { - aimmode[i] = g_player[i].ps->aim_mode; - autoaim[i] = g_player[i].ps->auto_aim; - weaponswitch[i] = g_player[i].ps->weaponswitch; - if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) - { - for (j=0; jammo_amount[j]; - - tsbar[i].gotweapon = g_player[i].ps->gotweapon; - Bmemcpy(tsbar[i].inv_amount, g_player[i].ps->inv_amount, sizeof(tsbar[i].inv_amount)); - tsbar[i].curr_weapon = g_player[i].ps->curr_weapon; - tsbar[i].inven_icon = g_player[i].ps->inven_icon; - } - } - - resetplayerstats(0); - - for (TRAVERSE_CONNECT(i)) - if (i) Bmemcpy(g_player[i].ps,g_player[0].ps,sizeof(DukePlayer_t)); - - if (ud.recstat != 2) - for (TRAVERSE_CONNECT(i)) - { - g_player[i].ps->aim_mode = aimmode[i]; - g_player[i].ps->auto_aim = autoaim[i]; - g_player[i].ps->weaponswitch = weaponswitch[i]; - if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) - { - for (j=0; jammo_amount[j] = tsbar[i].ammo_amount[j]; - - g_player[i].ps->gotweapon = tsbar[i].gotweapon; - g_player[i].ps->curr_weapon = tsbar[i].curr_weapon; - g_player[i].ps->inven_icon = tsbar[i].inven_icon; - Bmemcpy(g_player[i].ps->inv_amount, tsbar[i].inv_amount, sizeof(tsbar[i].inv_amount)); - } - } - - numplayersprites = 0; -// circ = 2048/ud.multimode; - - g_whichPalForPlayer = 9; - j = 0; - i = headspritestat[STAT_PLAYER]; - while (i >= 0) - { - const int32_t nexti = nextspritestat[i]; - spritetype *const s = &sprite[i]; - - if (numplayersprites == MAXPLAYERS) - G_GameExit("\nToo many player sprites (max 16.)"); - - g_playerSpawnPoints[numplayersprites].pos.x = s->x; - g_playerSpawnPoints[numplayersprites].pos.y = s->y; - g_playerSpawnPoints[numplayersprites].pos.z = s->z; - g_playerSpawnPoints[numplayersprites].ang = s->ang; - g_playerSpawnPoints[numplayersprites].sect = s->sectnum; - - numplayersprites++; - - if (j < MAXPLAYERS) - { - s->owner = i; - s->shade = 0; - s->xrepeat = RR ? 24 : 42; - s->yrepeat = RR ? 17 : 36; - //s->xrepeat = 42; - //s->yrepeat = 36; - if (!g_fakeMultiMode) - s->cstat = j < numplayers ? 1+256 : 32768; - else - s->cstat = j < ud.multimode ? 1+256 : 32768; - s->xoffset = 0; - s->clipdist = 64; - - if (j < g_mostConcurrentPlayers) - { - if ((gameMode&MODE_EOL) != MODE_EOL || g_player[j].ps->last_extra == 0) - { - g_player[j].ps->last_extra = max_player_health; - s->extra = max_player_health; - g_player[j].ps->runspeed = dukefriction; - } - else s->extra = g_player[j].ps->last_extra; - - s->yvel = j; - - if (!g_player[j].pcolor && (g_netServer || ud.multimode > 1) && !(g_gametypeFlags[ud.coop] & GAMETYPE_TDM)) - { - if (s->pal == 0) - { - int32_t k = 0; - - for (; kpalookup) - { - g_whichPalForPlayer++; - if (g_whichPalForPlayer >= 17) - g_whichPalForPlayer = 9; - k=0; - } - } - g_player[j].pcolor = s->pal = g_player[j].ps->palookup = g_whichPalForPlayer++; - if (g_whichPalForPlayer >= 17) - g_whichPalForPlayer = 9; - } - else g_player[j].pcolor = g_player[j].ps->palookup = s->pal; - } - else - { - int32_t k = g_player[j].pcolor; - - if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM) - { - k = G_GetTeamPalette(g_player[j].pteam); - g_player[j].ps->team = g_player[j].pteam; - } - s->pal = g_player[j].ps->palookup = k; - } - - g_player[j].ps->i = i; - g_player[j].ps->frag_ps = j; - actor[i].owner = i; - - g_player[j].ps->autostep = (20L<<8); - g_player[j].ps->autostep_sbw = (4L<<8); - - actor[i].bpos.x = g_player[j].ps->bobpos.x = g_player[j].ps->opos.x = g_player[j].ps->pos.x = s->x; - actor[i].bpos.y = g_player[j].ps->bobpos.y = g_player[j].ps->opos.y = g_player[j].ps->pos.y = s->y; - actor[i].bpos.z = g_player[j].ps->opos.z = g_player[j].ps->pos.z = s->z; - g_player[j].ps->oq16ang = g_player[j].ps->q16ang = fix16_from_int(s->ang); - - updatesector(s->x,s->y,&g_player[j].ps->cursectnum); - } - - j++; - } - else A_DeleteSprite(i); - - i = nexti; - } -} +void resetpspritevars(int gameMode); static inline void clearfrags(void) {