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

Method InitFromFile

neo/renderer/Model_liquid.cpp:345–460  ·  view source on GitHub ↗

==================== idRenderModelLiquid::InitFromFile ==================== */

Source from the content-addressed store, hash-verified

343====================
344*/
345void idRenderModelLiquid::InitFromFile( const char *fileName ) {
346 int i, x, y;
347 idToken token;
348 idParser parser( LEXFL_ALLOWPATHNAMES | LEXFL_NOSTRINGESCAPECHARS );
349 idList<int> tris;
350 float size_x, size_y;
351 float rate;
352
353 name = fileName;
354
355 if ( !parser.LoadFile( fileName ) ) {
356 MakeDefaultModel();
357 return;
358 }
359
360 size_x = scale_x * verts_x;
361 size_y = scale_y * verts_y;
362
363 while( parser.ReadToken( &token ) ) {
364 if ( !token.Icmp( "seed" ) ) {
365 seed = parser.ParseInt();
366 } else if ( !token.Icmp( "size_x" ) ) {
367 size_x = parser.ParseFloat();
368 } else if ( !token.Icmp( "size_y" ) ) {
369 size_y = parser.ParseFloat();
370 } else if ( !token.Icmp( "verts_x" ) ) {
371 verts_x = parser.ParseFloat();
372 if ( verts_x < 2 ) {
373 parser.Warning( "Invalid # of verts. Using default model." );
374 MakeDefaultModel();
375 return;
376 }
377 } else if ( !token.Icmp( "verts_y" ) ) {
378 verts_y = parser.ParseFloat();
379 if ( verts_y < 2 ) {
380 parser.Warning( "Invalid # of verts. Using default model." );
381 MakeDefaultModel();
382 return;
383 }
384 } else if ( !token.Icmp( "liquid_type" ) ) {
385 liquid_type = parser.ParseInt() - 1;
386 if ( ( liquid_type < 0 ) || ( liquid_type >= LIQUID_MAX_TYPES ) ) {
387 parser.Warning( "Invalid liquid_type. Using default model." );
388 MakeDefaultModel();
389 return;
390 }
391 } else if ( !token.Icmp( "density" ) ) {
392 density = parser.ParseFloat();
393 } else if ( !token.Icmp( "drop_height" ) ) {
394 drop_height = parser.ParseFloat();
395 } else if ( !token.Icmp( "drop_radius" ) ) {
396 drop_radius = parser.ParseInt();
397 } else if ( !token.Icmp( "drop_delay" ) ) {
398 drop_delay = SEC2MS( parser.ParseFloat() );
399 } else if ( !token.Icmp( "shader" ) ) {
400 parser.ReadToken( &token );
401 shader = declManager->FindMaterial( token );
402 } else if ( !token.Icmp( "update_rate" ) ) {

Callers

nothing calls this directly

Calls 15

R_BuildDeformInfoFunction · 0.85
ReadFileMethod · 0.80
IcmpMethod · 0.60
idVec3Class · 0.50
LoadFileMethod · 0.45
ReadTokenMethod · 0.45
ParseIntMethod · 0.45
ParseFloatMethod · 0.45
WarningMethod · 0.45
FindMaterialMethod · 0.45
c_strMethod · 0.45
SetNumMethod · 0.45

Tested by

no test coverage detected