MCPcopy Create free account
hub / github.com/ZDoom/Raze / LoadMapHack

Function LoadMapHack

source/core/maphack.cpp:61–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites)
62{
63 int currentsprite = -1;
64 int currentwall = -1;
65 int currentsector = -1;
66 int numsprites = sprites.sprites.Size();
67
68 FScanner sc;
69 int lump = fileSystem.FindFile(filename);
70 if (lump < 0)
71 {
72 return -1;
73 }
74 sc.OpenLumpNum(lump);
75 sprites.sprext.Resize(numsprites);
76 memset(sprites.sprext.Data(), 0, sizeof(spriteext_t) * sprites.sprext.Size());
77
78 while (sc.GetString())
79 {
80 FString token = sc.String;
81 auto validateSprite = [&]()
82 {
83 if (currentsprite < 0 || currentsprite >= numsprites)
84 {
85 sc.ScriptMessage("Using %s without a valid sprite", token.GetChars());
86 return false;
87 }
88 return true;
89 };
90
91 auto validateWall = [&]()
92 {
93 if (currentwall < 0 || currentwall >= (int)wall.Size())
94 {
95 sc.ScriptMessage("Using %s without a valid wall", token.GetChars());
96 return false;
97 }
98 return true;
99 };
100
101 auto validateSector = [&]()
102 {
103 if (currentsector < 0 || currentsector >= (int)sector.Size())
104 {
105 sc.ScriptMessage("Using %s without a valid sector", token.GetChars());
106 return false;
107 }
108 return true;
109 };
110
111 if (sc.Compare("sprite"))
112 {
113 currentwall = -1;
114 currentsector = -1;
115 if (sc.CheckNumber())
116 {
117 currentsprite = sc.Number;
118 if ((unsigned)currentsprite >= sprites.sprites.Size())

Callers 1

loadMapHackFunction · 0.85

Calls 15

validWallIndexFunction · 0.85
validSectorIndexFunction · 0.85
validateSpriteFunction · 0.85
mapangleFunction · 0.85
FindFileMethod · 0.80
ScriptMessageMethod · 0.80
MustGetNumberMethod · 0.80
MustGetStringMethod · 0.80
SizeMethod · 0.45
ResizeMethod · 0.45
DataMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected