diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 70fad42ed..a63c88f4f 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -950,7 +950,59 @@ int parse(void) else { // I am not convinced this is even remotely smart to be executed from here... - P_ResetPlayer(g_p); + pickrandomspot(g_p); + g_sp->x = hittype[g_i].bposx = ps[g_p].bobposx = ps[g_p].oposx = ps[g_p].posx; + g_sp->y = hittype[g_i].bposy = ps[g_p].bobposy = ps[g_p].oposy = ps[g_p].posy; + g_sp->z = hittype[g_i].bposy = ps[g_p].oposz = ps[g_p].posz; + updatesector(ps[g_p].posx, ps[g_p].posy, &ps[g_p].cursectnum); + setsprite(ps[g_p].i, ps[g_p].posx, ps[g_p].posy, ps[g_p].posz + PHEIGHT); + g_sp->cstat = 257; + + g_sp->shade = -12; + g_sp->clipdist = 64; + g_sp->xrepeat = 42; + g_sp->yrepeat = 36; + g_sp->owner = g_i; + g_sp->xoffset = 0; + g_sp->pal = ps[g_p].palookup; + + ps[g_p].last_extra = g_sp->extra = max_player_health; + ps[g_p].wantweaponfire = -1; + ps[g_p].sethoriz(100); + ps[g_p].on_crane = -1; + ps[g_p].frag_ps = g_p; + ps[g_p].sethorizoff(0); + ps[g_p].opyoff = 0; + ps[g_p].wackedbyactor = -1; + ps[g_p].shield_amount = max_armour_amount; + ps[g_p].dead_flag = 0; + ps[g_p].pals.f = 0; + ps[g_p].footprintcount = 0; + ps[g_p].weapreccnt = 0; + ps[g_p].fta = 0; + ps[g_p].ftq = 0; + ps[g_p].posxv = ps[g_p].posyv = 0; + if (!isRR()) ps[g_p].rotscrnang = 0; + + ps[g_p].falling_counter = 0; + + hittype[g_i].extra = -1; + hittype[g_i].owner = g_i; + + hittype[g_i].cgg = 0; + hittype[g_i].movflag = 0; + hittype[g_i].tempang = 0; + hittype[g_i].actorstayput = -1; + hittype[g_i].dispicnum = 0; + hittype[g_i].owner = ps[g_p].i; + hittype[g_i].temp_data[4] = 0; + + resetinventory(g_p); + resetweapons(g_p); + ps[g_p].movement_lock = 0; + + //cameradist = 0; + //cameraclock = totalclock; } setpal(&ps[g_p]); break; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index ec7b8cdae..2dfb48d4d 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -37,7 +37,7 @@ BEGIN_DUKE_NS // //--------------------------------------------------------------------------- -void pickrandomspot(short snum) +void pickrandomspot(int snum) { struct player_struct *p; short i; diff --git a/source/games/duke/src/premap.h b/source/games/duke/src/premap.h index d1c5ead83..fe1c0e332 100644 --- a/source/games/duke/src/premap.h +++ b/source/games/duke/src/premap.h @@ -35,7 +35,7 @@ void G_CacheMapData(void); void G_NewGame(int volumeNum, int levelNum, int skillNum); void G_ResetTimers(uint8_t keepgtics); void G_UpdateScreenArea(void); -void P_RandomSpawnPoint(int playerNum); +void pickrandomspot(int playerNum); void resetinventory(int playerNum); void P_ResetPlayer(int playerNum); void resetplayerstats(int playerNum); diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index 392618464..5ca19b2fa 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -199,118 +199,11 @@ void G_UpdateScreenArea(void) pus = NUMPAGES; } -void P_RandomSpawnPoint(int playerNum) -{ - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - - int32_t i = playerNum; - - if ((g_netServer || ud.multimode > 1) && !(g_gametypeFlags[ud.coop] & GAMETYPE_FIXEDRESPAWN)) - { - i = krand2() % numplayersprites; - - if (g_gametypeFlags[ud.coop] & GAMETYPE_TDMSPAWN) - { - uint32_t pdist = -1; - for (bssize_t j=0; j<ud.multimode; j++) - { - if (j != playerNum && g_player[j].ps->team == pPlayer->team && sprite[g_player[j].ps->i].extra > 0) - { - for (bssize_t k=0; k<numplayersprites; k++) - { - uint32_t dist = FindDistance2D(g_player[j].ps->pos.x - g_playerSpawnPoints[k].pos.x, - g_player[j].ps->pos.y - g_playerSpawnPoints[k].pos.y); - - if (dist < pdist) - i = k, pdist = dist; - } - break; - } - } - } - } - - pPlayer->pos = g_playerSpawnPoints[i].pos; - pPlayer->opos = pPlayer->pos; - pPlayer->bobpos = *(vec2_t *)&pPlayer->pos; - pPlayer->q16ang = fix16_from_int(g_playerSpawnPoints[i].ang); - pPlayer->cursectnum = g_playerSpawnPoints[i].sect; - - sprite[pPlayer->i].cstat = 1 + 256; -} - static inline void P_ResetTintFade(DukePlayer_t *const pPlayer) { pPlayer->pals.f = 0; } -void P_ResetPlayer(int playerNum) -{ - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - spritetype *const pSprite = &sprite[pPlayer->i]; - vec3_t tmpvect = pPlayer->pos; - - tmpvect.z += PHEIGHT; - - P_RandomSpawnPoint(playerNum); - - pPlayer->opos = pPlayer->pos; - pPlayer->bobpos = *(vec2_t *)&pPlayer->pos; - actor[pPlayer->i].bpos = pPlayer->pos; - *(vec3_t *)pSprite = pPlayer->pos; - - updatesector(pPlayer->pos.x, pPlayer->pos.y, &pPlayer->cursectnum); - setsprite(pPlayer->i, &tmpvect); - - pSprite->cstat = 257; - pSprite->shade = -12; - pSprite->clipdist = RR ? 32 : 64; - pSprite->xrepeat = RR ? 24 : 42; - pSprite->yrepeat = RR ? 17 : 36; - pSprite->owner = pPlayer->i; - pSprite->xoffset = 0; - pSprite->pal = pPlayer->palookup; - - pPlayer->last_extra = pSprite->extra = max_player_health; - - pPlayer->wantweaponfire = -1; - pPlayer->q16horiz = F16(100); - pPlayer->on_crane = -1; - pPlayer->frag_ps = playerNum; - pPlayer->q16horizoff = 0; - pPlayer->opyoff = 0; - pPlayer->wackedbyactor = -1; - pPlayer->inv_amount[GET_SHIELD] = max_armour_amount; - pPlayer->dead_flag = 0; - pPlayer->footprintcount = 0; - pPlayer->weapreccnt = 0; - pPlayer->fta = 0; - pPlayer->ftq = 0; - pPlayer->vel.x = pPlayer->vel.y = 0; - if (!RR) pPlayer->rotscrnang = 0; - pPlayer->runspeed = dukefriction; - pPlayer->falling_counter = 0; - - P_ResetTintFade(pPlayer); - - actor[pPlayer->i].extra = -1; - actor[pPlayer->i].owner = pPlayer->i; - actor[pPlayer->i].cgg = 0; - actor[pPlayer->i].movflag = 0; - actor[pPlayer->i].tempang = 0; - actor[pPlayer->i].actorstayput = -1; - actor[pPlayer->i].dispicnum = 0; - actor[pPlayer->i].owner = pPlayer->i; - actor[pPlayer->i].t_data[4] = 0; - - resetinventory(playerNum); - resetweapons(playerNum); - - //pPlayer->reloading = 0; - pPlayer->movement_lock = 0; -} - - static inline int G_CheckExitSprite(int spriteNum) { return ((uint16_t)sprite[spriteNum].lotag == UINT16_MAX && (sprite[spriteNum].cstat & 16)); }