- startrts and domovethings.

This commit is contained in:
Christoph Oelckers 2020-07-06 03:00:52 +02:00
parent 827672a775
commit 736a52f7b2
16 changed files with 204 additions and 316 deletions

View file

@ -18,6 +18,7 @@ set( PCH_SOURCES
src/game_misc.cpp
src/gamedef.cpp
src/gameexec.cpp
src/gameloop.cpp
src/gamevar.cpp
src/hudweapon_d.cpp
src/hudweapon_r.cpp

View file

@ -96,6 +96,7 @@ typedef struct {
} user_defs;
extern user_defs ud;
extern int rtsplaying;
#ifndef ONLY_USERDEFS
@ -125,7 +126,6 @@ extern int32_t cameraclock;
extern int32_t cameradist;
extern int32_t g_crosshairSum;
extern int32_t g_doQuickSave;
extern int32_t g_levelTextTime;
extern int32_t restorepalette;
extern int32_t tempwallptr;
@ -363,6 +363,7 @@ void initcrane(int j, int i, int CRANEPOLE);
void initwaterdrip(int j, int i);
int initreactor(int j, int i, bool isrecon);
void spawneffector(int i);
void gameexitfrommenu();
struct Dispatcher
{

View file

@ -45,6 +45,7 @@ BEGIN_DUKE_NS
FFont* IndexFont;
FFont* DigiFont;
int rtsplaying;
//---------------------------------------------------------------------------
//
@ -625,6 +626,28 @@ void cameratext(int i)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int G_StartRTS(int lumpNum, int localPlayer)
{
if (SoundEnabled() &&
RTS_IsInitialized() && rtsplaying == 0 && (snd_speech & (localPlayer ? 1 : 4)))
{
auto sid = RTS_GetSoundID(lumpNum - 1);
if (sid != -1)
{
S_PlaySound(sid, CHAN_AUTO, CHANF_UI);
rtsplaying = 7;
return 1;
}
}
return 0;
}
END_DUKE_NS

View file

@ -29,7 +29,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "ns.h" // Must come before everything else!
#include "duke3d.h"
#include "demo.h"
#include "sbar.h"
#include "screens.h"
#include "baselayer.h"
#include "m_argv.h"
@ -38,6 +38,10 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
BEGIN_DUKE_NS
void GetNextInput();
/*
static inline int movefifoend(int myconnectindex)
{
#if 1
@ -46,6 +50,7 @@ static inline int movefifoend(int myconnectindex)
return movefifoend[myconnectindex];
#endif
}
*/
static void fakedomovethings()
{
@ -57,89 +62,67 @@ static void fakedomovethingscorrect()
// unprediction
}
/*
void mploadsave()
{
for(int i=connecthead;i>=0;i=connectpoint2[i])
if( sync[i].bits&(1<<17) )
{
multiflag = 2;
multiwhat = (sync[i].bits>>18)&1;
multipos = (unsigned) (sync[i].bits>>19)&15;
multiwho = i;
if( multiwhat )
{
saveplayer( multipos );
multiflag = 0;
if(multiwho != myconnectindex)
{
strcpy(&fta_quotes[122],&ud.user_name[multiwho][0]);
strcat(&fta_quotes[122]," SAVED A MULTIPLAYER GAME");
FTA(122,&ps[myconnectindex]);
}
else
{
strcpy(&fta_quotes[122],"MULTIPLAYER GAME SAVED");
FTA(122,&ps[myconnectindex]);
}
break;
}
else
{
// waitforeverybody();
j = loadplayer( multipos );
multiflag = 0;
if(j == 0 && !RR)
{
if(multiwho != myconnectindex)
{
strcpy(&fta_quotes[122],&ud.user_name[multiwho][0]);
strcat(&fta_quotes[122]," LOADED A MULTIPLAYER GAME");
FTA(122,&ps[myconnectindex]);
}
else
{
strcpy(&fta_quotes[122],"MULTIPLAYER GAME LOADED");
FTA(122,&ps[myconnectindex]);
}
return 1;
}
}
}
}
*/
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int domovethings();
char moveloop()
/*
void mploadsave()
{
int i;
for(int i=connecthead;i>=0;i=connectpoint2[i])
if( sync[i].bits&(1<<17) )
{
multiflag = 2;
multiwhat = (sync[i].bits>>18)&1;
multipos = (unsigned) (sync[i].bits>>19)&15;
multiwho = i;
if (numplayers > 1)
while (fakemovefifoplc < movefifoend[myconnectindex]) fakedomovethings();
if( multiwhat )
{
saveplayer( multipos );
multiflag = 0;
getpackets();
if(multiwho != myconnectindex)
{
strcpy(&fta_quotes[122],&ud.user_name[multiwho][0]);
strcat(&fta_quotes[122]," SAVED A MULTIPLAYER GAME");
FTA(122,&ps[myconnectindex]);
}
else
{
strcpy(&fta_quotes[122],"MULTIPLAYER GAME SAVED");
FTA(122,&ps[myconnectindex]);
}
break;
}
else
{
// waitforeverybody();
if (numplayers < 2) bufferjitter = 0;
while (movefifoend(myconnectindex)-movefifoplc > bufferjitter)
{
for(i=connecthead;i>=0;i=connectpoint2[i])
if (movefifoplc == movefifoend(i)) break;
if (i >= 0) break;
if( domovethings() ) return 1;
}
return 0;
j = loadplayer( multipos );
multiflag = 0;
if(j == 0 && !RR)
{
if(multiwho != myconnectindex)
{
strcpy(&fta_quotes[122],&ud.user_name[multiwho][0]);
strcat(&fta_quotes[122]," LOADED A MULTIPLAYER GAME");
FTA(122,&ps[myconnectindex]);
}
else
{
strcpy(&fta_quotes[122],"MULTIPLAYER GAME LOADED");
FTA(122,&ps[myconnectindex]);
}
return 1;
}
}
}
}
*/
//---------------------------------------------------------------------------
//
@ -149,117 +132,126 @@ char moveloop()
int domovethings()
{
int i, j;
int ch;
int i, j;
// mplpadsave();
ud.camerasprite = -1;
lockclock += TICSPERFRAME;
ud.camerasprite = -1;
lockclock += TICSPERFRAME;
if(earthquaketime > 0) earthquaketime--;
if(rtsplaying > 0) rtsplaying--;
if (earthquaketime > 0) earthquaketime--;
if (rtsplaying > 0) rtsplaying--;
if( show_shareware > 0 )
{
show_shareware--;
if(show_shareware == 0)
{
pus = NUMPAGES;
pub = NUMPAGES;
}
}
if (show_shareware > 0)
{
show_shareware--;
}
everyothertime++;
everyothertime++;
GetNextInput();
updateinterpolations();
for(i=connecthead;i>=0;i=connectpoint2[i])
copybufbyte(&inputfifo[movefifoplc&(MOVEFIFOSIZ-1)][i],&sync[i],sizeof(input));
movefifoplc++;
j = -1;
for (i = connecthead; i >= 0; i = connectpoint2[i])
{
if (PlayerInput(i, SK_GAMEQUIT))
{
if (i == myconnectindex) gameexitfrommenu();
if (screenpeek == i)
{
screenpeek = connectpoint2[i];
if (screenpeek < 0) screenpeek = connecthead;
}
updateinterpolations();
if (i == connecthead) connecthead = connectpoint2[connecthead];
else connectpoint2[j] = connectpoint2[i];
j = -1;
for(i=connecthead;i>=0;i=connectpoint2[i])
{
if ((sync[i].bits&(1<<26)) == 0) { j = i; continue; }
numplayers--;
ud.multimode--;
if (i == myconnectindex) gameexit(" ");
if (screenpeek == i)
{
screenpeek = connectpoint2[i];
if (screenpeek < 0) screenpeek = connecthead;
}
//closedemowrite();
if (i == connecthead) connecthead = connectpoint2[connecthead];
else connectpoint2[j] = connectpoint2[i];
if (numplayers < 2 && !isRR())
S_PlaySound(GENERIC_AMBIENCE17, CHAN_AUTO, CHANF_UI);
numplayers--;
ud.multimode--;
Printf(PRINT_NOTIFY, "%s is history!", g_player[i].user_name);
closedemowrite();
quickkill(&ps[i]);
deletesprite(ps[i].i);
}
else j = i;
}
if (numplayers < 2 && !RR)
sound(GENERIC_AMBIENCE17);
//if(ud.recstat == 1) record();
pub = NUMPAGES;
pus = NUMPAGES;
vscrn();
if (ud.pause_on == 0)
{
global_random = krand();
movedummyplayers();//ST 13
}
Printf(PRINT_NOTIFY, "%s is history!",ud.user_name[i]);
for (i = connecthead; i >= 0; i = connectpoint2[i])
{
if (ud.pause_on == 0)
{
auto p = &ps[i];
if (p->pals.f > 0)
p->pals.f--;
quickkill(&ps[i]);
deletesprite(ps[i].i);
fi.processinput(i);
fi.checksectors(i);
}
}
if(j < 0 && networkmode == 0 )
gameexit( " \nThe 'MASTER/First player' just quit the game. All\nplayers are returned from the game. This only happens in 5-8\nplayer mode as a different network scheme is used.");
}
if (ud.pause_on == 0)
{
if (levelTextTime > 0)
levelTextTime--;
if ((numplayers >= 2) && ((movefifoplc&7) == 7))
{
ch = (char)(randomseed&255);
for(i=connecthead;i>=0;i=connectpoint2[i])
ch += ((ps[i].posx+ps[i].posy+ps[i].posz+ps[i].ang+ps[i].horiz)&255);
syncval[myconnectindex][syncvalhead[myconnectindex]&(MOVEFIFOSIZ-1)] = ch;
syncvalhead[myconnectindex]++;
}
if(ud.recstat == 1) record();
if( ud.pause_on == 0 )
{
global_random = TRAND;
movedummyplayers();//ST 13
}
for(i=connecthead;i>=0;i=connectpoint2[i])
{
cheatkeys(i);
if( ud.pause_on == 0 )
{
processinput(i);
checksectors(i);
}
}
if( ud.pause_on == 0 )
{
fi.think();
}
}
fakedomovethingscorrect();
fakedomovethingscorrect();
if( (everyothertime&1) == 0)
{
animatewalls();
movecyclers();
pan3dsound();
}
if ((everyothertime & 1) == 0)
{
fi.animatewalls();
movecyclers();
}
if (isRR() && ud.recstat == 0 && ud.multimode < 2)
dotorch();
return 0;
return 0;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
/*
char moveloop()
{
int i;
if (numplayers > 1)
while (fakemovefifoplc < movefifoend[myconnectindex]) fakedomovethings();
getpackets();
if (numplayers < 2) bufferjitter = 0;
while (movefifoend(myconnectindex)-movefifoplc > bufferjitter)
{
for(i=connecthead;i>=0;i=connectpoint2[i])
if (movefifoplc == movefifoend(i)) break;
if (i >= 0) break;
if( domovethings() ) return 1;
}
return 0;
}
*/
END_DUKE_NS

View file

@ -143,7 +143,7 @@ G_EXTERN int32_t playerswhenstarted;
G_EXTERN int32_t g_musicSize;
G_EXTERN int32_t numplayersprites;
G_EXTERN int32_t g_scriptDebug;
G_EXTERN int32_t g_showShareware;
G_EXTERN int32_t show_shareware;
G_EXTERN int32_t g_spriteDeleteQueuePos;
G_EXTERN int32_t max_player_health;
G_EXTERN int32_t max_armour_amount;
@ -160,9 +160,9 @@ G_EXTERN int32_t g_animateVel[MAXANIMATES];
#define animatevel g_animateVel
G_EXTERN int16_t clouds[256];
G_EXTERN int16_t g_cloudX;
G_EXTERN int16_t g_cloudY;
G_EXTERN ClockTicks g_cloudClock;
G_EXTERN int16_t cloudx;
G_EXTERN int16_t cloudy;
G_EXTERN ClockTicks cloudtotalclock;
G_EXTERN int16_t SpriteDeletionQueue[1024];
G_EXTERN int16_t g_cyclers[MAXCYCLERS][6];

View file

@ -370,7 +370,6 @@ extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
extern playerspawn_t g_playerSpawnPoints[MAXPLAYERS];
extern playerdata_t *const g_player;
extern hudweapon_t hudweap;
extern int32_t g_levelTextTime;
extern int32_t mouseyaxismode;
#define SHOOT_HARDCODED_ZVEL INT32_MIN
@ -392,7 +391,6 @@ inline void SetPlayerPal(DukePlayer_t* pPlayer, PalEntry pe)
}
int hitawall(DukePlayer_t* pPlayer, int* hitWall);
void P_AddKills(DukePlayer_t * pPlayer, uint16_t kills);
int hits(int spriteNum);
void P_GetInput(int playerNum);
void P_GetInputMotorcycle(int playerNum);
@ -414,7 +412,6 @@ void quickkill(DukePlayer_t* pPlayer);
void setpal(DukePlayer_t* pPlayer);
void P_EndLevel(void);
void P_CheckWeaponI(int playerNum);
int P_GetOverheadPal(const DukePlayer_t *pPlayer);
int madenoise(int playerNum);
int haskey(int sect, int snum);

View file

@ -27,7 +27,6 @@ BEGIN_DUKE_NS
extern int16_t ambientlotag[64];
extern int16_t ambienthitag[64];
extern int32_t g_levelTextTime;
int G_EnterLevel(int gameMode);
int G_FindLevelByFile(const char *fileName);
void G_CacheMapData(void);

View file

@ -41,6 +41,8 @@ source as it is released.
#include "texturemanager.h"
BEGIN_DUKE_NS
int levelTextTime;
//==========================================================================
//
// very much a dummy to access the methods.

View file

@ -27,4 +27,6 @@ public:
};
extern int levelTextTime;
END_DUKE_NS

View file

@ -416,11 +416,11 @@ void drawstatusbar_d(int snum)
dsb.Statusbar(snum);
}
if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1 && !M_Active())
if (ud.show_level_text && hud_showmapname && levelTextTime > 1 && !M_Active())
{
double alpha;
if (g_levelTextTime > 16) alpha = 1.;
else alpha = (g_levelTextTime) / 16.;
if (levelTextTime > 16) alpha = 1.;
else alpha = (levelTextTime) / 16.;
PrintLevelName_d(alpha);
}

View file

@ -400,11 +400,11 @@ void drawstatusbar_r(int snum)
dsb.Statusbar(snum);
}
if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1 && !M_Active())
if (ud.show_level_text && hud_showmapname && levelTextTime > 1 && !M_Active())
{
double alpha;
if (g_levelTextTime > 16) alpha = 1.;
else alpha = (g_levelTextTime) / 16.;
if (levelTextTime > 16) alpha = 1.;
else alpha = (levelTextTime) / 16.;
PrintLevelName_r(alpha);
}

View file

@ -72,8 +72,6 @@ int32_t tempwallptr;
static int32_t nonsharedtimer;
int32_t g_levelTextTime = 0;
static void gameTimerHandler(void)
{
S_Update();
@ -98,25 +96,6 @@ void G_InitTimer(int32_t ticspersec)
}
static int32_t g_RTSPlaying;
// Returns: started playing?
int G_StartRTS(int lumpNum, int localPlayer)
{
if (SoundEnabled() &&
RTS_IsInitialized() && g_RTSPlaying == 0 && (snd_speech & (localPlayer ? 1 : 4)))
{
auto sid = RTS_GetSoundID(lumpNum - 1);
if (sid != -1)
{
S_PlaySound(sid, CHAN_AUTO, CHANF_UI);
g_RTSPlaying = 7;
return 1;
}
}
return 0;
}
void G_HandleLocalKeys(void)
{
@ -227,7 +206,7 @@ void G_HandleLocalKeys(void)
}
// Not SHIFT -- that is, either some ALT or WIN.
if (G_StartRTS(ridiculeNum, 1))
if (startrts(ridiculeNum, 1))
{
Net_SendRTS(ridiculeNum);
return;
@ -915,6 +894,7 @@ MAIN_LOOP_RESTART:
while (1);
}
int domovethings();
int32_t G_MoveLoop()
{
int i;
@ -932,99 +912,19 @@ int32_t G_MoveLoop()
if (movefifoplc == g_player[i].movefifoend) break;
}
if (i >= 0) break;
if (G_DoMoveThings()) return 1;
if (domovethings()) return 1;
}
return 0;
}
int G_DoMoveThings(void)
void GetNextInput()
{
ud.camerasprite = -1;
lockclock += TICSPERFRAME;
// Moved lower so it is restored correctly by demo diffs:
//if (g_earthquakeTime > 0) g_earthquakeTime--;
if (g_RTSPlaying > 0)
g_RTSPlaying--;
if (g_showShareware > 0)
{
g_showShareware--;
if (g_showShareware == 0)
{
pus = NUMPAGES;
pub = NUMPAGES;
}
}
for (bssize_t TRAVERSE_CONNECT(i))
Bmemcpy(g_player[i].input, &inputfifo[movefifoplc&(MOVEFIFOSIZ-1)][i], sizeof(input_t));
Bmemcpy(g_player[i].input, &inputfifo[movefifoplc & (MOVEFIFOSIZ - 1)][i], sizeof(input_t));
movefifoplc++;
updateinterpolations();
g_moveThingsCount++;
everyothertime++;
if (g_earthquakeTime > 0) g_earthquakeTime--;
if (ud.pause_on == 0)
{
g_globalRandom = krand2();
movedummyplayers();//ST 13
}
for (bssize_t TRAVERSE_CONNECT(i))
{
if (g_player[i].input->extbits&(1<<6))
{
g_player[i].ps->team = g_player[i].pteam;
}
if (sprite[g_player[i].ps->i].pal != 1)
sprite[g_player[i].ps->i].pal = g_player[i].pcolor;
hud_input(i);
if (ud.pause_on == 0)
{
auto p = &ps[i];
if (p->pals.f > 0)
p->pals.f--;
if (g_levelTextTime > 0)
g_levelTextTime--;
//P_ProcessInput(i);
fi.processinput(i);
fi.checksectors(i);
}
}
if (ud.pause_on == 0)
fi.think();
Net_CorrectPrediction();
if ((everyothertime&1) == 0)
{
{
fi.animatewalls();
movecyclers();
}
}
if (RR && ud.recstat == 0 && ud.multimode < 2)
dotorch();
return 0;
}
void GameInterface::FreeGameData()

View file

@ -33,36 +33,6 @@ int32_t PHEIGHT = PHEIGHT_DUKE;
int32_t lastvisinc;
hudweapon_t hudweap;
extern int32_t g_levelTextTime;
void P_AddKills(DukePlayer_t * const pPlayer, uint16_t kills)
{
pPlayer->actors_killed += kills;
}
int P_GetOverheadPal(DukePlayer_t const * pPlayer)
{
return sprite[pPlayer->i].pal;
}
#define DRAWEAP_CENTER 262144
#define weapsc(sc) scale(sc, hud_weaponscale, 100)
static int32_t g_dts_yadd;
// Set C-CON's WEAPON and WORKSLIKE gamevars.
void P_SetWeaponGamevars(int playerNum, const DukePlayer_t * const pPlayer)
{
if (!WW2GI)
return;
SetGameVarID(g_iWeaponVarID, pPlayer->curr_weapon, pPlayer->i, playerNum);
SetGameVarID(g_iWorksLikeVarID,
((unsigned)pPlayer->curr_weapon < MAX_WEAPONS) ? PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) : -1,
pPlayer->i, playerNum);
}
#define TURBOTURNTIME (TICRATE/8) // 7
#define NORMALTURN 15
#define PREAMBLETURN 5

View file

@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "cmdlib.h"
#include "v_2ddrawer.h"
#include "secrets.h"
#include "sbar.h"
#include "glbackend/glbackend.h"
BEGIN_DUKE_NS
@ -103,7 +104,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
G_BonusScreen(0);
#endif
g_showShareware = GAMETICSPERSEC*34;
show_shareware = GAMETICSPERSEC*34;
ud.level_number = levelNum;
ud.volume_number = volumeNum;
@ -172,9 +173,9 @@ static inline void clearfrags(void)
void G_ResetTimers(uint8_t keepgtics)
{
totalclock = g_cloudClock = ototalclock = lockclock = 0;
totalclock = cloudtotalclock = ototalclock = lockclock = 0;
ready2send = 1;
g_levelTextTime = 85;
levelTextTime = 85;
if (!keepgtics)
g_moveThingsCount = 0;

View file

@ -851,8 +851,8 @@ static const dataspec_t svgm_anmisc[] =
{ DS_CNT(g_deleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_deleteQueueSize },
{ DS_NOCHK, &numclouds, sizeof(numclouds), 1 },
{ 0, &clouds[0], sizeof(clouds), 1 },
{ 0, &g_cloudX, sizeof(g_cloudX), 1 },
{ 0, &g_cloudY, sizeof(g_cloudY), 1 },
{ 0, &cloudx, sizeof(cloudx), 1 },
{ 0, &cloudy, sizeof(cloudy), 1 },
{ 0, &g_pskyidx, sizeof(g_pskyidx), 1 }, // DS_NOCHK?
{ 0, &g_earthquakeTime, sizeof(g_earthquakeTime), 1 },
@ -1436,7 +1436,7 @@ static void postloadplayer(int32_t savegamep)
G_ResetInterpolations();
//6
g_showShareware = 0;
show_shareware = 0;
if (savegamep)
everyothertime = 0;

View file

@ -303,7 +303,7 @@ void G_DisplayRest(int32_t smoothratio)
if (VOLUMEONE)
{
if (g_showShareware > 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
if (show_shareware > 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
rotatesprite_fs((320-50)<<16, 9<<16, 65536L, 0, TILE_BETAVERSION, 0, 0, 2+8+16+128);
}