MCPcopy Create free account
hub / github.com/ZDoom/gzdoom / ParseModelDefLump

Function ParseModelDefLump

src/r_data/models.cpp:704–1110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702}
703
704void ParseModelDefLump(int Lump)
705{
706 FScanner sc(Lump);
707 while (sc.GetString())
708 {
709 if (sc.Compare("model"))
710 {
711 int index, surface;
712 FString path = "";
713 sc.MustGetString();
714
715 FSpriteModelFrame smf;
716 memset(&smf, 0, sizeof(smf));
717 smf.xscale=smf.yscale=smf.zscale=1.f;
718
719 auto type = PClass::FindClass(sc.String);
720 if (!type || type->Defaults == nullptr)
721 {
722 sc.ScriptError("MODELDEF: Unknown actor type '%s'\n", sc.String);
723 }
724 smf.type = type;
725 FScanner::SavedPos scPos = sc.SavePos();
726 sc.MustGetStringName("{");
727 while (!sc.CheckString("}"))
728 {
729 sc.MustGetString();
730 if (sc.Compare("model"))
731 {
732 sc.MustGetNumber();
733 index = sc.Number;
734 if (index < 0)
735 {
736 sc.ScriptError("Model index must be 0 or greater in %s", type->TypeName.GetChars());
737 }
738 smf.modelsAmount = index + 1;
739 }
740 }
741 //Make sure modelsAmount is at least equal to MIN_MODELS(4) to ensure compatibility with old mods
742 if (smf.modelsAmount < MIN_MODELS)
743 {
744 smf.modelsAmount = MIN_MODELS;
745 }
746
747 const auto initArray = [](auto& array, const unsigned count, const auto value)
748 {
749 array.Alloc(count);
750 std::fill(array.begin(), array.end(), value);
751 };
752
753 initArray(smf.modelIDs, smf.modelsAmount, -1);
754 initArray(smf.skinIDs, smf.modelsAmount, FNullTextureID());
755 initArray(smf.surfaceskinIDs, smf.modelsAmount * MD3_MAX_SURFACES, FNullTextureID());
756 initArray(smf.animationIDs, smf.modelsAmount, -1);
757 initArray(smf.modelframes, smf.modelsAmount, 0);
758
759 sc.RestorePos(scPos);
760 sc.MustGetStringName("{");
761 while (!sc.CheckString("}"))

Callers 1

InitModelsFunction · 0.85

Calls 15

FNullTextureIDClass · 0.85
FindModelFunction · 0.85
PrintfFunction · 0.85
LoadSkinFunction · 0.85
GetDefaultByTypeFunction · 0.85
MustGetStringMethod · 0.80
ScriptErrorMethod · 0.80
SavePosMethod · 0.80
MustGetStringNameMethod · 0.80
MustGetNumberMethod · 0.80
RestorePosMethod · 0.80
LenMethod · 0.80

Tested by

no test coverage detected