diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index 086ecf97d..9ca4ea961 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -18,6 +18,9 @@ set( PCH_SOURCES src/player_d.cpp src/player_r.cpp src/player_w.cpp + src/premap.cpp + src/premap_d.cpp + src/premap_r.cpp src/sectors.cpp src/sectors_d.cpp src/sectors_r.cpp @@ -30,7 +33,6 @@ set( PCH_SOURCES src/zz_cheats.cpp src/zz_cmdline.cpp src/zz_common.cpp - src/zz_config.cpp src/zz_d_menu.cpp src/zz_demo.cpp src/zz_game.cpp diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 83994c6de..2b98b426a 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -131,7 +131,7 @@ G_EXTERN int32_t g_maxPlayerHealth; G_EXTERN int32_t g_mirrorCount; G_EXTERN int32_t g_mostConcurrentPlayers; G_EXTERN int32_t g_musicSize; -G_EXTERN int32_t g_playerSpawnCnt; +G_EXTERN int32_t numplayersprites; G_EXTERN int32_t g_scriptDebug; G_EXTERN int32_t g_showShareware; G_EXTERN int32_t g_spriteDeleteQueuePos; diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index ecfce0caa..1d4cf879a 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -113,7 +113,11 @@ typedef struct { vec3_t pos; struct { int ox, oy, oz; }; }; - int16_t ang; + union + { + int16_t oa; + int16_t ang; + }; union { int16_t sect; @@ -189,6 +193,7 @@ typedef struct player_struct { void addhoriz(int v) { q16horiz += (v << FRACBITS); } void addhorizoff(int v) { q16horiz += (v << FRACBITS); } void sethoriz(int v) { q16horiz = (v << FRACBITS); } + void sethorizoff(int v) { q16horizoff = (v << FRACBITS); } int gethoriz() { return q16horiz >> FRACBITS; } int gethorizof() { return q16horizoff >> FRACBITS; } int gethorizsum() { return (q16horiz + q16horizoff) >> FRACBITS; } @@ -297,6 +302,9 @@ typedef struct player_struct { #define at57c detonate_time #define at58e drink_timer #define at592 eat_timer +#define raat5f1 drug_stat[0] +#define raat5f3 drug_stat[1] +#define raat5f5 drug_stat[2] // KEEPINSYNC lunatic/_defs_game.lua typedef struct diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp new file mode 100644 index 000000000..0b447d896 --- /dev/null +++ b/source/games/duke/src/premap.cpp @@ -0,0 +1,485 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2017-2019 Nuke.YKT + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- + +#include "ns.h" +#include "global.h" + +BEGIN_DUKE_NS + + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void pickrandomspot(short snum) +{ + struct player_struct *p; + short i; + + p = &ps[snum]; + + if( ud.multimode > 1 && ud.coop != 1) + i = krand()%numplayersprites; + else i = snum; + + p->bobposx = p->oposx = p->posx = po[i].ox; + p->bobposy = p->oposy = p->posy = po[i].oy; + p->oposz = p->posz = po[i].oz; + p->setang(po[i].oa); + p->cursectnum = po[i].os; +} + + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void resetplayerstats(int snum) +{ + struct player_struct *p; + + p = &ps[snum]; + + gFullMap = 0; + p->dead_flag = 0; + p->wackedbyactor = -1; + p->falling_counter = 0; + p->quick_kick = 0; + p->subweapon = 0; + p->last_full_weapon = 0; + p->ftq = 0; + p->fta = 0; + p->tipincs = 0; + p->buttonpalette = 0; + p->actorsqu =-1; + p->invdisptime = 0; + p->refresh_inventory= 0; + p->last_pissed_time = 0; + p->holster_weapon = 0; + p->pycount = 0; + p->pyoff = 0; + p->opyoff = 0; + p->loogcnt = 0; + //p->angvel = 0; + p->weapon_sway = 0; +// p->select_dir = 0; + p->extra_extra8 = 0; + p->show_empty_weapon= 0; + p->dummyplayersprite=-1; + p->crack_time = 0; + p->hbomb_hold_delay = 0; + p->transporter_hold = 0; + p->wantweaponfire = -1; + p->hurt_delay = 0; + p->hurt_delay2 = 0; + p->footprintcount = 0; + p->footprintpal = 0; + p->footprintshade = 0; + p->jumping_toggle = 0; + p->sethoriz(140); //!! + //p->oq16horiz = p->q16horiz; + p->sethorizoff(0); + p->bobcounter = 0; + p->on_ground = 0; + p->player_par = 0; + p->return_to_center = 9; + p->airleft = 15*26; + p->rapid_fire_hold = 0; + p->toggle_key_flag = 0; + p->access_spritenum = -1; + if(ud.multimode > 1 && ud.coop != 1 ) + p->got_access = 7; + else p->got_access = 0; + p->random_club_frame= 0; + pus = 1; + p->on_warping_sector = 0; + p->spritebridge = 0; + p->palette = 0; + + if(p->steroids_amount < 400 ) + { + p->steroids_amount = 0; + p->inven_icon = 0; + } + p->heat_on = 0; + p->jetpack_on = 0; + p->holoduke_on = -1; + + p->look_ang = 512 - ((ud.level_number&1)<<10); + + p->rotscrnang = 0; + p->orotscrnang = 1; // JBF 20031220 + p->newowner =-1; + p->jumping_counter = 0; + p->hard_landing = 0; + p->posxv = 0; //!! + p->posyv = 0; + p->poszv = 0; + p->fric.x = 0; + p->fric.y = 0; + p->somethingonplayer =-1; + p->one_eighty_count = 0; + p->cheat_phase = 0; + + p->on_crane = -1; + + if(p->curr_weapon == PISTOL_WEAPON) + p->kickback_pic = isRR()? 22 : 5; + else p->kickback_pic = 0; + + p->weapon_pos = 6; + p->walking_snd_toggle= 0; + p->weapon_ang = 0; + + p->knuckle_incs = 1; + p->fist_incs = 0; + p->knee_incs = 0; + setpal(p); + p->stairs = 0; + //p->fogtype = 0; + p->noise_x = 0; + p->noise_y = 0; + p->make_noise = 0; + p->noise_radius = 0; + if (isRR() && ud.multimode > 1 && ud.coop != 1) + { + p->keys[0] = 1; + p->keys[1] = 1; + p->keys[2] = 1; + p->keys[3] = 1; + p->keys[4] = 1; + } + else + { + p->keys[0] = 0; + p->keys[1] = 0; + p->keys[2] = 0; + p->keys[3] = 0; + p->keys[4] = 0; + } + wupass = 0; + //p->at582 = 0; + p->drunkang = 1647; + p->eatang = 1647; + p->drink_amt = 0; + p->eat = 0; + p->drink_timer = 4096; + p->eat_timer = 4096; + p->shotgun_state[0] = 0; + p->shotgun_state[1] = 0; + p->detonate_time = 0; + p->detonate_count = 0; + p->recoil = 0; + p->yehaa_timer = 0; + chickenphase = 0; + if (p->OnMotorcycle) + { + p->OnMotorcycle = 0; + p->gotweapon.Clear(MOTORCYCLE_WEAPON); + p->curr_weapon = isRRRA()? SLINGBLADE_WEAPON : KNEE_WEAPON; // just in case this is made available for the other games + } + p->lotag800kill = 0; + p->moto_do_bump = 0; + p->MotoOnGround = 1; + p->moto_underwater = 0; + p->MotoSpeed = 0; + p->TiltStatus = 0; + p->moto_drink = 0; + p->VBumpTarget = 0; + p->VBumpNow =0; + p->moto_bump_fast = 0; + p->TurbCount = 0; + p->moto_on_mud = 0; + p->moto_on_oil = 0; + if (p->OnBoat) + { + p->OnBoat = 0; + p->gotweapon.Clear(BOAT_WEAPON); + p->curr_weapon = isRRRA()? SLINGBLADE_WEAPON : KNEE_WEAPON; // just in case this is made available for the other games + } + p->NotOnWater = 0; + p->SeaSick = 0; + p->nocheat = 0; + p->DrugMode = 0; + p->drug_stat[0] = 0; + p->drug_stat[1] = 0; + p->drug_stat[2] = 0; + p->drug_aspect = 0; + resetlanepics(); + + if (numplayers < 2) + { + ufospawn = isRRRA()? 3 : std::min(ud.m_player_skill*4+1, 32); + ufocnt = 0; + hulkspawn = ud.m_player_skill + 1; + } + else + { + ufospawn = isRRRA()? 0 :32; + ufocnt = 0; + hulkspawn = isRRRA()? 0 :2; + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void resetweapons(int snum) +{ + short weapon; + struct player_struct *p; + + p = &ps[snum]; + + for ( weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++ ) + p->gotweapon.Clear(weapon); + for ( weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++ ) + p->ammo_amount[weapon] = 0; + + p->weapon_pos = 6; + p->kickback_pic = 5; + p->curr_weapon = PISTOL_WEAPON; + p->gotweapon.Set(PISTOL_WEAPON); + p->gotweapon.Set(KNEE_WEAPON); + p->ammo_amount[PISTOL_WEAPON] = 48; + p->gotweapon.Set(HANDREMOTE_WEAPON); + p->last_weapon = -1; + + p->show_empty_weapon= 0; + p->last_pissed_time = 0; + p->holster_weapon = 0; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void resetinventory(short snum) +{ + struct player_struct *p; + + p = &ps[snum]; + + p->inven_icon = 0; + p->boot_amount = 0; + p->scuba_on = 0;p->scuba_amount = 0; + p->heat_amount = 0;p->heat_on = 0; + p->jetpack_on = 0;p->jetpack_amount = 0; + p->shield_amount = max_armour_amount; + p->holoduke_on = -1; + p->holoduke_amount = 0; + p->firstaid_amount = 0; + p->steroids_amount = 0; + p->inven_icon = 0; + + if (ud.multimode > 1 && ud.coop != 1) + { + p->keys[0] = 1; + p->keys[1] = 1; + p->keys[2] = 1; + p->keys[3] = 1; + p->keys[4] = 1; + } + else + { + p->keys[0] = 0; + p->keys[1] = 0; + p->keys[2] = 0; + p->keys[3] = 0; + p->keys[4] = 0; + } + + p->drunkang = 1647; + p->eatang = 1647; + p->drink_amt = 0; + p->eat = 0; + p->drink_timer = 0; + p->eat_timer = 0; + p->shotgun_state[0] = 0; + p->shotgun_state[1] = 0; + p->detonate_time = 0; + p->detonate_count = 0; + p->recoil = 0; + p->yehaa_timer = 0; + resetlanepics(); + + if (numplayers < 2) + { + ufospawn = ud.m_player_skill*4+1; + if (ufospawn > 32) + ufospawn = 32; + ufocnt = 0; + hulkspawn = ud.m_player_skill + 1; + } + else + { + ufospawn = 32; + ufocnt = 0; + hulkspawn = 2; + } +} + + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void resetprestat(short snum,char g) +{ + struct player_struct *p; + short i; + + p = &ps[snum]; + + spriteqloc = 0; + for(i=0;ihbomb_on = 0; + p->cheat_phase = 0; + p->pals.f = 0; + p->toggle_key_flag = 0; + p->secret_rooms = 0; + p->max_secret_rooms = 0; + p->actors_killed = 0; + p->max_actors_killed = 0; + p->lastrandomspot = 0; + p->weapon_pos = 6; + p->kickback_pic = 5; + p->last_weapon = -1; + p->weapreccnt = 0; + p->show_empty_weapon= 0; + p->holster_weapon = 0; + p->last_pissed_time = 0; + + p->one_parallax_sectnum = -1; + p->visibility = ud.const_visibility; + + screenpeek = myconnectindex; + numanimwalls = 0; + numcyclers = 0; + animatecnt = 0; + parallaxtype = 0; + randomseed = 17L; + ud.pause_on = 0; + ud.camerasprite =-1; + ud.eog = 0; + tempwallptr = 0; + camsprite =-1; + earthquaketime = 0; + + WindTime = 0; + WindDir = 0; + fakebubba_spawn = 0; + RRRA_ExitedLevel = 0; + BellTime = 0; + g_bellSprite = 0; + + //numinterpolations = 0; + //startofdynamicinterpolations = 0; + + if( ( (g&MODE_EOL) != MODE_EOL && numplayers < 2) || (ud.coop != 1 && numplayers > 1) ) + { + resetweapons(snum); + resetinventory(snum); + } + else if(p->curr_weapon == HANDREMOTE_WEAPON) + { + p->ammo_amount[HANDBOMB_WEAPON]++; + p->curr_weapon = HANDBOMB_WEAPON; + } + + p->timebeforeexit = 0; + p->customexitsound = 0; + + p->stairs = 0; + //if (!isRRRA()) p->fogtype = 0; + p->noise_x = 131072; + p->noise_y = 131072; + p->make_noise = 0; + p->noise_radius = 0; + + if (ud.multimode > 1 && ud.coop != 1) + { + p->keys[0] = 1; + p->keys[1] = 1; + p->keys[2] = 1; + p->keys[3] = 1; + p->keys[4] = 1; + } + else + { + p->keys[0] = 0; + p->keys[1] = 0; + p->keys[2] = 0; + p->keys[3] = 0; + p->keys[4] = 0; + } + + p->drunkang = 1647; + p->eatang = 1647; + p->drink_amt = 0; + p->eat = 0; + p->drink_timer = 0; + p->eat_timer = 0; + p->shotgun_state[0] = 0; + p->shotgun_state[1] = 0; + p->detonate_time = 0; + p->detonate_count = 0; + p->recoil = 0; + p->yehaa_timer = 0; + resetlanepics(); + + if (numplayers < 2) + { + ufospawn = ud.m_player_skill*4+1; + if (ufospawn > 32) + ufospawn = 32; + ufocnt = 0; + hulkspawn = ud.m_player_skill + 1; + } + else + { + ufospawn = 32; + ufocnt = 0; + hulkspawn = 2; + } + +} + + +END_DUKE_NS \ No newline at end of file diff --git a/source/games/duke/src/premap.h b/source/games/duke/src/premap.h index a5cc7e332..59445edc5 100644 --- a/source/games/duke/src/premap.h +++ b/source/games/duke/src/premap.h @@ -38,7 +38,7 @@ void G_UpdateScreenArea(void); void P_RandomSpawnPoint(int playerNum); void P_ResetInventory(int playerNum); void P_ResetPlayer(int playerNum); -void P_ResetStatus(int playerNum); +void resetplayerstats(int playerNum); void P_ResetWeapons(int playerNum); void G_ClearFIFO(void); void G_ResetInterpolations(void); diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp new file mode 100644 index 000000000..7cd356d61 --- /dev/null +++ b/source/games/duke/src/premap_d.cpp @@ -0,0 +1,777 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: EDuke source was in transition. Changes are in-progress in the +source as it is released. + +*/ +//------------------------------------------------------------------------- + +#include "ns.h" +#include "global.h" +#include "build.h" +#include "names.h" + +BEGIN_DUKE_NS + +inline void tloadtile(int tilenum, int palnum = 0) +{ + markTileForPrecache(tilenum, palnum); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void cachespritenum(int i) +{ + int maxc; + int j; + int pal = sprite[i].pal; + + if(ud.monsters_off && badguy(&sprite[i])) return; + + maxc = 1; + + switch(sprite[i].picnum) + { + case HYDRENT: + tloadtile(BROKEFIREHYDRENT); + for(j = TOILETWATER; j < (TOILETWATER+4); j++) + tloadtile(j, pal); + break; + case TOILET: + tloadtile(TOILETBROKE); + for(j = TOILETWATER; j < (TOILETWATER+4); j++) + tloadtile(j, pal); + break; + case STALL: + tloadtile(STALLBROKE); + for(j = TOILETWATER; j < (TOILETWATER+4); j++) + tloadtile(j, pal); + break; + case RUBBERCAN: + maxc = 2; + break; + case TOILETWATER: + maxc = 4; + break; + case FEMPIC1: + maxc = 44; + break; + case LIZTROOP: + case LIZTROOPRUNNING: + case LIZTROOPSHOOT: + case LIZTROOPJETPACK: + case LIZTROOPONTOILET: + case LIZTROOPDUCKING: + for(j = LIZTROOP; j < (LIZTROOP+72); j++) + tloadtile(j, pal); + for(j=HEADJIB1;j 1) + { + maxc = 5; + for(j = 1420;j < 1420+106; j++) + tloadtile(j, pal); + } + break; + case ATOMICHEALTH: + maxc = 14; + break; + case DRONE: + maxc = 10; + break; + case EXPLODINGBARREL: + case SEENINE: + case OOZFILTER: + maxc = 3; + break; + case NUKEBARREL: + case CAMERA1: + maxc = 5; + break; + } + + for(j = sprite[i].picnum; j < (sprite[i].picnum+maxc); j++) + tloadtile(j, pal); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void cachegoodsprites(void) +{ + int i; + + if (ud.screen_size >= 8) + { + tloadtile(BOTTOMSTATUSBAR); + if (ud.multimode > 1) + { + tloadtile(FRAGBAR); + for (i = MINIFONT; i < MINIFONT + 63; i++) + tloadtile(i); + } + } + + tloadtile(VIEWSCREEN); + + for(i=FOOTPRINTS;i= 0) + tloadtile(wall[i].overpicnum, wall[i].pal); + } + + for (i = 0; i < numsectors; i++) + { + tloadtile(sector[i].floorpicnum, sector[i].floorpal); + tloadtile(sector[i].ceilingpicnum, sector[i].ceilingpal); + if (sector[i].ceilingpicnum == LA) + { + tloadtile(LA + 1); + tloadtile(LA + 2); + } + } + + j = headspritesect[i]; + while (j >= 0) + { + if (sprite[j].xrepeat != 0 && sprite[j].yrepeat != 0 && (sprite[j].cstat & 32768) == 0) + cachespritenum(j); + j = nextspritesect[j]; + } + + precacheMarkedTiles(); +} + +#if 0 +void resetweapons_w(int snum) +{ + resetweapons(snum); + OnEvent(EVENT_RESETWEAPONS, -1, snum, -1); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void prelevel(int g) +{ + short i, nexti, j, startwall, endwall, lotaglist; + short lotags[65]; + + + show2dsector.Zero(); + memset(show2dwall,0, sizeof(show2dwall)); + memset(show2dsprite,0, sizeof(show2dsprite)); + + resetprestat(0,g); + numclouds = 0; + + for(i=0;i sector[i].ceilingz) + sector[i].lotag |= 32768; + continue; + } + + if(sector[i].ceilingstat&1) + { + setupbackdrop(sector[i].ceilingpicnum); + + if(sector[i].ceilingpicnum == CLOUDYSKIES && numclouds < 127) + clouds[numclouds++] = i; + + if(ps[0].one_parallax_sectnum == -1) + ps[0].one_parallax_sectnum = i; + } + + if(sector[i].lotag == 32767) //Found a secret room + { + ps[0].max_secret_rooms++; + continue; + } + + if(sector[i].lotag == -1) + { + ps[0].exitx = wall[sector[i].wallptr].x; + ps[0].exity = wall[sector[i].wallptr].y; + continue; + } + } + + i = headspritestat[0]; + while(i >= 0) + { + nexti = nextspritestat[i]; + + LoadActor(i, -1, -1); + + if(sprite[i].lotag == -1 && (sprite[i].cstat&16) ) + { + ps[0].exitx = SX; + ps[0].exity = SY; + } + else switch(PN) + { + case GPSPEED: + sector[SECT].extra = SLT; + deletesprite(i); + break; + + case CYCLER: + if(numcyclers >= MAXCYCLERS) + gameexit("\nToo many cycling sectors."); + cyclers[numcyclers][0] = SECT; + cyclers[numcyclers][1] = SLT; + cyclers[numcyclers][2] = SS; + cyclers[numcyclers][3] = sector[SECT].floorshade; + cyclers[numcyclers][4] = SHT; + cyclers[numcyclers][5] = (SA == 1536); + numcyclers++; + deletesprite(i); + break; + } + i = nexti; + } + + for(i=0;i < MAXSPRITES;i++) + { + if(sprite[i].statnum < MAXSTATUS) + { + if(PN == SECTOREFFECTOR && SLT == 14) + continue; + spawn(-1,i); + } + } + + for(i=0;i < MAXSPRITES;i++) + if(sprite[i].statnum < MAXSTATUS) + { + if( PN == SECTOREFFECTOR && SLT == 14 ) + spawn(-1,i); + } + + lotaglist = 0; + + i = headspritestat[0]; + while(i >= 0) + { + switch(PN) + { + case DIPSWITCH: + case DIPSWITCH2: + case ACCESSSWITCH: + case PULLSWITCH: + case HANDSWITCH: + case SLOTDOOR: + case LIGHTSWITCH: + case SPACELIGHTSWITCH: + case SPACEDOORSWITCH: + case FRANKENSTINESWITCH: + case LIGHTSWITCH2: + case POWERSWITCH1: + case LOCKSWITCH1: + case POWERSWITCH2: + break; + case DIPSWITCH+1: + case DIPSWITCH2+1: + case PULLSWITCH+1: + case HANDSWITCH+1: + case SLOTDOOR+1: + case LIGHTSWITCH+1: + case SPACELIGHTSWITCH+1: + case SPACEDOORSWITCH+1: + case FRANKENSTINESWITCH+1: + case LIGHTSWITCH2+1: + case POWERSWITCH1+1: + case LOCKSWITCH1+1: + case POWERSWITCH2+1: + for(j=0;j 64) + gameexit("\nToo many switches (64 max)."); + + j = headspritestat[3]; + while(j >= 0) + { + if(sprite[j].lotag == 12 && sprite[j].hitag == SLT) + hittype[j].temp_data[0] = 1; + j = nextspritestat[j]; + } + } + break; + } + i = nextspritestat[i]; + } + + mirrorcnt = 0; + + for( i = 0; i < numwalls; i++ ) + { + walltype *wal; + wal = &wall[i]; + + if(wal->overpicnum == MIRROR && (wal->cstat&32) != 0) + { + j = wal->nextsector; + + if(mirrorcnt > 63) + gameexit("\nToo many mirrors (64 max.)"); + if ( (j >= 0) && sector[j].ceilingpicnum != MIRROR ) + { + sector[j].ceilingpicnum = MIRROR; + sector[j].floorpicnum = MIRROR; + mirrorwall[mirrorcnt] = i; + mirrorsector[mirrorcnt] = j; + mirrorcnt++; + continue; + } + } + + if(numanimwalls >= MAXANIMWALLS) + gameexit("\nToo many 'anim' walls (max 512.)"); + + animwall[numanimwalls].tag = 0; + animwall[numanimwalls].wallnum = 0; + + switch(wal->overpicnum) + { + case FANSHADOW: + case FANSPRITE: + wall->cstat |= 65; + animwall[numanimwalls].wallnum = i; + numanimwalls++; + break; + + case W_FORCEFIELD: + if(waloff[W_FORCEFIELD] == 0) + for(j=0;j<3;j++) + tloadtile(W_FORCEFIELD+j); + case W_FORCEFIELD+1: + case W_FORCEFIELD+2: + if(wal->shade > 31) + wal->cstat = 0; + else wal->cstat |= 85+256; + + + if(wal->lotag && wal->nextwall >= 0) + wall[wal->nextwall].lotag = + wal->lotag; + + case BIGFORCE: + + animwall[numanimwalls].wallnum = i; + numanimwalls++; + + continue; + } + + wal->extra = -1; + + switch(wal->picnum) + { + case WATERTILE2: + for(j=0;j<3;j++) + if(waloff[wal->picnum+j] == 0) + tloadtile(wal->picnum+j); + break; + + case TECHLIGHT2: + case TECHLIGHT4: + if(waloff[wal->picnum] == 0) + tloadtile(wal->picnum); + break; + case W_TECHWALL1: + case W_TECHWALL2: + case W_TECHWALL3: + case W_TECHWALL4: + animwall[numanimwalls].wallnum = i; +// animwall[numanimwalls].tag = -1; + numanimwalls++; + break; + case SCREENBREAK6: + case SCREENBREAK7: + case SCREENBREAK8: + if(waloff[SCREENBREAK6] == 0) + for(j=SCREENBREAK6;jextra = wal->picnum; + animwall[numanimwalls].tag = -1; + if(ud.lockout) + { + if(wal->picnum == FEMPIC1) + wal->picnum = BLANKSCREEN; + else wal->picnum = SCREENBREAK6; + } + + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = wal->picnum; + numanimwalls++; + break; + + case SCREENBREAK1: + case SCREENBREAK2: + case SCREENBREAK3: + case SCREENBREAK4: + case SCREENBREAK5: + + case SCREENBREAK9: + case SCREENBREAK10: + case SCREENBREAK11: + case SCREENBREAK12: + case SCREENBREAK13: + case SCREENBREAK14: + case SCREENBREAK15: + case SCREENBREAK16: + case SCREENBREAK17: + case SCREENBREAK18: + case SCREENBREAK19: + + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = wal->picnum; + numanimwalls++; + break; + } + } + + //Invalidate textures in sector behind mirror + for(i=0;i=0;i=connectpoint2[i]) + switch(sector[sprite[ps[i].i].sectnum].floorpicnum) + { + case HURTRAIL: + case FLOORSLIME: + case FLOORPLASMA: + resetweapons(i); + resetinventory(i); + ps[i].gotweapon[PISTOL_WEAPON] = 0; + ps[i].ammo_amount[PISTOL_WEAPON] = 0; + ps[i].curr_weapon = KNEE_WEAPON; + ps[i].kickback_pic = 0; + break; + } + + //PREMAP.C - replace near the my's at the end of the file + + resetmys(); + + ps[myconnectindex].palette = palette; + palto(0,0,0,0); + + setpal(&ps[myconnectindex]); + flushperms(); + + everyothertime = 0; + global_random = 0; + + ud.last_level = ud.level_number+1; + + clearfifo(); + + for(i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; + + restorepalette = 1; + + flushpackets(); + waitforeverybody(); + + palto(0,0,0,0); + vscrn(); + clearview(0L); + drawbackground(); + displayrooms(myconnectindex,65536); + + clearbufbyte(playerquitflag,MAXPLAYERS,0x01010101); + ps[myconnectindex].over_shoulder_on = 0; + + clearfrags(); + + resettimevars(); // Here we go +} +#endif + +END_DUKE_NS \ No newline at end of file diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp new file mode 100644 index 000000000..b66bfcb11 --- /dev/null +++ b/source/games/duke/src/premap_r.cpp @@ -0,0 +1,1191 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2017-2019 Nuke.YKT + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- + +#include "ns.h" +#include "global.h" +#include "names_rr.h" + +BEGIN_DUKE_NS + +static inline void tloadtile(int tilenum, int palnum = 0) +{ + markTileForPrecache(tilenum, palnum); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void cachespritenum(short i) +{ + char maxc; + short j; + int pal = sprite[i].pal; + + if (ud.monsters_off && badguy(&sprite[i])) return; + + maxc = 1; + + switch (sprite[i].picnum) + { + case HYDRENT: + tloadtile(BROKEFIREHYDRENT); + for (j = TOILETWATER; j < (TOILETWATER + 4); j++) + tloadtile(j, pal); + break; + case RRTILE2121: + case RRTILE2122: + tloadtile(j, pal); + break; + case TOILET: + tloadtile(TOILETBROKE); + for (j = TOILETWATER; j < (TOILETWATER + 4); j++) + tloadtile(j, pal); + break; + case STALL: + tloadtile(STALLBROKE); + for (j = TOILETWATER; j < (TOILETWATER + 4); j++) + tloadtile(j, pal); + break; + case FORCERIPPLE: + maxc = 9; + break; + case RUBBERCAN: + maxc = 2; + break; + case TOILETWATER: + maxc = 4; + break; + case BUBBASTAND: + for (j = BUBBASCRATCH; j <= (BUBBASCRATCH + 47); j++) + tloadtile(j, pal); + maxc = 0; + break; + case SBSWIPE: + if (isRRRA()) + for (j = SBSWIPE; j <= (SBSWIPE + 29); j++) + tloadtile(j, pal); + maxc = 0; + break; + + case COOT: + for (j = COOT; j <= (COOT + 217); j++) + tloadtile(j, pal); + for (j = COOTJIBA; j < COOTJIBC + 4; j++) + tloadtile(j, pal); + maxc = 0; + break; + case LTH: + maxc = 105; + for (j = LTH; j < (LTH + maxc); j++) + tloadtile(j, pal); + maxc = 0; + break; + case BILLYRAY: + maxc = 144; + for (j = BILLYWALK; j < (BILLYWALK + maxc); j++) + tloadtile(j, pal); + for (j = BILLYJIBA; j <= BILLYJIBB + 4; j++) + tloadtile(j, pal); + maxc = 0; + break; + case COW: + maxc = 56; + for (j = sprite[i].picnum; j < (sprite[i].picnum + maxc); j++) + tloadtile(j, pal); + maxc = 0; + break; + case DOGRUN: + for (j = DOGATTACK; j <= DOGATTACK + 35; j++) + tloadtile(j, pal); + for (j = DOGRUN; j <= DOGRUN + 80; j++) + tloadtile(j, pal); + maxc = 0; + break; + case RABBIT: + if (isRRRA()) + { + for (j = RABBIT; j <= RABBIT + 54; j++) + tloadtile(j, pal); + for (j = RABBIT + 56; j <= RABBIT + 56 + 49; j++) + tloadtile(j, pal); + for (j = RABBIT + 56; j <= RABBIT + 56 + 49; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case BIKERB: + case BIKERBV2: + if (isRRRA()) + { + for (j = BIKERB; j <= BIKERB + 104; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case BIKER: + if (isRRRA()) + { + for (j = BIKER; j <= BIKER + 116; j++) + tloadtile(j, pal); + for (j = BIKER + 150; j <= BIKER + 150 + 104; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case CHEER: + if (isRRRA()) + { + for (j = CHEER; j <= CHEER + 44; j++) + tloadtile(j, pal); + for (j = CHEER + 47; j <= CHEER + 47 + 211; j++) + tloadtile(j, pal); + for (j = CHEER + 262; j <= CHEER + 262 + 72; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case CHEERB: + if (isRRRA()) + { + for (j = CHEERB; j <= CHEERB + 83; j++) + tloadtile(j, pal); + for (j = CHEERB + 157; j <= CHEERB + 157 + 83; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case MAMA: + if (isRRRA()) + { + for (j = MAMA; j <= MAMA + 78; j++) + tloadtile(j, pal); + for (j = MAMA + 80; j <= MAMA + 80 + 7; j++) + tloadtile(j, pal); + for (j = MAMA + 90; j <= MAMA + 90 + 94; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case CHEERBOAT: + if (isRRRA()) + { + tloadtile(CHEERBOAT); + maxc = 0; + } + break; + case HULKBOAT: + if (isRRRA()) + { + tloadtile(HULKBOAT); + maxc = 0; + } + break; + case MINIONBOAT: + if (isRRRA()) + { + tloadtile(MINIONBOAT); + maxc = 0; + } + break; + case BILLYPLAY: + if (isRRRA()) + { + for (j = BILLYPLAY; j <= BILLYPLAY + 2; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case COOTPLAY: + if (isRRRA()) + { + for (j = COOTPLAY; j <= COOTPLAY + 4; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case PIG: + case PIGSTAYPUT: + maxc = 68; + break; + case TORNADO: + maxc = 7; + break; + case HEN: + case HENSTAND: + maxc = 34; + break; + case APLAYER: + maxc = 0; + if (ud.multimode > 1) + { + maxc = 5; + for (j = APLAYER; j < APLAYER + 220; j++) + tloadtile(j, pal); + for (j = DUKEGUN; j < DUKELEG + 4; j++) + tloadtile(j, pal); + } + break; + case ATOMICHEALTH: + maxc = 14; + break; + case DRONE: + maxc = 6; + break; + case EXPLODINGBARREL: + case SEENINE: + case OOZFILTER: + maxc = 3; + break; + case NUKEBARREL: + case CAMERA1: + maxc = 5; + break; + case VIXEN: + maxc = 214; + for (j = sprite[i].picnum; j < sprite[i].picnum + maxc; j++) + tloadtile(j, pal); + maxc = 0; + break; + case SBMOVE: + if (!isRRRA()) + { + + maxc = 54; + for (j = sprite[i].picnum; j < sprite[i].picnum + maxc; j++) + tloadtile(j, pal); + maxc = 100; + for (j = SBMOVE; j < SBMOVE + maxc; j++) + tloadtile(j, pal); + maxc = 0; + } + break; + case HULK: + maxc = 40; + for (j = sprite[i].picnum - 41; j < sprite[i].picnum + maxc - 41; j++) + tloadtile(j, pal); + for (j = HULKJIBA; j <= HULKJIBC + 4; j++) + tloadtile(j, pal); + maxc = 0; + break; + case MINION: + maxc = 141; + for (j = sprite[i].picnum; j < sprite[i].picnum + maxc; j++) + tloadtile(j, pal); + for (j = MINJIBA; j <= MINJIBC + 4; j++) + tloadtile(j, pal); + maxc = 0; + break; + + + } + + for (j = sprite[i].picnum; j < (sprite[i].picnum + maxc); j++) + tloadtile(j, pal); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void cachegoodsprites(void) +{ + short i; + + if (ud.screen_size >= 8) + { + tloadtile(BOTTOMSTATUSBAR); + if (ud.multimode > 1) + { + tloadtile(FRAGBAR); + } + } + + //tloadtile(VIEWSCREEN); + + for (i = FOOTPRINTS; i < FOOTPRINTS + 3; i++) + tloadtile(i); + + for (i = BURNING; i < BURNING + 14; i++) + tloadtile(i); + + for (i = FIRSTGUN; i < FIRSTGUN + 10; i++) + tloadtile(i); + + for (i = EXPLOSION2; i < EXPLOSION2 + 21; i++) + tloadtile(i); + + tloadtile(BULLETHOLE); + + for (i = SHOTGUN; i < SHOTGUN + 8; i++) + tloadtile(i); + + tloadtile(FOOTPRINTS); + + for (i = JIBS1; i < (JIBS5 + 5); i++) + tloadtile(i); + + for (i = SCRAP1; i < (SCRAP1 + 19); i++) + tloadtile(i); + + for (i = SMALLSMOKE; i < (SMALLSMOKE + 4); i++) + tloadtile(i); + + if (isRRRA() && ud.volume_number == 0 && ud.level_number == 4) + { + tloadtile(RRTILE2577); + } + if (!isRRRA() && ud.volume_number == 1 && ud.level_number == 2) + { + tloadtile(RRTILE3190); + tloadtile(RRTILE3191); + tloadtile(RRTILE3192); + tloadtile(RRTILE3144); + tloadtile(RRTILE3139); + tloadtile(RRTILE3132); + tloadtile(RRTILE3120); + tloadtile(RRTILE3121); + tloadtile(RRTILE3122); + tloadtile(RRTILE3123); + tloadtile(RRTILE3124); + } + if (lastlevel) + { + i = isRRRA() ? UFO1_RRRA : UFO1_RR; + tloadtile(i); + i = UFO2; + tloadtile(i); + i = UFO3; + tloadtile(i); + i = UFO4; + tloadtile(i); + i = UFO5; + tloadtile(i); + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void cacheit(void) +{ + short i,j; + + cachegoodsprites(); + + for(i=0;i= 0) + tloadtile(wall[i].overpicnum, wall[i].pal); + } + + for (i = 0; i < numsectors; i++) + { + tloadtile(sector[i].floorpicnum, sector[i].floorpal); + tloadtile(sector[i].ceilingpicnum, sector[i].ceilingpal); + if (sector[i].ceilingpicnum == LA) + { + tloadtile(LA + 1); + tloadtile(LA + 2); + } + } + + j = headspritesect[i]; + while(j >= 0) + { + if(sprite[j].xrepeat != 0 && sprite[j].yrepeat != 0 && (sprite[j].cstat&32768) == 0) + cachespritenum(j); + j = nextspritesect[j]; + } + precacheMarkedTiles(); +} + +#if 0 +void resetweapons_r(int snum) +{ + resetweapons(snum); + if (isRRRA()) + { + auto p = &ps[snum]; + p->chickenphase = 0; + p->ammo_amount[KNEE_WEAPON] = 1; + p->gotweapon[SLINGBLADE_WEAPON] = 1; + p->ammo_amount[SLINGBLADE_WEAPON] = 1; + p->OnMotorcycle = 0; + p->moto_underwater = 0; + p->OnBoat = 0; + p->MamaEnd = 0; + } +} +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void prelevel(char g) +{ + struct player_struct* p; + short i; + short nexti; + short j; + short startwall; + short endwall; + short lotaglist; + short k; + short lotags[65]; + int speed; + int dist; + short sound; + sound = 0; + + p = &ps[screenpeek]; + + +#ifdef RRRA + sub_86730(0); + p->fogtype = 0; + p->raat5dd = 0; + p->raat5fd = 0; + p->raat601 = 0; + p->SlotWin = 0; + p->raat607 = 0; + p->raat609 = 0; + mamaspawn_count = 15; + word_119BDC = 0; + word_119BE2 = 0; + if (ud.level_number == 3 && ud.volume_number == 0) + mamaspawn_count = 5; + else if (ud.level_number == 2 && ud.volume_number == 1) + mamaspawn_count = 10; + else if (ud.level_number == 6 && ud.volume_number == 1) + mamaspawn_count = 15; + else if (ud.level_number == 4 && ud.volume_number == 1) + ps[myconnectindex].steroids_amount = 0; +#endif + + clearbufbyte(show2dsector, sizeof(show2dsector), 0L); + clearbufbyte(show2dwall, sizeof(show2dwall), 0L); + clearbufbyte(show2dsprite, sizeof(show2dsprite), 0L); + + for (i = 0; i < MAXSECTORS; i++) + shadedsector[i] = 0; + + for (i = 0; i < 64; i++) + { + geosectorwarp[i] = -1; + geosectorwarp2[i] = -1; + } + + for (i = 0; i < 64; i++) + { + ambienthitag[i] = -1; + ambientlotag[i] = -1; + ambientsprite[i] = -1; + } + + resetprestat(0, g); + lightnincnt = 0; + torchcnt = 0; + geocnt = 0; + jaildoorcnt = 0; + minecartcnt = 0; + ambientfx = 0; + crashcnt = 0; + thunderon = 0; + chickenplant = 0; +#ifdef RRRA + WindTime = 0; + WindDir = 0; + fakebubba_spawn = 0; + word_119BE2 = 0; + mamaspawn_count = 15; + BellTime = 0; + word_119BE0 = 0; + + for (j = 0; j < MAXSPRITES; j++) + { + if (sprite[j].pal == 100) + { + if (numplayers > 1) + deletesprite(j); + else + sprite[j].pal = 0; + } + else if (sprite[j].pal == 101) + { + sprite[j].extra = 0; + sprite[j].hitag = 1; + sprite[j].pal = 0; + changespritestat(j, 118); + } + } +#endif + + for (i = 0; i < numsectors; i++) + { + if (sector[i].ceilingpicnum == RRTILE2577) + thunderon = 1; + sector[i].extra = 256; + + switch (sector[i].lotag) + { + case 41: + k = headspritesect[i]; + while (k != -1) + { + nexti = nextspritesect[k]; + if (sprite[k].picnum == RRTILE11) + { + dist = sprite[k].lotag << 4; + speed = sprite[k].hitag; + deletesprite(k); + } + if (sprite[k].picnum == RRTILE38) + { + sound = sprite[k].lotag; + deletesprite(k); + } + k = nexti; + } + for (j = 0; j < numsectors; j++) + { + if (sector[i].hitag == sector[j].hitag && j != i) + { + if (jaildoorcnt > 32) + gameexit("\nToo many jaildoor sectors"); + jaildoordist[jaildoorcnt] = dist; + jaildoorspeed[jaildoorcnt] = speed; + jaildoorsecthtag[jaildoorcnt] = sector[i].hitag; + jaildoorsect[jaildoorcnt] = j; + jaildoordrag[jaildoorcnt] = 0; + jaildooropen[jaildoorcnt] = 0; + jaildoordir[jaildoorcnt] = sector[j].lotag; + jaildoorsound[jaildoorcnt] = sound; + jaildoorcnt++; + } + } + break; + case 42: + { + short ii; + k = headspritesect[i]; + while (k != -1) + { + nexti = nextspritesect[k]; + if (sprite[k].picnum == RRTILE64) + { + dist = sprite[k].lotag << 4; + speed = sprite[k].hitag; + for (ii = 0; ii < MAXSPRITES; ii++) + { + if (sprite[ii].picnum == RRTILE66) + if (sprite[ii].lotag == sprite[k].sectnum) + { + minecartchildsect[minecartcnt] = sprite[ii].sectnum; + deletesprite(ii); + } + } + deletesprite(k); + } + if (sprite[k].picnum == RRTILE65) + { + sound = sprite[k].lotag; + deletesprite(k); + } + k = nexti; + } + if (minecartcnt > 16) + gameexit("\nToo many minecart sectors"); + minecartdist[minecartcnt] = dist; + minecartspeed[minecartcnt] = speed; + minecartsect[minecartcnt] = i; + minecartdir[minecartcnt] = sector[i].hitag; + minecartdrag[minecartcnt] = dist; + minecartopen[minecartcnt] = 1; + minecartsound[minecartcnt] = sound; + minecartcnt++; + break; + } + case 20: + case 22: + if (sector[i].floorz > sector[i].ceilingz) + sector[i].lotag |= 32768; + continue; + } + + if (sector[i].ceilingstat & 1) + { + if (waloff[sector[i].ceilingpicnum] == 0) + { + if (sector[i].ceilingpicnum == LA) + for (j = 0; j < 5; j++) + if (waloff[sector[i].ceilingpicnum + j] == 0) + tloadtile(sector[i].ceilingpicnum + j); + } + setupbackdrop(sector[i].ceilingpicnum); + + if (ps[0].one_parallax_sectnum == -1) + ps[0].one_parallax_sectnum = i; + } + + if (sector[i].lotag == 32767) //Found a secret room + { + ps[0].max_secret_rooms++; + continue; + } + + if (sector[i].lotag == -1) + { + ps[0].exitx = wall[sector[i].wallptr].x; + ps[0].exity = wall[sector[i].wallptr].y; + continue; + } + } + + i = headspritestat[0]; + while (i >= 0) + { + nexti = nextspritestat[i]; + + if (sprite[i].lotag == -1 && (sprite[i].cstat & 16)) + { + ps[0].exitx = SX; + ps[0].exity = SY; + } + else switch (sprite[i].picnum) + { + case NUKEBUTTON: + chickenplant = 1; + break; + + case GPSPEED: + sector[SECT].extra = SLT; + deletesprite(i); + break; + + case CYCLER: + if (numcyclers >= MAXCYCLERS) + gameexit("\nToo many cycling sectors."); + cyclers[numcyclers][0] = SECT; + cyclers[numcyclers][1] = SLT; + cyclers[numcyclers][2] = SS; + cyclers[numcyclers][3] = sector[SECT].floorshade; + cyclers[numcyclers][4] = SHT; + cyclers[numcyclers][5] = (SA == 1536); + numcyclers++; + deletesprite(i); + break; + + case RRTILE18: + if (torchcnt > 64) + gameexit("\nToo many torch effects"); + torchsector[torchcnt] = SECT; + torchsectorshade[torchcnt] = sector[SECT].floorshade; + torchtype[torchcnt] = SLT; + torchcnt++; + deletesprite(i); + break; + + case RRTILE35: + if (lightnincnt > 64) + gameexit("\nToo many lightnin effects"); + lightninsector[lightnincnt] = SECT; + lightninsectorshade[lightnincnt] = sector[SECT].floorshade; + lightnincnt++; + deletesprite(i); + break; + + case RRTILE68: + shadedsector[SECT] = 1; + deletesprite(i); + break; + + case RRTILE67: + sprite[i].cstat |= 32768; + break; + + case SOUNDFX: + if (ambientfx >= 64) + gameexit("\nToo many ambient effects"); + else + { + ambienthitag[ambientfx] = SHT; + ambientlotag[ambientfx] = SLT; + ambientsprite[ambientfx] = i; + sprite[i].ang = ambientfx; + ambientfx++; + sprite[i].lotag = 0; + sprite[i].hitag = 0; + } + break; + } + i = nexti; + } + + for (i = 0; i < MAXSPRITES; i++) + { + if (sprite[i].picnum == RRTILE19) + { + if (geocnt > 64) + gameexit("\nToo many geometry effects"); + if (sprite[i].hitag == 0) + { + geosector[geocnt] = sprite[i].sectnum; + for (j = 0; j < MAXSPRITES; j++) + { + if (sprite[i].lotag == sprite[j].lotag && j != i && sprite[j].picnum == RRTILE19) + { + if (sprite[j].hitag == 1) + { + geosectorwarp[geocnt] = sprite[j].sectnum; + geox[geocnt] = sprite[i].x - sprite[j].x; + geoy[geocnt] = sprite[i].y - sprite[j].y; + geoz[geocnt] = sprite[i].z - sprite[j].z; + } + if (sprite[j].hitag == 2) + { + geosectorwarp2[geocnt] = sprite[j].sectnum; + geox2[geocnt] = sprite[i].x - sprite[j].x; + geoy2[geocnt] = sprite[i].y - sprite[j].y; + geoz2[geocnt] = sprite[i].z - sprite[j].z; + } + } + } + geocnt++; + } + } + } + + for (i = 0; i < MAXSPRITES; i++) + { + if (sprite[i].statnum < MAXSTATUS) + { + if (sprite[i].picnum == SECTOREFFECTOR && SLT == 14) + continue; + spawn(-1, i); + } + } + + for (i = 0; i < MAXSPRITES; i++) + { + if (sprite[i].statnum < MAXSTATUS) + { + if (sprite[i].picnum == SECTOREFFECTOR && SLT == 14) + spawn(-1, i); + } + if (sprite[i].picnum == RRTILE19) + deletesprite(i); + if (sprite[i].picnum == RRTILE34) + { + sector[sprite[i].sectnum].filler = sprite[i].lotag; + deletesprite(i); + } + } + + lotaglist = 0; + + i = headspritestat[0]; + while (i >= 0) + { + switch (sprite[i].picnum) + { + case DIPSWITCH: + case DIPSWITCH2: + case ACCESSSWITCH: + case PULLSWITCH: + case HANDSWITCH: + case SLOTDOOR: + case LIGHTSWITCH: + case SPACELIGHTSWITCH: + case SPACEDOORSWITCH: + case FRANKENSTINESWITCH: + case LIGHTSWITCH2: + case POWERSWITCH1: + case LOCKSWITCH1: + case POWERSWITCH2: +#ifdef RRRA + case RRTILE8464: +#endif + break; + case DIPSWITCH + 1: + case DIPSWITCH2 + 1: + case PULLSWITCH + 1: + case HANDSWITCH + 1: + case SLOTDOOR + 1: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH + 1: + case FRANKENSTINESWITCH + 1: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2 + 1: + case NUKEBUTTON: + case NUKEBUTTON + 1: +#ifdef RRRA + case RRTILE8464 + 1: +#endif + for (j = 0; j < lotaglist; j++) + if (SLT == lotags[j]) + break; + + if (j == lotaglist) + { + lotags[lotaglist] = SLT; + lotaglist++; + if (lotaglist > 64) + gameexit("\nToo many switches (64 max)."); + + j = headspritestat[3]; + while (j >= 0) + { + if (sprite[j].lotag == 12 && sprite[j].hitag == SLT) + hittype[j].temp_data[0] = 1; + j = nextspritestat[j]; + } + } + break; + } + i = nextspritestat[i]; + } + + mirrorcnt = 0; + + for (i = 0; i < numwalls; i++) + { + walltype* wal; + wal = &wall[i]; + + if (wal->overpicnum == MIRROR && (wal->cstat & 32) != 0) + { + j = wal->nextsector; + + if (mirrorcnt > 63) + gameexit("\nToo many mirrors (64 max.)"); + if ((j >= 0) && sector[j].ceilingpicnum != MIRROR) + { + sector[j].ceilingpicnum = MIRROR; + sector[j].floorpicnum = MIRROR; + mirrorwall[mirrorcnt] = i; + mirrorsector[mirrorcnt] = j; + mirrorcnt++; + continue; + } + } + + if (numanimwalls >= MAXANIMWALLS) + gameexit("\nToo many 'anim' walls (max 512.)"); + + animwall[numanimwalls].tag = 0; + animwall[numanimwalls].wallnum = 0; + + switch (wal->overpicnum) + { + case FANSPRITE: + wall->cstat |= 65; + animwall[numanimwalls].wallnum = i; + numanimwalls++; + break; + case BIGFORCE: + animwall[numanimwalls].wallnum = i; + numanimwalls++; + continue; + } + + wal->extra = -1; + + switch (wal->picnum) + { + case WATERTILE2: + for (j = 0; j < 3; j++) + if (waloff[wal->picnum + j] == 0) + tloadtile(wal->picnum + j); + break; + + case RRTILE1814: + case RRTILE1817: + if (waloff[wal->picnum] == 0) + tloadtile(wal->picnum); + break; + case RRTILE1939: + case RRTILE1986: + case RRTILE1987: + case RRTILE1988: + case RRTILE2004: + case RRTILE2005: + case RRTILE2123: + case RRTILE2124: + case RRTILE2125: + case RRTILE2126: + case RRTILE2636: + case RRTILE2637: + case RRTILE2878: + case RRTILE2879: + case RRTILE2898: + case RRTILE2899: + if (waloff[wal->picnum] == 0) + tloadtile(wal->picnum); + break; + case TECHLIGHT2: + case TECHLIGHT4: + if (waloff[wal->picnum] == 0) + tloadtile(wal->picnum); + break; + case SCREENBREAK6: + case SCREENBREAK7: + case SCREENBREAK8: + if (waloff[SCREENBREAK6] == 0) + for (j = SCREENBREAK6; j <= SCREENBREAK8; j++) + tloadtile(j, pal); + animwall[numanimwalls].wallnum = i; + animwall[numanimwalls].tag = -1; + numanimwalls++; + break; + } + } + + //Invalidate textures in sector behind mirror + for (i = 0; i < mirrorcnt; i++) + { + startwall = sector[mirrorsector[i]].wallptr; + endwall = startwall + sector[mirrorsector[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + wall[j].picnum = MIRROR; + wall[j].overpicnum = MIRROR; + } + } + if (!thunderon) + { + char brightness = ud.brightness >> 2; + setbrightness(brightness, palette); + visibility = p->visibility; + } + tilesizx[0] = tilesizy[0] = 0; +} + + + + +#if 0 +void enterlevel(char g) +{ + short i, j; + long l; + char levname[256]; + + if ((g & MODE_DEMO) != MODE_DEMO) ud.recstat = ud.m_recstat; + ud.respawn_monsters = ud.m_respawn_monsters; + ud.respawn_items = ud.m_respawn_items; + ud.respawn_inventory = ud.m_respawn_inventory; + ud.monsters_off = ud.m_monsters_off; + ud.coop = ud.m_coop; + ud.marker = ud.m_marker; + ud.ffire = ud.m_ffire; + + if ((g & MODE_DEMO) == 0 && ud.recstat == 2) + ud.recstat = 0; + + i = ud.screen_size; + ud.screen_size = 0; + dofrontscreens(); + vscrn(); + ud.screen_size = i; + + if (lastlevel) + { + if (loadboard("endgame.map", &ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang, &ps[0].cursectnum) == -1) + { + sprintf(tempbuf, "Map %s not found!", boardfilename); + gameexit(tempbuf); + } + } + else + { + if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) + { + if (loadboard(boardfilename, &ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang, &ps[0].cursectnum) == -1) + { + sprintf(tempbuf, "Map %s not found!", boardfilename); + gameexit(tempbuf); + } + } + else if (loadboard(level_file_names[(ud.volume_number * 7) + ud.level_number], &ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang, &ps[0].cursectnum) == -1) + { + sprintf(tempbuf, "Map %s not found!", level_file_names[(ud.volume_number * 8) + ud.level_number]); + gameexit(tempbuf); + } + } + +} +#endif + + +void loadlevel(const char *filename) + + +#ifndef RRRA + if (ud.volume_number == 1 && ud.level_number == 1) + { + short ii; + for (ii = PISTOL_WEAPON; ii < MAX_WEAPONS; ii++) + ps[0].gotweapon[ii] = 0; + for (ii = PISTOL_WEAPON; ii < MAX_WEAPONS; ii++) + ps[0].ammo_amount[ii] = 0; + } +#endif + + clearbufbyte(gotpic,sizeof(gotpic),0L); + + prelevel(g); + +#ifdef RRRA + if (ud.level_number == 2 && ud.volume_number == 0) + { + short ii; + for (ii = PISTOL_WEAPON; ii < MAX_WEAPONS; ii++) + ps[0].gotweapon[ii] = 0; + for (ii = PISTOL_WEAPON; ii < MAX_WEAPONS; ii++) + ps[0].ammo_amount[ii] = 0; + ps[0].gotweapon[RA15_WEAPON] = 1; + ps[0].ammo_amount[RA15_WEAPON] = 1; + ps[0].curr_weapon = RA15_WEAPON; + } +#endif + + allignwarpelevators(); + resetpspritevars(g); + + cachedebug = 0; + automapping = 0; + + cacheit(); + docacheit(); + + if (globalskillsound >= 0) + { + while (Sound[globalskillsound].lock >= 200); + } + globalskillsound = -1; + + FX_StopAllSounds(); + clearsoundlocks(); + FX_SetReverb(0); + + if( (g&MODE_GAME) || (g&MODE_EOL) ) + ps[myconnectindex].gm = MODE_GAME; + else if(g&MODE_RESTART) + { + if(ud.recstat == 2) + ps[myconnectindex].gm = MODE_DEMO; + else ps[myconnectindex].gm = MODE_GAME; + } + + if( (ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART ) + opendemowrite(); + + for(i=connecthead;i>=0;i=connectpoint2[i]) + switch(sector[sprite[ps[i].i].sectnum].floorpicnum) + { + case HURTRAIL: + case FLOORSLIME: + case FLOORPLASMA: + resetweapons(i); + resetinventory(i); + ps[i].gotweapon[PISTOL_WEAPON] = 0; + ps[i].ammo_amount[PISTOL_WEAPON] = 0; + ps[i].curr_weapon = KNEE_WEAPON; + ps[i].kickback_pic = 0; + break; + } + + //PREMAP.C - replace near the my's at the end of the file + myx = omyx = ps[myconnectindex].posx; + myy = omyy = ps[myconnectindex].posy; + myz = omyz = ps[myconnectindex].posz; + myxvel = myyvel = myzvel = 0; + myang = omyang = ps[myconnectindex].ang; + myhoriz = omyhoriz = ps[myconnectindex].horiz; + myhorizoff = omyhorizoff = ps[myconnectindex].horizoff; + mycursectnum = ps[myconnectindex].cursectnum; + myjumpingcounter = ps[myconnectindex].jumping_counter; + myjumpingtoggle = ps[myconnectindex].jumping_toggle; + myonground = ps[myconnectindex].on_ground; + myhardlanding = ps[myconnectindex].hard_landing; + myreturntocenter = ps[myconnectindex].return_to_center; + + ps[myconnectindex].palette = palette; + palto(0,0,0,0); + + setpal(&ps[myconnectindex]); + flushperms(); + + everyothertime = 0; + global_random = 0; + + ud.last_level = ud.level_number+1; + + clearfifo(); + + for(i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; + + restorepalette = 1; + + flushpackets(); + waitforeverybody(); + + palto(0,0,0,0); + vscrn(); + clearview(0L); + drawbackground(); + displayrooms(screenpeek,65536); + displayrest(screenpeek); + nextpage(); + + clearbufbyte(playerquitflag,MAXPLAYERS,0x01010101); + if (waitabort == 1) + gameexit(" "); + ps[myconnectindex].over_shoulder_on = 0; + + clearfrags(); + + resettimevars(); // Here we go +} +#endif + + + +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 5f3ec8c42..385815ff5 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -626,31 +626,6 @@ void G_CacheMapData(void) if ((j&7) == 0) G_HandleAsync(); - -#if 0 - if (bpp > 8 && totalclock - tc > TICRATE/4) - { - /*Bsprintf(tempbuf,"%d resources remaining\n",g_precacheCount-pc+1);*/ - int percentage = min(100, tabledivide32_noinline(100 * pc, g_precacheCount)); - - while (percentage > lpc) - { - G_HandleAsync(); - Bsprintf(tempbuf, "Loaded %d%% (%d/%d textures)\n", lpc, pc, g_precacheCount); - G_DoLoadScreen(tempbuf, lpc); - - if (totalclock - tc >= 1) - { - tc = (int32_t) totalclock; - lpc++; - } - -// Printf("percentage %d lpc %d\n", percentage, lpc); - } - - tc = (int32_t) totalclock; - } -#endif } Bmemset(gotpic, 0, sizeof(gotpic)); @@ -727,7 +702,7 @@ void P_RandomSpawnPoint(int playerNum) if ((g_netServer || ud.multimode > 1) && !(g_gametypeFlags[ud.coop] & GAMETYPE_FIXEDRESPAWN)) { - i = krand2() % g_playerSpawnCnt; + i = krand2() % numplayersprites; if (g_gametypeFlags[ud.coop] & GAMETYPE_TDMSPAWN) { @@ -736,7 +711,7 @@ void P_RandomSpawnPoint(int playerNum) { if (j != playerNum && g_player[j].ps->team == pPlayer->team && sprite[g_player[j].ps->i].extra > 0) { - for (bssize_t k=0; kpos.x - g_playerSpawnPoints[k].pos.x, g_player[j].ps->pos.y - g_playerSpawnPoints[k].pos.y); @@ -830,6 +805,7 @@ void P_ResetPlayer(int playerNum) pPlayer->movement_lock = 0; } +#if 0 void P_ResetStatus(int playerNum) { DukePlayer_t *const pPlayer = g_player[playerNum].ps; @@ -1011,7 +987,7 @@ void P_ResetStatus(int playerNum) } } } - +#endif void P_ResetWeapons(int playerNum) { DukePlayer_t *const pPlayer = g_player[playerNum].ps; @@ -1972,7 +1948,7 @@ static void resetpspritevars(char gameMode) } } - P_ResetStatus(0); + resetplayerstats(0); for (TRAVERSE_CONNECT(i)) if (i) Bmemcpy(g_player[i].ps,g_player[0].ps,sizeof(DukePlayer_t)); @@ -1995,7 +1971,7 @@ static void resetpspritevars(char gameMode) } } - g_playerSpawnCnt = 0; + numplayersprites = 0; // circ = 2048/ud.multimode; g_whichPalForPlayer = 9; @@ -2006,16 +1982,16 @@ static void resetpspritevars(char gameMode) const int32_t nexti = nextspritestat[i]; spritetype *const s = &sprite[i]; - if (g_playerSpawnCnt == MAXPLAYERS) + if (numplayersprites == MAXPLAYERS) G_GameExit("\nToo many player sprites (max 16.)"); - g_playerSpawnPoints[g_playerSpawnCnt].pos.x = s->x; - g_playerSpawnPoints[g_playerSpawnCnt].pos.y = s->y; - g_playerSpawnPoints[g_playerSpawnCnt].pos.z = s->z; - g_playerSpawnPoints[g_playerSpawnCnt].ang = s->ang; - g_playerSpawnPoints[g_playerSpawnCnt].sect = s->sectnum; + 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; - g_playerSpawnCnt++; + numplayersprites++; if (j < MAXPLAYERS) { diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index 80090375a..79cbdbe91 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -783,7 +783,7 @@ static const dataspec_t svgm_udnetw[] = { { DS_STRING, (void *)svgm_udnetw_string, 0, 1 }, { 0, &ud.multimode, sizeof(ud.multimode), 1 }, - { 0, &g_playerSpawnCnt, sizeof(g_playerSpawnCnt), 1 }, + { 0, &numplayersprites, sizeof(numplayersprites), 1 }, { 0, &g_playerSpawnPoints, sizeof(g_playerSpawnPoints), 1 }, { DS_NOCHK, &ud.volume_number, sizeof(ud.volume_number), 1 }, diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 681ff5989..f6cbade4e 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -464,4 +464,10 @@ void videoShowFrame(int32_t w) twod->Clear(); } +void markTileForPrecache(int tilenum, int palnum) +{ +} +void precacheMarkedTiles() +{ +}