MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / Parse

Method Parse

neo/idlib/MapFile.cpp:111–214  ·  view source on GitHub ↗

================= idMapPatch::Parse ================= */

Source from the content-addressed store, hash-verified

109=================
110*/
111idMapPatch *idMapPatch::Parse( idLexer &src, const idVec3 &origin, bool patchDef3, float version ) {
112 float info[7];
113 idDrawVert *vert;
114 idToken token;
115 int i, j;
116
117 if ( !src.ExpectTokenString( "{" ) ) {
118 return NULL;
119 }
120
121 // read the material (we had an implicit 'textures/' in the old format...)
122 if ( !src.ReadToken( &token ) ) {
123 src.Error( "idMapPatch::Parse: unexpected EOF" );
124 return NULL;
125 }
126
127 // Parse it
128 if (patchDef3) {
129 if ( !src.Parse1DMatrix( 7, info ) ) {
130 src.Error( "idMapPatch::Parse: unable to Parse patchDef3 info" );
131 return NULL;
132 }
133 } else {
134 if ( !src.Parse1DMatrix( 5, info ) ) {
135 src.Error( "idMapPatch::Parse: unable to parse patchDef2 info" );
136 return NULL;
137 }
138 }
139
140 idMapPatch *patch = new idMapPatch( info[0], info[1] );
141 patch->SetSize( info[0], info[1] );
142 if ( version < 2.0f ) {
143 patch->SetMaterial( "textures/" + token );
144 } else {
145 patch->SetMaterial( token );
146 }
147
148 if ( patchDef3 ) {
149 patch->SetHorzSubdivisions( info[2] );
150 patch->SetVertSubdivisions( info[3] );
151 patch->SetExplicitlySubdivided( true );
152 }
153
154 if ( patch->GetWidth() < 0 || patch->GetHeight() < 0 ) {
155 src.Error( "idMapPatch::Parse: bad size" );
156 delete patch;
157 return NULL;
158 }
159
160 // these were written out in the wrong order, IMHO
161 if ( !src.ExpectTokenString( "(" ) ) {
162 src.Error( "idMapPatch::Parse: bad patch vertex data" );
163 delete patch;
164 return NULL;
165 }
166 for ( j = 0; j < patch->GetWidth(); j++ ) {
167 if ( !src.ExpectTokenString( "(" ) ) {
168 src.Error( "idMapPatch::Parse: bad vertex row data" );

Callers

nothing calls this directly

Calls 15

vaFunction · 0.85
SetHorzSubdivisionsMethod · 0.80
SetVertSubdivisionsMethod · 0.80
GetWidthMethod · 0.80
AddSideMethod · 0.80
AddPrimitiveMethod · 0.80
GetFloatValueMethod · 0.80
MatchPrefixMethod · 0.80
GetNumPrimitivesMethod · 0.80
GetPrimitiveMethod · 0.80

Tested by

no test coverage detected