mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-05-30 00:41:19 +00:00
* Updated to ZDoom r4318:
- Added more string functions to ACS: strcmp, stricmp (aka strcasecmp), strleft, strright, and strmid. - Clean up excess code around a few calls to SingleActorFromTID(), since that function is already designed specifically to handle the case where tid is 0. - Added GetActorClass and GetWeapon functions to ACS. - Added S_ChangeSoundVolume() to change the volume of an already playing sound, accessible through the new ACS function SoundVolume. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1587 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
915b50bb25
commit
4af7bc0386
8 changed files with 171 additions and 6 deletions
123
src/p_acs.cpp
123
src/p_acs.cpp
|
@ -4127,6 +4127,14 @@ enum EACSFunctions
|
|||
ACSF_LineAttack,
|
||||
ACSF_PlaySound,
|
||||
ACSF_StopSound,
|
||||
ACSF_strcmp,
|
||||
ACSF_stricmp,
|
||||
ACSF_StrLeft,
|
||||
ACSF_StrRight,
|
||||
ACSF_StrMid,
|
||||
ACSF_GetActorClass,
|
||||
ACSF_GetWeapon,
|
||||
ACSF_SoundVolume,
|
||||
|
||||
// ZDaemon
|
||||
ACSF_GetTeamScore = 19620, // (int team)
|
||||
|
@ -4593,7 +4601,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
|
|||
FName varname(FBehavior::StaticLookupString(args[1]), true);
|
||||
if (varname != NAME_None)
|
||||
{
|
||||
AActor *a = args[0] == 0 ? (AActor *)activator : SingleActorFromTID(args[0], NULL);
|
||||
AActor *a = SingleActorFromTID(args[0], activator);
|
||||
return a != NULL ? GetUserVariable(a, varname, 0) : 0;
|
||||
}
|
||||
return 0;
|
||||
|
@ -4632,7 +4640,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
|
|||
FName varname(FBehavior::StaticLookupString(args[1]), true);
|
||||
if (varname != NAME_None)
|
||||
{
|
||||
AActor *a = args[0] == 0 ? (AActor *)activator : SingleActorFromTID(args[0], NULL);
|
||||
AActor *a = SingleActorFromTID(args[0], activator);
|
||||
return a != NULL ? GetUserVariable(a, varname, args[2]) : 0;
|
||||
}
|
||||
return 0;
|
||||
|
@ -4644,10 +4652,16 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
|
|||
|
||||
case ACSF_CheckActorClass:
|
||||
{
|
||||
AActor *a = args[0] == 0 ? (AActor *)activator : SingleActorFromTID(args[0], NULL);
|
||||
AActor *a = SingleActorFromTID(args[0], activator);
|
||||
return a == NULL ? false : a->GetClass()->TypeName == FName(FBehavior::StaticLookupString(args[1]));
|
||||
}
|
||||
|
||||
case ACSF_GetActorClass:
|
||||
{
|
||||
AActor *a = SingleActorFromTID(args[0], activator);
|
||||
return GlobalACSStrings.AddString(a == NULL ? "None" : a->GetClass()->TypeName.GetChars());
|
||||
}
|
||||
|
||||
case ACSF_SoundSequenceOnActor:
|
||||
{
|
||||
const char *seqname = FBehavior::StaticLookupString(args[1]);
|
||||
|
@ -4951,6 +4965,109 @@ doplaysound: if (!looping)
|
|||
}
|
||||
break;
|
||||
|
||||
case ACSF_SoundVolume:
|
||||
// SoundVolume(int tid, int channel, fixed volume)
|
||||
{
|
||||
int chan = args[1];
|
||||
float volume = FIXED2FLOAT(args[2]);
|
||||
|
||||
if (args[0] == 0)
|
||||
{
|
||||
S_ChangeSoundVolume(activator, chan, volume);
|
||||
}
|
||||
else
|
||||
{
|
||||
FActorIterator it(args[0]);
|
||||
AActor *spot;
|
||||
|
||||
while ((spot = it.Next()) != NULL)
|
||||
{
|
||||
S_ChangeSoundVolume(spot, chan, volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ACSF_strcmp:
|
||||
case ACSF_stricmp:
|
||||
if (argCount >= 2)
|
||||
{
|
||||
const char *a, *b;
|
||||
a = FBehavior::StaticLookupString(args[0]);
|
||||
b = FBehavior::StaticLookupString(args[1]);
|
||||
|
||||
// Don't crash on invalid strings.
|
||||
if (a == NULL) a = "";
|
||||
if (b == NULL) b = "";
|
||||
|
||||
if (argCount > 2)
|
||||
{
|
||||
int n = args[2];
|
||||
return (funcIndex == ACSF_strcmp) ? strncmp(a, b, n) : strnicmp(a, b, n);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (funcIndex == ACSF_strcmp) ? strcmp(a, b) : stricmp(a, b);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ACSF_StrLeft:
|
||||
case ACSF_StrRight:
|
||||
if (argCount >= 2)
|
||||
{
|
||||
const char *oldstr = FBehavior::StaticLookupString(args[0]);
|
||||
if (oldstr == NULL || *oldstr == '\0')
|
||||
{
|
||||
return GlobalACSStrings.AddString("");
|
||||
}
|
||||
size_t oldlen = strlen(oldstr);
|
||||
size_t newlen = args[1];
|
||||
|
||||
if (oldlen < newlen)
|
||||
{
|
||||
newlen = oldlen;
|
||||
}
|
||||
FString newstr(funcIndex == ACSF_StrLeft ? oldstr : oldstr + oldlen - newlen, newlen);
|
||||
return GlobalACSStrings.AddString(newstr);
|
||||
}
|
||||
break;
|
||||
|
||||
case ACSF_StrMid:
|
||||
if (argCount >= 3)
|
||||
{
|
||||
const char *oldstr = FBehavior::StaticLookupString(args[0]);
|
||||
if (oldstr == NULL || *oldstr == '\0')
|
||||
{
|
||||
return GlobalACSStrings.AddString("");
|
||||
}
|
||||
size_t oldlen = strlen(oldstr);
|
||||
size_t pos = args[1];
|
||||
size_t newlen = args[2];
|
||||
|
||||
if (pos >= oldlen)
|
||||
{
|
||||
return GlobalACSStrings.AddString("");
|
||||
}
|
||||
if (pos + newlen > oldlen || pos + newlen < pos)
|
||||
{
|
||||
newlen = oldlen - pos;
|
||||
}
|
||||
return GlobalACSStrings.AddString(FString(oldstr + pos, newlen));
|
||||
}
|
||||
break;
|
||||
|
||||
case ACSF_GetWeapon:
|
||||
if (activator == NULL || activator->player == NULL || // Non-players do not have weapons
|
||||
activator->player->ReadyWeapon == NULL)
|
||||
{
|
||||
return GlobalACSStrings.AddString("None");
|
||||
}
|
||||
else
|
||||
{
|
||||
return GlobalACSStrings.AddString(activator->player->ReadyWeapon->GetClass()->TypeName.GetChars());
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1592,6 +1592,29 @@ void S_RelinkSound (AActor *from, AActor *to)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// S_ChangeSoundVolume
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool S_ChangeSoundVolume(AActor *actor, int channel, float volume)
|
||||
{
|
||||
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
|
||||
{
|
||||
if (chan->SourceType == SOURCE_Actor &&
|
||||
chan->Actor == actor &&
|
||||
(chan->EntChannel == channel || (i_compatflags & COMPATF_MAGICSILENCE)))
|
||||
{
|
||||
GSnd->ChannelVolume(chan, volume);
|
||||
chan->Volume = volume;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// S_GetSoundPlayingInfo
|
||||
|
@ -2136,7 +2159,6 @@ void S_StopChannel(FSoundChan *chan)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// (FArchive &) << (FSoundID &)
|
||||
|
|
|
@ -303,6 +303,9 @@ bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id);
|
|||
|
||||
bool S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id);
|
||||
|
||||
// Change a playing sound's volume
|
||||
bool S_ChangeSoundVolume(AActor *actor, int channel, float volume);
|
||||
|
||||
// Moves all sounds from one mobj to another
|
||||
void S_RelinkSound (AActor *from, AActor *to);
|
||||
|
||||
|
|
|
@ -2053,6 +2053,20 @@ void FMODSoundRenderer::StopChannel(FISoundChannel *chan)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FMODSoundRenderer :: ChannelVolume
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FMODSoundRenderer::ChannelVolume(FISoundChannel *chan, float volume)
|
||||
{
|
||||
if (chan != NULL && chan->SysChannel != NULL)
|
||||
{
|
||||
((FMOD::Channel *)chan->SysChannel)->setVolume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FMODSoundRenderer :: GetPosition
|
||||
|
|
|
@ -33,6 +33,9 @@ public:
|
|||
// Stops a sound channel.
|
||||
void StopChannel (FISoundChannel *chan);
|
||||
|
||||
// Changes a channel's volume.
|
||||
void ChannelVolume (FISoundChannel *chan, float volume);
|
||||
|
||||
// Marks a channel's start time without actually playing it.
|
||||
void MarkStartTime (FISoundChannel *chan);
|
||||
|
||||
|
|
|
@ -150,6 +150,9 @@ public:
|
|||
void StopChannel(FISoundChannel *chan)
|
||||
{
|
||||
}
|
||||
void ChannelVolume(FISoundChannel *, float)
|
||||
{
|
||||
}
|
||||
|
||||
// Streaming sounds.
|
||||
SoundStream *CreateStream (SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata)
|
||||
|
|
|
@ -110,6 +110,9 @@ public:
|
|||
// Stops a sound channel.
|
||||
virtual void StopChannel (FISoundChannel *chan) = 0;
|
||||
|
||||
// Changes a channel's volume.
|
||||
virtual void ChannelVolume (FISoundChannel *chan, float volume) = 0;
|
||||
|
||||
// Marks a channel's start time without actually playing it.
|
||||
virtual void MarkStartTime (FISoundChannel *chan) = 0;
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
// This file was automatically generated by the
|
||||
// updaterevision tool. Do not edit by hand.
|
||||
|
||||
#define ZD_SVN_REVISION_STRING "4310"
|
||||
#define ZD_SVN_REVISION_NUMBER 4310
|
||||
#define ZD_SVN_REVISION_STRING "4318"
|
||||
#define ZD_SVN_REVISION_NUMBER 4318
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue