| 1586 | } |
| 1587 | |
| 1588 | static void parseModel(FScanner& sc, FScriptPosition& pos) |
| 1589 | { |
| 1590 | FScanner::SavedPos blockend; |
| 1591 | |
| 1592 | FString modelfn; |
| 1593 | double scale = 1.0, mzadd = 0.0, myoffset = 0.0; |
| 1594 | int32_t shadeoffs = 0, flags = 0; |
| 1595 | FixedBitArray<1024> usedframes; |
| 1596 | |
| 1597 | usedframes.Zero(); |
| 1598 | mdglobal.modelskin = mdglobal.lastmodelskin = 0; |
| 1599 | mdglobal.seenframe = 0; |
| 1600 | |
| 1601 | if (!sc.GetString(modelfn)) return; |
| 1602 | |
| 1603 | if (sc.StartBraces(&blockend)) return; |
| 1604 | |
| 1605 | mdglobal.lastmodelid = modelManager.LoadModel(modelfn.GetChars()); |
| 1606 | if (mdglobal.lastmodelid < 0) |
| 1607 | { |
| 1608 | pos.Message(MSG_WARNING, "Unable to load model file '%s'", modelfn.GetChars()); |
| 1609 | sc.RestorePos(blockend); |
| 1610 | sc.CheckString("}"); |
| 1611 | return; |
| 1612 | } |
| 1613 | |
| 1614 | bool ok = true; |
| 1615 | while (!sc.FoundEndBrace(blockend)) |
| 1616 | { |
| 1617 | sc.MustGetString(); |
| 1618 | if (sc.Compare("scale")) sc.GetFloat(scale, true); |
| 1619 | else if (sc.Compare("shade")) sc.GetNumber(shadeoffs, true); |
| 1620 | else if (sc.Compare("zadd")) sc.GetFloat(mzadd, true); |
| 1621 | else if (sc.Compare("yoffset")) sc.GetFloat(myoffset, true); |
| 1622 | else if (sc.Compare("frame")) ok &= parseModelFrameBlock(sc, usedframes); |
| 1623 | else if (sc.Compare("anim")) ok &= parseModelAnimBlock(sc); |
| 1624 | else if (sc.Compare("skin")) ok &= parseModelSkinBlock(sc, 0); |
| 1625 | else if (sc.Compare("detail")) ok &= parseModelSkinBlock(sc, DETAILPAL); |
| 1626 | else if (sc.Compare("glow")) ok &= parseModelSkinBlock(sc, GLOWPAL); |
| 1627 | else if (sc.Compare("specular")) ok &= parseModelSkinBlock(sc, SPECULARPAL); |
| 1628 | else if (sc.Compare("normal")) ok &= parseModelSkinBlock(sc, NORMALPAL); |
| 1629 | else if (sc.Compare("hud")) ok &= parseModelHudBlock(sc); |
| 1630 | else if (sc.Compare("flags")) sc.GetNumber(flags, true); |
| 1631 | } |
| 1632 | |
| 1633 | if (!ok) |
| 1634 | { |
| 1635 | if (mdglobal.lastmodelid >= 0) |
| 1636 | { |
| 1637 | pos.Message(MSG_ERROR, "Removing model %d due to errors.", mdglobal.lastmodelid); |
| 1638 | modelManager.UndefineModel(mdglobal.lastmodelid); |
| 1639 | } |
| 1640 | } |
| 1641 | else |
| 1642 | { |
| 1643 | modelManager.SetMisc(mdglobal.lastmodelid, (float)scale, shadeoffs, (float)mzadd, (float)myoffset, flags); |
| 1644 | mdglobal.modelskin = mdglobal.lastmodelskin = 0; |
| 1645 | mdglobal.seenframe = 0; |
nothing calls this directly
no test coverage detected