eclass_t *Eclass_ForName (const char *name, bool has_brushes) { eclass_t *e; char buff[1024]; if (!name) { return eclass_bad; } for ( e = eclass; e; e = e->next ) { if ( !strcmp( name, e->name ) ) { return e; } } e = EClass_Alloc(); if ( !e ) { return NULL; } e->name = Mem_CopyString( name ); sprintf(buff, "%s not found in def/*.def\n", name); e->comments = Mem_CopyString( buff ); e->color.x = 0.0f; e->color.y = 0.5f; e->color.z = 0.0f; e->fixedsize = !has_brushes; e->mins.x = e->mins.y = e->mins.z = -8.0f; e->maxs.x = e->maxs.y = e->maxs.z = 8.0f; Eclass_InsertAlphabetized( e ); return e; }
void Eclass_InitForSourceDirectory( const char *path ) { int c = declManager->GetNumDecls( DECL_ENTITYDEF ); for( int i = 0; i < c; i++ ) { const idDeclEntityDef *def = static_cast<const idDeclEntityDef *>( declManager->DeclByIndex( DECL_ENTITYDEF, i ) ); if( def ) { eclass_t *e = EClass_InitFromDict( &def->dict, def->GetName() ); if( e ) { Eclass_InsertAlphabetized( e ); } } } eclass_bad = EClass_Alloc(); if( !eclass_bad ) { return; } eclass_bad->color.x = 0.0f; eclass_bad->color.y = 0.5f; eclass_bad->color.z = 0.0f; eclass_bad->fixedsize = false; eclass_bad->name = Mem_CopyString( "UKNOWN ENTITY CLASS" ); }
eclass_t *EClass_InitFromDict( const idDict *d, const char *name ) { eclass_t *e; const idKeyValue *kv; // only include entityDefs with "editor_" values in them if ( !d->MatchPrefix( "editor_" ) ) { return NULL; } e = EClass_Alloc(); if ( !e ) { return NULL; } e->defArgs = *d; idStr str; idStr text; idStr varname; idStr defaultStr; e->name = name; d->GetVector("editor_color", "0 0 1", e->color); d->GetString("editor_mins", "", str); if (str != "?") { d->GetVector("editor_mins", "0 0 0", e->mins); d->GetVector("editor_maxs", "0 0 0", e->maxs); e->fixedsize = true; } else { e->fixedsize = false; } d->GetString("editor_material", "", e->defMaterial); //str = d->GetString("model"); //if (str.Length()) { // e->entityModel = renderModelManager->FindModel(str); //} str = ""; // concatenate all editor usage comments text = ""; kv = d->MatchPrefix( "editor_usage" ); while( kv != NULL ) { text += kv->GetValue(); if ( !kv->GetValue().Length() || ( text[ text.Length() - 1 ] != '\n' ) ) { text += "\n"; } kv = d->MatchPrefix( "editor_usage", kv ); } e->desc = text; str += "Spawn args:\n"; for (int i = 0; i < NumEvarPrefixes; i++) { kv = d->MatchPrefix(EvarPrefixes[i].prefix); while (kv) { evar_t ev; kv->GetKey().Right( kv->GetKey().Length() - strlen(EvarPrefixes[i].prefix), ev.name ); ev.desc = kv->GetValue(); ev.type = EvarPrefixes[i].type; e->vars.Append(ev); kv = d->MatchPrefix(EvarPrefixes[i].prefix, kv); } } /* while( kv != NULL ) { kv->key.Right( kv->key.Length() - 11, varname ); str += va( "'%s':\t %s", varname.c_str(), kv->value.c_str() ); if ( d->GetString( varname, "", defaultStr ) && defaultStr.Length() ) { str += va( " Default '%s'.", defaultStr.c_str() ); } str += "\n"; kv = d->MatchPrefix( "editor_var ", kv ); } e->comments = Mem_CopyString( str.c_str() ); */ // concatenate all variable comments kv = d->MatchPrefix( "editor_copy" ); while (kv) { const char *temp = d->GetString(kv->GetValue()); if (temp && *temp) { e->args.Set(kv->GetValue(), d->GetString(kv->GetValue())); } kv = d->MatchPrefix("editor_copy", kv); } // setup show flags e->nShowFlags = 0; if (d->GetBool("editor_rotatable")) { e->nShowFlags |= ECLASS_ROTATABLE; } if (d->GetBool("editor_showangle")) { e->nShowFlags |= ECLASS_ANGLE; } if (d->GetBool("editor_mover")) { e->nShowFlags |= ECLASS_MOVER; } if (d->GetBool("editor_env") || idStr::Icmpn(e->name, "env_", 4) == 0) { e->nShowFlags |= (ECLASS_ENV | ECLASS_ROTATABLE); if (d->GetBool("editor_ragdoll")) { e->defArgs.Set("model", ""); } } if (d->GetBool("editor_combatnode")) { e->nShowFlags |= ECLASS_COMBATNODE; } if (d->GetBool("editor_light")) { e->nShowFlags |= ECLASS_LIGHT; } if ( idStr::Icmp(e->name, "light") == 0 ) { e->nShowFlags |= ECLASS_LIGHT; } else if ( idStr::Icmp(e->name, "path") == 0 ) { e->nShowFlags |= ECLASS_PATH; } else if ( idStr::Icmp(e->name, "target_null") == 0 ) { e->nShowFlags |= ECLASS_CAMERAVIEW; } else if ( idStr::Icmp(e->name, "worldspawn") == 0 ) { e->nShowFlags |= ECLASS_WORLDSPAWN; } else if ( idStr::Icmp(e->name, "speaker") == 0 ) { e->nShowFlags |= ECLASS_SPEAKER; } else if ( idStr::Icmp( e->name, "func_emitter" ) == 0 || idStr::Icmp( e->name, "func_splat" ) == 0 ) { e->nShowFlags |= ECLASS_PARTICLE; } else if ( idStr::Icmp(e->name, "func_liquid") == 0 ) { e->nShowFlags |= ECLASS_LIQUID; } return e; }