Follow-up to RTS cleanup: factor out 2x almost-same code into G_StartRTS().

git-svn-id: https://svn.eduke32.com/eduke32@4279 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-01-30 19:12:10 +00:00
parent da6c7109c1
commit bebdc6ff4f
4 changed files with 40 additions and 40 deletions

View file

@ -8456,6 +8456,28 @@ void G_InitTimer(int32_t ticspersec)
}
}
static int32_t g_RTSPlaying;
// Returns: started playing?
int32_t G_StartRTS(int32_t i, int localp)
{
if (!ud.lockout && ud.config.FXDevice >= 0 && ud.config.SoundToggle &&
RTS_IsInitialized() && g_RTSPlaying == 0 && (ud.config.VoiceToggle & (localp ? 1 : 4)))
{
char *sndptr = (char *)RTS_GetSound(i-1);
if (sndptr != NULL)
{
FX_PlayAuto3D(sndptr, RTS_SoundLength(i-1), FX_ONESHOT, 0, 0, FX_VOLUME(1), 255, -i);
g_RTSPlaying = 7;
return 1;
}
}
return 0;
}
void G_HandleLocalKeys(void)
{
int32_t i,ch;
@ -8719,16 +8741,8 @@ void G_HandleLocalKeys(void)
}
// Not SHIFT -- that is, either some ALT or WIN.
if (!ud.lockout && ud.config.SoundToggle &&
RTS_IsInitialized() && g_RTSPlaying == 0 && (ud.config.VoiceToggle & 1))
if (G_StartRTS(i, 1))
{
char *sndptr = (char *)RTS_GetSound(i-1);
if (sndptr != NULL)
{
FX_PlayAuto3D(sndptr, RTS_SoundLength(i-1), FX_ONESHOT, 0, 0, FX_VOLUME(1), 255, -i);
g_RTSPlaying = 7;
#ifndef NETCODE_DISABLE
if ((g_netServer || ud.multimode > 1))
{
@ -8749,11 +8763,9 @@ void G_HandleLocalKeys(void)
}
}
}
}
if (!ALT_IS_PRESSED && !SHIFTS_IS_PRESSED && !WIN_IS_PRESSED)
{
if ((g_netServer || ud.multimode > 1) && BUTTON(gamefunc_SendMessage))
{
KB_FlushKeyboardQueue();

View file

@ -413,6 +413,8 @@ extern char forcegl;
#define Net_EnterText(x, y, t, dalen, c) _EnterText(1,x,y,t,dalen,c)
#define S_StopSound(num) S_StopEnvSound(num, -1)
extern int32_t G_StartRTS(int32_t i, int localp);
extern void G_MaybeAllocPlayer(int32_t pnum);
static inline void G_HandleAsync(void)

View file

@ -59,7 +59,6 @@ G_EXTERN animwalltype animwall[MAXANIMWALLS];
G_EXTERN char *ScriptQuotes[MAXQUOTES],*ScriptQuoteRedefinitions[MAXQUOTES];
G_EXTERN char *label;
G_EXTERN char EnvMusicFilename[MAXVOLUMES+1][BMAX_PATH];
G_EXTERN char g_RTSPlaying;
G_EXTERN int32_t g_musicIndex;
G_EXTERN char g_loadFromGroupOnly;
G_EXTERN char g_numSkills;

View file

@ -682,20 +682,7 @@ void Net_ParsePacketCommon(uint8_t *pbuf, int32_t packbufleng, int32_t serverpac
break;
case PACKET_RTS:
if (!RTS_IsInitialized())
break;
if (ud.config.SoundToggle == 0 || ud.lockout == 1 || ud.config.FXDevice < 0 || !(ud.config.VoiceToggle & 4))
break;
{
char *sndptr = (char *)RTS_GetSound(pbuf[1]-1);
if (sndptr != NULL)
{
FX_PlayAuto3D(sndptr, RTS_SoundLength(pbuf[1]-1), FX_ONESHOT, 0, 0, FX_VOLUME(1), 255, -pbuf[1]);
g_RTSPlaying = 7;
}
}
G_StartRTS(pbuf[1], 0);
break;
case PACKET_USER_MAP: