- cleanup continues.

This commit is contained in:
Christoph Oelckers 2020-07-06 21:10:20 +02:00
parent 45f51b0c4b
commit 1644c1d33a
19 changed files with 66 additions and 152 deletions

View file

@ -308,7 +308,7 @@ void GameInterface::StartGame(FNewGameStartup& gs)
while (S_CheckSoundPlaying(skillsound))
{
S_Update();
G_HandleAsync();
handleevents();
}
}
ud.m_respawn_monsters = (gs.Skill == 3);

View file

@ -174,4 +174,13 @@ int initreactor(int j, int i, bool isrecon);
void spawneffector(int i);
void gameexitfrommenu();
void pickrandomspot(int pn);
void resetinventory(int pn);
void resetplayerstats(int pn);
void resetweapons(int pn);
void resetprestat(int snum, int g);
void clearfifo(void);
void setmapfog(int fogtype);
void prelevel_common(int g);
END_DUKE_NS

View file

@ -57,17 +57,6 @@ struct ActorInfo
};
#define MAXSAVEGAMENAMESTRUCT 32
#define MAXSAVEGAMENAME (MAXSAVEGAMENAMESTRUCT-1)
#define MAXPWLOCKOUT 128
#define MAXRTSNAME 128
#define MAX_RETURN_VALUES 6
// KEEPINSYNC lunatic/_defs_game.lua
typedef struct {
vec3_t camerapos;
int32_t const_visibility,uw_framerate;
@ -89,8 +78,6 @@ typedef struct {
int32_t ffire,m_player_skill,m_level_number,m_volume_number,multimode;
int32_t player_skill,level_number,volume_number,marker;
//int32_t returnvar[MAX_RETURN_VALUES-1];
uint32_t userbytever;
fix16_t cameraq16ang, cameraq16horiz;
@ -123,9 +110,6 @@ extern int rtsplaying;
#ifndef ONLY_USERDEFS
// this is checked against http://eduke32.com/VERSION
extern const char *s_buildDate;
extern char boardfilename[BMAX_PATH];
#define USERMAPMUSICFAKEVOLUME MAXVOLUMES
#define USERMAPMUSICFAKELEVEL (MAXLEVELS-1)
@ -149,34 +133,12 @@ extern int32_t g_doQuickSave;
extern int32_t restorepalette;
extern int32_t tempwallptr;
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
#define A_InsertSprite EGS
int G_DoMoveThings(void);
//int32_t G_EndOfLevel(void);
#ifdef YAX_ENABLE
void Yax_SetBunchZs(int32_t sectnum, int32_t cf, int32_t daz);
#else
#define Yax_SetBunchZs(sectnum, cf, daz)
#endif
void G_BackToMenu(void);
const char* G_PrintYourTime(void);
const char* G_PrintParTime(void);
const char* G_PrintDesignerTime(void);
const char* G_PrintBestTime(void);
void G_BonusScreen(int32_t bonusonly);
void G_BonusScreenRRRA(int32_t bonusonly);
//void G_CheatGetInv(void);
void G_DisplayRest(int32_t smoothratio);
void drawbackground(void);
void G_DrawFrags(void);
void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio);
void displayrooms(int32_t playerNum,int32_t smoothratio);
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
void G_HandleLocalKeys(void);
void G_UpdatePlayerFromMenu(void);
void FTA(int q, struct player_struct* p);
@ -187,23 +149,8 @@ void OffMotorcycle(DukePlayer_t *pPlayer);
void OnBoat(DukePlayer_t *pPlayer, int spriteNum);
void OffBoat(DukePlayer_t *pPlayer);
// Cstat protection mask for (currently) spawned MASKWALL* sprites.
// TODO: look at more cases of cstat=(cstat&PROTECTED)|ADDED in fi.spawn()?
// 2048+(32+16)+8+4
#define SPAWN_PROTECT_CSTAT_MASK (CSTAT_SPRITE_NOSHADE|CSTAT_SPRITE_ALIGNMENT_SLAB|CSTAT_SPRITE_XFLIP|CSTAT_SPRITE_YFLIP);
void G_InitTimer(int32_t ticspersec);
inline int32_t G_GetTeamPalette(int32_t team)
{
int8_t pal[] = { 3, 10, 11, 12 };
if ((unsigned)team >= ARRAY_SIZE(pal))
return 0;
return pal[team];
}
enum
{
TFLAG_WALLSWITCH = 1
@ -216,19 +163,10 @@ struct TileInfo
extern TileInfo tileinfo[MAXTILES];
// (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots)
#define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (actorinfo[iPicnum].flags & iType) != 0)
#define S_StopSound(num) S_StopEnvSound(num, -1)
extern int startrts(int lumpNum, int localPlayer);
extern void G_MaybeAllocPlayer(int32_t pnum);
static inline void G_HandleAsync(void)
{
handleevents();
}
static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
{
if (!((ud.multimode < 2 && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
@ -249,9 +187,6 @@ static inline void G_NewGame_EnterLevel(void)
G_BackToMenu();
}
extern void G_PrintCurrentMusic(void);
extern void G_InitMultiPsky(int CLOUDYOCEAN__DYN, int MOONSKY1__DYN, int BIGORBIT1__DYN, int LA__DYN);
extern void G_SetupGlobalPsky(void);

View file

@ -281,18 +281,8 @@ extern int32_t g_volumeCnt;
extern int16_t weaponsandammosprites[15];
extern int32_t g_gametypeFlags[MAXGAMETYPES];
extern const char *s_buildDate;
#endif
inline void clearfriction()
{
for (int playerNum = 0; playerNum != -1; playerNum = connectpoint2[playerNum])
{
vec2_t& fric = g_player[playerNum].ps->fric;
fric.x = fric.y = 0;
}
}
enum
{
EF_HIDEFROMSP = 1<<0,

View file

@ -144,6 +144,15 @@ inline fixed_t PlayerInputAngVel(int pl)
return g_player[pl].input->q16avel;
}
inline void clearfriction()
{
for (int i = 0; i != -1; i = connectpoint2[i])
{
ps[i].fric.x = ps[i].fric.y = 0;
}
}
//---------------------------------------------------------------------------
//
//

View file

@ -2600,8 +2600,7 @@ void processinput_d(int snum)
g_player[snum].horizAngleAdjust = 0;
g_player[snum].horizSkew = 0;
if (p->cheat_phase <= 0) sb_snum = PlayerInputBits(snum, SKB_ALL);
else sb_snum = 0;
sb_snum = PlayerInputBits(snum, SKB_ALL);
auto sb_fvel = PlayerInputForwardVel(snum);
auto sb_svel = PlayerInputSideVel(snum);

View file

@ -3439,8 +3439,7 @@ void processinput_r(int snum)
g_player[snum].horizAngleAdjust = 0;
g_player[snum].horizSkew = 0;
if (p->cheat_phase <= 0) sb_snum = g_player[snum].input->bits;// sync[snum].bits;
else sb_snum = 0;
sb_snum = g_player[snum].input->bits;// sync[snum].bits;
auto sb_fvel = g_player[snum].input->fvel; // TRANSITIONAL
auto sb_svel = g_player[snum].input->svel;

View file

@ -149,7 +149,6 @@ void resetplayerstats(int snum)
p->fric.y = 0;
p->somethingonplayer =-1;
p->one_eighty_count = 0;
p->cheat_phase = 0;
p->on_crane = -1;
@ -166,7 +165,6 @@ void resetplayerstats(int snum)
p->knee_incs = 0;
setpal(p);
p->stairs = 0;
//p->fogtype = 0;
p->noise_x = 0;
p->noise_y = 0;
p->make_noise = 0;
@ -390,7 +388,6 @@ void resetprestat(int snum,int g)
for(i=0;i<spriteqamount;i++) spriteq[i] = -1;
p->hbomb_on = 0;
p->cheat_phase = 0;
p->pals.f = 0;
p->toggle_key_flag = 0;
p->secret_rooms = 0;

View file

@ -29,20 +29,12 @@ extern int16_t ambientlotag[64];
extern int16_t ambienthitag[64];
int G_EnterLevel(int gameMode);
int G_FindLevelByFile(const char *fileName);
void G_CacheMapData(void);
void G_NewGame(int volumeNum, int levelNum, int skillNum);
void G_ResetTimers(uint8_t keepgtics);
void pickrandomspot(int pn);
void resetinventory(int pn);
void P_ResetPlayer(int pn);
void resetplayerstats(int pn);
void resetweapons(int pn);
void resetprestat(int snum, int g);
void clearfifo(void);
void G_ResetInterpolations(void);
void setmapfog(int fogtype);
void G_InitRRRASkies(void);
void prelevel_common(int g);
END_DUKE_NS

View file

@ -133,13 +133,13 @@ void DDukeCommonStatusBar::DrawInventory(const DukePlayer_t* p, double x, double
if (p->invdisptime <= 0)return;
int n = 0, j = 0;
if (p->inv_amount[GET_FIRSTAID] > 0) n |= 1, j++;
if (p->inv_amount[GET_STEROIDS] > 0) n |= 2, j++;
if (p->inv_amount[GET_HOLODUKE] > 0) n |= 4, j++;
if (p->inv_amount[GET_JETPACK] > 0) n |= 8, j++;
if (p->inv_amount[GET_HEATS] > 0) n |= 16, j++;
if (p->inv_amount[GET_SCUBA] > 0) n |= 32, j++;
if (p->inv_amount[GET_BOOTS] > 0) n |= 64, j++;
if (p->firstaid_amount > 0) n |= 1, j++;
if (p->steroids_amount > 0) n |= 2, j++;
if (p->holoduke_amount > 0) n |= 4, j++;
if (p->jetpack_amount > 0) n |= 8, j++;
if (p->heat_amount > 0) n |= 16, j++;
if (p->scuba_amount > 0) n |= 32, j++;
if (p->boot_amount > 0) n |= 64, j++;
x -= (j * 11);
y -= 6;

View file

@ -76,19 +76,19 @@ public:
switch (p->inven_icon)
{
case ICON_FIRSTAID:
return p->inv_amount[GET_FIRSTAID];
return p->firstaid_amount;
case ICON_STEROIDS:
return (p->inv_amount[GET_STEROIDS] + 3) >> 2;
return (p->steroids_amount + 3) >> 2;
case ICON_HOLODUKE:
return (p->inv_amount[GET_HOLODUKE] + 15) / 24;
return (p->holoduke_amount + 15) / 24;
case ICON_JETPACK:
return (p->inv_amount[GET_JETPACK] + 15) >> 4;
return (p->jetpack_amount + 15) >> 4;
case ICON_HEATS:
return p->inv_amount[GET_HEATS] / 12;
return p->heat_amount / 12;
case ICON_SCUBA:
return (p->inv_amount[GET_SCUBA] + 63) >> 6;
return (p->scuba_amount + 63) >> 6;
case ICON_BOOTS:
return p->inv_amount[GET_BOOTS] >> 1;
return p->boot_amount >> 1;
}
return -1;
@ -98,7 +98,7 @@ public:
{
// special handling for WW2GI
int lAmount = GetGameVar("PLR_MORALE", -1, p->i, snum);
if (lAmount == -1) lAmount = p->inv_amount[GET_SHIELD];
if (lAmount == -1) lAmount = p->shield_amount;
return lAmount;
}

View file

@ -62,20 +62,20 @@ public:
{
switch (p->inven_icon)
{
case ICON_FIRSTAID:
return p->inv_amount[GET_FIRSTAID];
case ICON_STEROIDS:
return (p->inv_amount[GET_STEROIDS] + 3) >> 2;
case ICON_HOLODUKE:
return p->inv_amount[GET_HOLODUKE] / 400;
case ICON_JETPACK:
return p->inv_amount[GET_JETPACK] / 100;
case ICON_HEATS:
return p->inv_amount[GET_HEATS] / 12;
case ICON_SCUBA:
return (p->inv_amount[GET_SCUBA] + 63) >> 6;
case ICON_BOOTS:
return (p->inv_amount[GET_BOOTS] / 10) >> 1;
case ICON_FIRSTAID:
return p->firstaid_amount;
case ICON_STEROIDS:
return (p->steroids_amount + 3) >> 2;
case ICON_HOLODUKE:
return (p->holoduke_amount) / 400;
case ICON_JETPACK:
return (p->jetpack_amount) / 100;
case ICON_HEATS:
return p->heat_amount / 12;
case ICON_SCUBA:
return (p->scuba_amount + 63) >> 6;
case ICON_BOOTS:
return (p->boot_amount / 10) >> 1;
}
return -1;

View file

@ -112,7 +112,7 @@ void cacheAllSounds(void)
{
soundEngine->CacheSound(&snd);
if (((++i)&31) == 0)
G_HandleAsync();
handleevents();
}
}
@ -151,9 +151,6 @@ int S_GetUserFlags(int num)
int S_DefineSound(unsigned index, const char *filename, int minpitch, int maxpitch, int priority, int type, int distance, float volume)
{
if ((unsigned)index >= MAXSOUNDS)
return -1;
auto& S_sfx = soundEngine->GetSounds();
index++;
unsigned oldindex = S_sfx.Size();
@ -421,9 +418,6 @@ int S_PlaySound3D(int sndnum, int spriteNum, const vec3_t* pos, int channel, ECh
GetPositionInfo(spriteNum, sndnum, camsect, campos, pos, &sndist, &sndpos);
int pitch = S_GetPitch(sndnum);
if (ps[screenpeek].sound_pitch)
pitch += ps[screenpeek].sound_pitch;
bool explosion = ((userflags & (SF_GLOBAL | SF_DTAG)) == (SF_GLOBAL | SF_DTAG)) || ((sndnum == PIPEBOMB_EXPLODE || sndnum == LASERTRIP_EXPLODE || sndnum == RPG_EXPLODE));
bool underwater = ps[screenpeek].cursectnum > -1 && sector[ps[screenpeek].cursectnum].lotag == ST_2_UNDERWATER;

View file

@ -46,10 +46,6 @@ enum {
SF_DTAG = 128,
};
// KEEPINSYNC lunatic/con_lang.lua
#define MAXSOUNDS 4096
#define LOUDESTVOLUME 111
enum esound_t
{
kPitchStart,
@ -69,7 +65,6 @@ inline int spritesound(int soundnum, int spritenum)
int A_CheckAnySoundPlaying(int spriteNum);
int S_CheckSoundPlaying(int soundNum);
inline int S_CheckSoundPlaying(int sprnum, int soundNum) { return S_CheckSoundPlaying(soundNum); }
inline void S_ClearSoundLocks(void) {}
void cacheAllSounds(void);
void S_MenuSound(void);
void S_PauseMusic(bool paused);
@ -88,6 +83,8 @@ inline void stopsound(int snd)
{
S_StopEnvSound(snd, -1);
}
#define S_StopSound(num) S_StopEnvSound(num, -1)
void S_Update(void);
void S_ChangeSoundPitch(int soundNum, int spriteNum, int pitchoffset);
int S_GetUserFlags(int sndnum);

View file

@ -150,7 +150,7 @@ void G_HandleLocalKeys(void)
}
}
if (g_player[myconnectindex].ps->cheat_phase == 1 || (g_player[myconnectindex].ps->gm&(MODE_MENU|MODE_TYPE)) || System_WantGuiCapture())
if ((g_player[myconnectindex].ps->gm&(MODE_MENU|MODE_TYPE)) || System_WantGuiCapture())
return;
if (buttonMap.ButtonDown(gamefunc_See_Coop_View) && (ud.coop || ud.recstat == 2))
@ -181,8 +181,8 @@ void G_HandleLocalKeys(void)
ud.scrollmode = 1-ud.scrollmode;
if (ud.scrollmode)
{
ud.folx = g_player[screenpeek].ps->opos.x;
ud.foly = g_player[screenpeek].ps->opos.y;
ud.folx = g_player[screenpeek].ps->oposx;
ud.foly = g_player[screenpeek].ps->oposy;
ud.fola = fix16_to_int(g_player[screenpeek].ps->oq16ang);
}
FTA(QUOTE_MAP_FOLLOW_OFF+ud.scrollmode,g_player[myconnectindex].ps);
@ -444,8 +444,6 @@ void G_UpdatePlayerFromMenu(void)
}
else
{
/*int32_t j = g_player[myconnectindex].ps->team;*/
P_SetupMiscInputSettings();
g_player[myconnectindex].ps->palookup = g_player[myconnectindex].pcolor = G_CheckPlayerColor(playercolor);
@ -686,7 +684,7 @@ int GameInterface::app_main()
for (int i=1, j=numplayers; j<ud.multimode; j++)
{
Bsprintf(g_player[j].user_name,"%s %d", GStrings("PLAYER"),j+1);
g_player[j].ps->team = g_player[j].pteam = i;
g_player[j].pteam = i;
g_player[j].ps->weaponswitch = 3;
g_player[j].ps->auto_aim = 0;
i = 1-i;
@ -740,7 +738,6 @@ int GameInterface::app_main()
videoSetPalette(BASEPAL, 0);
FX_StopAllSounds();
S_ClearSoundLocks();
app_loop();
return 0;
}

View file

@ -410,8 +410,8 @@ void P_GetInput(int const playerNum)
if (!pPlayer->aim_mode && pPlayer->on_ground && sectorLotag != ST_2_UNDERWATER && (sector[pPlayer->cursectnum].floorstat & 2))
{
// this is some kind of horse shit approximation of where the player is looking, I guess?
vec2_t const adjustedPosition = { pPlayer->pos.x + (sintable[(fix16_to_int(pPlayer->q16ang) + 512) & 2047] >> 5),
pPlayer->pos.y + (sintable[fix16_to_int(pPlayer->q16ang) & 2047] >> 5) };
vec2_t const adjustedPosition = { pPlayer->posx + (sintable[(fix16_to_int(pPlayer->q16ang) + 512) & 2047] >> 5),
pPlayer->posy + (sintable[fix16_to_int(pPlayer->q16ang) & 2047] >> 5) };
int16_t currentSector = pPlayer->cursectnum;
updatesector(adjustedPosition.x, adjustedPosition.y, &currentSector);

View file

@ -87,7 +87,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
{
DukePlayer_t *const pPlayer = g_player[0].ps;
G_HandleAsync();
handleevents();
g_skillSoundVoice = -1;
@ -329,7 +329,6 @@ int G_EnterLevel(int gameMode)
{
S_PauseSounds(false);
FX_StopAllSounds();
S_ClearSoundLocks();
FX_SetReverb(0);
}

View file

@ -161,7 +161,6 @@ int32_t G_LoadPlayer(const char *path)
Net_WaitForEverybody();
FX_StopAllSounds();
S_ClearSoundLocks();
// non-"m_" fields will be loaded from svgm_udnetw
ud.m_volume_number = h.volnum;
@ -1397,9 +1396,7 @@ static void postloadplayer(int32_t savegamep)
if (savegamep)
{
Bmemset(gotpic, 0, sizeof(gotpic));
S_ClearSoundLocks();
//G_CacheMapData();
Mus_ResumeSaved();
Mus_ResumeSaved();
Mus_SetPaused(false);
g_player[myconnectindex].ps->gm = MODE_GAME;

View file

@ -235,15 +235,15 @@ void G_DisplayRest(int32_t smoothratio)
}
else
{
cposx = pp->opos.x + mulscale16(pp->pos.x-pp->opos.x, smoothratio);
cposy = pp->opos.y + mulscale16(pp->pos.y-pp->opos.y, smoothratio);
cposx = pp->oposx + mulscale16(pp->posx-pp->oposx, smoothratio);
cposy = pp->oposy + mulscale16(pp->posy-pp->oposy, smoothratio);
cang = fix16_to_int(pp->oq16ang) + mulscale16((fix16_to_int(pp->q16ang+F16(1024)-pp->oq16ang)&2047)-1024, smoothratio);
}
}
else
{
cposx = pp->opos.x;
cposy = pp->opos.y;
cposx = pp->oposx;
cposy = pp->oposy;
cang = fix16_to_int(pp->oq16ang);
}
}