mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-19 08:01:50 +00:00
Changed static arrays to TArrays
- Made the models and skins arrays TArrays - The issue I described with models not always reverting to default properly was caused by the fact I was unintentionally overwriting smf data. Now intermediate TArrays store the data before the loop instead of overwriting anything
This commit is contained in:
parent
5abadd3aab
commit
c304a8f974
3 changed files with 26 additions and 10 deletions
|
@ -1069,8 +1069,8 @@ public:
|
|||
double Speed;
|
||||
double FloatSpeed;
|
||||
FName modelDef;
|
||||
int models[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; //[SM] - I hate this solution, but it get's the job done
|
||||
FTextureID skins[16];
|
||||
TArray<int> models;
|
||||
TArray <FTextureID> skins;
|
||||
|
||||
// interaction info
|
||||
FBlockNode *BlockNode; // links in blocks (if needed)
|
||||
|
|
|
@ -5055,8 +5055,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_ChangeModel)
|
|||
|
||||
mobj->hasmodel = modeldef == nullptr && !mobj->hasmodel ? 1 : 0;
|
||||
mobj->modelDef = modeldef;
|
||||
mobj->models[modelindex] = model != nullptr ? FindModel(modelpath.GetChars(), model.GetChars()) : -1;
|
||||
mobj->skins[skinindex] = skin != nullptr ? LoadSkin(skinpath.GetChars(), skin.GetChars()) : mobj->skins[skinindex] = FNullTextureID();
|
||||
|
||||
mobj->models.Delete(modelindex);
|
||||
mobj->skins.Delete(skinindex);
|
||||
if(model != nullptr) mobj->models.Insert(modelindex, FindModel(modelpath.GetChars(), model.GetChars()));
|
||||
else mobj->models.Insert(modelindex, -1);
|
||||
if(skin != nullptr) mobj->skins.Insert(skinindex, LoadSkin(skinpath.GetChars(), skin.GetChars()));
|
||||
else mobj->skins.Insert(skinindex, FNullTextureID());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -276,14 +276,25 @@ void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, const FSpr
|
|||
}
|
||||
}
|
||||
|
||||
//[SM] - these temporary arrays prevent actual smf data from being overwritten, which was the source of my problems
|
||||
TArray<int> tempModelIDs = smf->modelIDs;
|
||||
TArray<FTextureID> tempSkinIDs = smf->skinIDs;
|
||||
for (int i = 0; i < smf->modelsAmount; i++)
|
||||
{
|
||||
if (actor->models[i] != -1)
|
||||
smf->modelIDs[i] = actor->models[i];
|
||||
if (smf->modelIDs[i] != -1)
|
||||
{
|
||||
if (i < actor->models.Size())
|
||||
{
|
||||
FModel * mdl = Models[smf->modelIDs[i]];
|
||||
auto tex = actor->skins[i].isValid() ? TexMan.GetGameTexture(actor->skins[i], true) : smf->skinIDs[i].isValid() ? TexMan.GetGameTexture(smf->skinIDs[i], true) : nullptr;
|
||||
if (actor->models[i] >= 0)
|
||||
tempModelIDs[i] = actor->models[i];
|
||||
}
|
||||
if (tempModelIDs[i] != -1)
|
||||
{
|
||||
FModel * mdl = Models[tempModelIDs[i]];
|
||||
if (i < actor->skins.Size())
|
||||
{
|
||||
if (actor->skins[i].isValid())
|
||||
tempSkinIDs[i] = actor->skins[i];
|
||||
}
|
||||
auto tex = tempSkinIDs[i].isValid() ? TexMan.GetGameTexture(tempSkinIDs[i], true) : nullptr;
|
||||
mdl->BuildVertexBuffer(renderer);
|
||||
|
||||
mdl->PushSpriteMDLFrame(smf, i);
|
||||
|
|
Loading…
Reference in a new issue