- Fixed: The save percentage for Doom's green armor was slightly too low
which caused roundoff errors that made it less than 1/3 effective. - Added support for "RRGGBB" strings to V_GetColor. - Fixed: Desaturation maps for the TEXTURES lump were calculated incorrectly. - Changed GetSpriteIndex to cache the last used sprite name so that the code using this function doesn't have to do it itself. - Moved some more code for the state parser into p_states.cpp. - Fixed: TDeletingArray should not try to delete NULL pointers. SVN r1312 (trunk)
This commit is contained in:
parent
238de9cda1
commit
081658d3d5
24 changed files with 1978 additions and 1901 deletions
152
src/p_states.cpp
152
src/p_states.cpp
|
|
@ -366,17 +366,33 @@ FStateDefine * FStateDefinitions::FindStateAddress(const char *name)
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// Adds a new state tp the curremt list
|
||||
// Adds a new state to the curremt list
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FStateDefinitions::AddState (const char *statename, FState *state, BYTE defflags)
|
||||
void FStateDefinitions::SetStateLabel (const char *statename, FState *state, BYTE defflags)
|
||||
{
|
||||
FStateDefine *std = FindStateAddress(statename);
|
||||
std->State = state;
|
||||
std->DefineFlags = defflags;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Adds a new state to the curremt list
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FStateDefinitions::AddStateLabel (const char *statename)
|
||||
{
|
||||
intptr_t index = StateArray.Size();
|
||||
FStateDefine *std = FindStateAddress(statename);
|
||||
std->State = (FState *)(index+1);
|
||||
std->DefineFlags = SDF_INDEX;
|
||||
laststate = NULL;
|
||||
lastlabel = index;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Finds the state associated with the given name
|
||||
|
|
@ -457,7 +473,7 @@ void FStateDefinitions::InstallStates(FActorInfo *info, AActor *defaults)
|
|||
if (state == NULL)
|
||||
{
|
||||
// A NULL spawn state will crash the engine so set it to something valid.
|
||||
AddState("Spawn", GetDefault<AActor>()->SpawnState);
|
||||
SetStateLabel("Spawn", GetDefault<AActor>()->SpawnState);
|
||||
}
|
||||
|
||||
if (info->StateList != NULL)
|
||||
|
|
@ -505,13 +521,17 @@ void FStateDefinitions::MakeStateList(const FStateLabels *list, TArray<FStateDef
|
|||
|
||||
void FStateDefinitions::MakeStateDefines(const PClass *cls)
|
||||
{
|
||||
if (cls->ActorInfo && cls->ActorInfo->StateList)
|
||||
StateArray.Clear();
|
||||
laststate = NULL;
|
||||
lastlabel = -1;
|
||||
|
||||
if (cls != NULL && cls->ActorInfo != NULL && cls->ActorInfo->StateList != NULL)
|
||||
{
|
||||
MakeStateList(cls->ActorInfo->StateList, StateLabels);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearStateLabels();
|
||||
StateLabels.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -559,7 +579,7 @@ void FStateDefinitions::RetargetStatePointers (intptr_t count, const char *targe
|
|||
{
|
||||
for(unsigned i = 0;i<statelist.Size(); i++)
|
||||
{
|
||||
if (statelist[i].State == (FState*)count)
|
||||
if (statelist[i].State == (FState*)count && statelist[i].DefineFlags == SDF_INDEX)
|
||||
{
|
||||
if (target == NULL)
|
||||
{
|
||||
|
|
@ -709,6 +729,118 @@ void FStateDefinitions::ResolveGotoLabels (FActorInfo *actor, AActor *defaults,
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// SetGotoLabel
|
||||
//
|
||||
// sets a jump at the current state or retargets a label
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FStateDefinitions::SetGotoLabel(const char *string)
|
||||
{
|
||||
// copy the text - this must be resolved later!
|
||||
if (laststate != NULL)
|
||||
{ // Following a state definition: Modify it.
|
||||
laststate->NextState = (FState*)copystring(string);
|
||||
laststate->DefineFlags = SDF_LABEL;
|
||||
return true;
|
||||
}
|
||||
else if (lastlabel >= 0)
|
||||
{ // Following a label: Retarget it.
|
||||
RetargetStates (lastlabel+1, string);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// SetStop
|
||||
//
|
||||
// sets a stop operation
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FStateDefinitions::SetStop()
|
||||
{
|
||||
if (laststate != NULL)
|
||||
{
|
||||
laststate->DefineFlags = SDF_STOP;
|
||||
return true;
|
||||
}
|
||||
else if (lastlabel >=0)
|
||||
{
|
||||
RetargetStates (lastlabel+1, NULL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// SetWait
|
||||
//
|
||||
// sets a wait or fail operation
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FStateDefinitions::SetWait()
|
||||
{
|
||||
if (laststate != NULL)
|
||||
{
|
||||
laststate->DefineFlags = SDF_WAIT;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// SetLoop
|
||||
//
|
||||
// sets a loop operation
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FStateDefinitions::SetLoop()
|
||||
{
|
||||
if (laststate != NULL)
|
||||
{
|
||||
laststate->DefineFlags = SDF_INDEX;
|
||||
laststate->NextState = (FState*)(lastlabel+1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// AddStates
|
||||
// adds some state to the current definition set
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FStateDefinitions::AddStates(FState *state, const char *framechars)
|
||||
{
|
||||
bool error = false;
|
||||
while (*framechars)
|
||||
{
|
||||
int frame=((*framechars++)&223)-'A';
|
||||
|
||||
if (frame<0 || frame>28)
|
||||
{
|
||||
frame = 0;
|
||||
error = true;
|
||||
}
|
||||
|
||||
state->Frame=(state->Frame&(SF_FULLBRIGHT))|frame;
|
||||
StateArray.Push(*state);
|
||||
}
|
||||
laststate = &StateArray[StateArray.Size() - 1];
|
||||
return !error;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FinishStates
|
||||
|
|
@ -716,7 +848,7 @@ void FStateDefinitions::ResolveGotoLabels (FActorInfo *actor, AActor *defaults,
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults, TArray<FState> &StateArray)
|
||||
int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults)
|
||||
{
|
||||
static int c=0;
|
||||
int count = StateArray.Size();
|
||||
|
|
@ -770,6 +902,12 @@ int FStateDefinitions::FinishStates (FActorInfo *actor, AActor *defaults, TArray
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Prints all state label info to the logfile
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DumpStateHelper(FStateLabels *StateList, const FString &prefix)
|
||||
{
|
||||
for (int i = 0; i < StateList->NumLabels; i++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue