- Rewrote a bunch of things for stability.

This commit is contained in:
MajorCooke 2014-12-17 21:47:00 -06:00
commit 93ca8502dd
7 changed files with 117 additions and 17 deletions

View file

@ -4438,6 +4438,8 @@ enum EACSFunctions
ACSF_PickActor,
ACSF_IsPointerEqual,
ACSF_CanRaiseActor,
ACSF_SetActorTeleFog, // 86
ACSF_SwapActorTeleFog,
/* Zandronum's - these must be skipped when we reach 99!
-100:ResetMap(0),
@ -4749,6 +4751,72 @@ static void SetActorPitch(AActor *activator, int tid, int angle, bool interpolat
}
}
static void SetActorTeleFog(AActor *activator, int tid, FName telefogsrc, FName telefogdest)
{
//Simply put, if it doesn't exist, it won't change. One can use "" in this scenario.
const PClass *check;
if (tid == 0)
{
if (activator != NULL)
{
check = PClass::FindClass(telefogsrc);
if (check != NULL)
activator->TeleFogSourceType = check;
check = PClass::FindClass(telefogdest);
if (check != NULL)
activator->TeleFogDestType = check;
}
}
else
{
FActorIterator iterator(tid);
AActor *actor;
while ((actor = iterator.Next()))
{
check = PClass::FindClass(telefogsrc);
if (check != NULL)
activator->TeleFogSourceType = check;
check = PClass::FindClass(telefogdest);
if (check != NULL)
activator->TeleFogDestType = check;
}
}
}
static int SwapActorTeleFog(AActor *activator, int tid)
{
int count = 0;
if (tid == 0)
{
if ((activator == NULL) || (activator->TeleFogSourceType = activator->TeleFogDestType))
return 0; //Does nothing if they're the same.
else
{
const PClass *temp = activator->TeleFogSourceType;
activator->TeleFogSourceType = activator->TeleFogDestType;
activator->TeleFogDestType = temp;
return 1;
}
}
else
{
FActorIterator iterator(tid);
AActor *actor;
while ((actor = iterator.Next()))
{
if (activator->TeleFogSourceType == activator->TeleFogDestType)
continue; //They're the same. Save the effort.
const PClass *temp = activator->TeleFogSourceType;
activator->TeleFogSourceType = activator->TeleFogDestType;
activator->TeleFogDestType = temp;
count++;
}
}
return count;
}
int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const SDWORD *stack, int stackdepth)
@ -5662,7 +5730,18 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
SetActorPitch(activator, args[0], args[1], argCount > 2 ? !!args[2] : false);
}
break;
case ACSF_SetActorTeleFog:
if (argCount >= 3)
{
SetActorTeleFog(activator, args[0], FBehavior::StaticLookupString(args[1]), FBehavior::StaticLookupString(args[2]));
}
break;
case ACSF_SwapActorTeleFog:
if (argCount >= 1)
{
return SwapActorTeleFog(activator, args[0]);
}
break;
case ACSF_PickActor:
if (argCount >= 5)
{