void master_renderer::render_scene(const std::vector<jac::entity>& entities, const jac::player& player, const jac::terrain& terrain, const std::vector<light>& lights, const jac::camera& camera, const glm::vec4& clip_plane) { process_terrain(terrain); process_entity(player); for (const auto& e : entities) { process_entity(e); } render(lights, camera, clip_plane); }
/** * Parse a test afffected entity structure * * Startpoint is the \c G_TOKEN_LEFT_CURLY. * Endpoint is the last \c G_TOKEN_RIGHT_CURLY. * * @param tae address of structure SaHpiDimiTestAffectedEntityT * * @return bool value success * **/ bool NewSimulatorFileDimi::process_dimi_entities( SaHpiDimiTestAffectedEntityT &tae ) { bool success = true; char *field = NULL; guint cur_token = g_scanner_get_next_token(m_scanner); if (cur_token == G_TOKEN_STRING) { field = g_strdup(m_scanner->value.v_string); cur_token = g_scanner_get_next_token(m_scanner); if (cur_token != G_TOKEN_EQUAL_SIGN) { err("Processing dimi entities: Missing equal sign"); success = false; } cur_token = g_scanner_get_next_token(m_scanner); } else if (cur_token == G_TOKEN_RIGHT_CURLY) { err("Processing dimi entities: Empty entities field"); success = false; } else { err("Processing dimi entitier: Unknown token"); success = false; } while ((cur_token != G_TOKEN_RIGHT_CURLY) && success) { if (!strcmp( "EntityImpacted", field )) { if (cur_token == G_TOKEN_LEFT_CURLY) success = process_entity( tae.EntityImpacted ); if ( !success ) err("Processing entity in dimi entities returns false"); } else if (!strcmp( "ServiceImpact", field )) { if (cur_token == G_TOKEN_INT) tae.ServiceImpact = ( SaHpiDimiTestServiceImpactT ) m_scanner->value.v_int; } else { err("Processing dimi entities: unknown field %s", field); } // Take the next token cur_token = g_scanner_get_next_token(m_scanner); if (cur_token == G_TOKEN_STRING) { field = g_strdup(m_scanner->value.v_string); cur_token = g_scanner_get_next_token(m_scanner); if (cur_token != G_TOKEN_EQUAL_SIGN) { err("Processing dimi entities: Missing equal sign"); success = false; } cur_token = g_scanner_get_next_token(m_scanner); } } return success; }
/** * Parse the Fumi Data section * * Startpoint is the \c FUMI_DATA_TOKEN_HANDLER. Endpoint is the last \c G_TOKEN_RIGHT_CURLY. * * @return bool value success * **/ bool NewSimulatorFileFumi::process_fumi_data( NewSimulatorFumi *fumi ) { bool success = true; int start = m_depth; char *field; guint cur_token; SaHpiFumiSpecInfoT fumiSpec; SaHpiFumiSpecInfoTypeT fumiSpecType = SAHPI_FUMI_SPEC_INFO_NONE; SaHpiBoolT rollbDisabled = SAHPI_TRUE; SaHpiFumiServiceImpactDataT fumiImpact; unsigned int entCounter = 0; bool impactFlag = false; NewSimulatorFumiBank *fbank; memset( &fumiSpec, 0, sizeof( SaHpiFumiSpecInfoT )); memset( &fumiImpact, 0, sizeof( SaHpiFumiServiceImpactDataT )); cur_token = g_scanner_get_next_token(m_scanner); if (cur_token != G_TOKEN_EQUAL_SIGN) { err("Processing parse rdr entry: Missing equal sign"); success = false; } cur_token = g_scanner_get_next_token(m_scanner); if (cur_token != G_TOKEN_LEFT_CURLY) { err("Processing parse fumi rdr entry - Missing left curly in FumiData section"); success = false; } m_depth++; if (!success) return success; while ( (m_depth > start) && success ) { cur_token = g_scanner_get_next_token(m_scanner); switch (cur_token) { case G_TOKEN_EOF: err("Processing parse rdr entry: File ends too early"); success = false; break; case G_TOKEN_RIGHT_CURLY: m_depth--; break; case G_TOKEN_LEFT_CURLY: m_depth++; break; case G_TOKEN_STRING: field = g_strdup(m_scanner->value.v_string); cur_token = g_scanner_get_next_token(m_scanner); if (cur_token != G_TOKEN_EQUAL_SIGN) { err("Processing parse rdr entry: Missing equal sign"); success = false; } cur_token = g_scanner_get_next_token(m_scanner); if (!strcmp(field, "SpecInfoType")) { if (cur_token == G_TOKEN_INT) fumiSpec.SpecInfoType = ( SaHpiFumiSpecInfoTypeT ) m_scanner->value.v_int; } else if (!strcmp(field, "SafDefined")) { if (cur_token != G_TOKEN_LEFT_CURLY) { err("Missing Left Curly for fumi SafDefined entry" ); success = false; } else { if ( fumiSpecType != SAHPI_FUMI_SPEC_INFO_NONE ) { err("Too many fumi spec info fields include inside FUMI_DATA."); success = false; } else if ( fumiSpec.SpecInfoType != SAHPI_FUMI_SPEC_INFO_SAF_DEFINED ) { err("SpecInfoType doesn't fit to SafDefined inside FUMI_DATA."); success = false; } fumiSpecType = SAHPI_FUMI_SPEC_INFO_SAF_DEFINED; m_depth++; } } else if (!strcmp(field, "OemDefined")) { if (cur_token != G_TOKEN_LEFT_CURLY) { err("Missing Left Curly for fumi OemDefined entry" ); success = false; } else { if ( fumiSpecType != SAHPI_FUMI_SPEC_INFO_NONE ) { err("Too many fumi spec info fields include inside FUMI_DATA."); success = false; } else if ( fumiSpec.SpecInfoType != SAHPI_FUMI_SPEC_INFO_OEM_DEFINED ) { err("SpecInfoType doesn't fit to OemDefined inside FUMI_DATA."); success = false; } fumiSpecType = SAHPI_FUMI_SPEC_INFO_OEM_DEFINED; m_depth++; } } else if (!strcmp(field, "SpecID")) { if (cur_token == G_TOKEN_INT) fumiSpec.SpecInfoTypeUnion.SafDefined.SpecID = ( SaHpiFumiSafDefinedSpecIdT ) m_scanner->value.v_int; } else if (!strcmp(field, "RevisionID")) { if (cur_token == G_TOKEN_INT) fumiSpec.SpecInfoTypeUnion.SafDefined.RevisionID = m_scanner->value.v_int; } else if (!strcmp(field, "Mid")) { if (cur_token == G_TOKEN_INT) fumiSpec.SpecInfoTypeUnion.OemDefined.Mid = m_scanner->value.v_int; } else if (!strcmp(field, "BodyLength")) { if (cur_token == G_TOKEN_INT) fumiSpec.SpecInfoTypeUnion.OemDefined.BodyLength = m_scanner->value.v_int; } else if (!strcmp(field, "Body")) { if (cur_token == G_TOKEN_STRING) success = process_hexstring(fumiSpec.SpecInfoTypeUnion.OemDefined.BodyLength, g_strdup(m_scanner->value.v_string), &(fumiSpec.SpecInfoTypeUnion.OemDefined.Body[0])); } else if (!strcmp(field, "AutoRollbackDisable")) { if (cur_token == G_TOKEN_INT) rollbDisabled = ( SaHpiBoolT ) m_scanner->value.v_int; } else if (!strcmp(field, "NumEntities")) { if (cur_token == G_TOKEN_INT) fumiImpact.NumEntities = m_scanner->value.v_int; if ( fumiImpact.NumEntities > SAHPI_FUMI_MAX_ENTITIES_IMPACTED ) { err("Too many entities are defined for ImpactedEntities"); success = false; } } else if (!strcmp(field, "ImpactedEntities")) { if (cur_token != G_TOKEN_LEFT_CURLY) { err("Missing Left Curly for fumi ImpactedEntities entry" ); success = false; } else { m_depth++; if ( entCounter > fumiImpact.NumEntities - 1 ) { err("Too many entries for ImpactedEntities are defined"); success = false; } } } else if (!strcmp(field, "ImpactedEntity")) { if (cur_token == G_TOKEN_LEFT_CURLY) success = process_entity( fumiImpact.ImpactedEntities[entCounter].ImpactedEntity ); if ( !success ) err("Error at parsing the entity path"); if ( impactFlag ) { entCounter++; impactFlag = false; } else { impactFlag = true; } } else if (!strcmp(field, "ServiceImpact")) { if (cur_token == G_TOKEN_INT) fumiImpact.ImpactedEntities[entCounter].ServiceImpact = ( SaHpiFumiServiceImpactT ) m_scanner->value.v_int; if ( impactFlag ) { entCounter++; impactFlag = false; } else { impactFlag = true; } } else { // Unknown Token err("Processing parse rdr entry: Unknown type field %s", field); success = false; } break; case FUMI_SOURCE_DATA_TOKEN_HANDLER: fbank = new NewSimulatorFumiBank; success = process_fumi_source_info( fbank ); fumi->SetBankSource( fbank ); delete fbank; fbank = NULL; break; case FUMI_TARGET_DATA_TOKEN_HANDLER: fbank = new NewSimulatorFumiBank; success = process_fumi_target_info( fbank ); fumi->SetBankTarget( fbank ); delete fbank; fbank = NULL; break; case FUMI_LOG_TARGET_DATA_TOKEN_HANDLER: fbank = new NewSimulatorFumiBank; success = process_fumi_logical_target_info( fbank ); fumi->SetBankLogical( fbank ); delete fbank; fbank = NULL; break; default: err("Processing Fumi data: Unknown token"); success = false; break; } } fumi->SetInfo( fumiSpec, fumiImpact, rollbDisabled ); return success; }
/*! \brief Adjust movement speed * * This has to adjust for each entity's speed. * 'Normal' speed appears to be 4. * * \param target_entity Index of entity */ static void speed_adjust(t_entity target_entity) { if (g_ent[target_entity].speed < 4) { switch (g_ent[target_entity].speed) { case 1: if (g_ent[target_entity].scount < 3) { g_ent[target_entity].scount++; return; } break; case 2: if (g_ent[target_entity].scount < 2) { g_ent[target_entity].scount++; return; } break; case 3: if (g_ent[target_entity].scount < 1) { g_ent[target_entity].scount++; return; } break; } } if (g_ent[target_entity].speed < 5) { process_entity(target_entity); } switch (g_ent[target_entity].speed) { case 5: process_entity(target_entity); process_entity(target_entity); break; case 6: process_entity(target_entity); process_entity(target_entity); process_entity(target_entity); break; case 7: process_entity(target_entity); process_entity(target_entity); process_entity(target_entity); process_entity(target_entity); break; } /* TT: This is to see if the player is "running" */ if (key[kctrl] && target_entity < PSIZE) { process_entity(target_entity); } }
/** * Read a RDR section * * Startpoint is token \c RDR_TOKEN_HANDLER. Endpoint is \c G_TOKEN_RIGHT_CURLY if * no error occurs during parsing.\n * Depend on wich RDR type is read, some helper functions are called. * * @return success bool * **/ bool NewSimulatorFileRdr::process_rdr_token( void ) { guint cur_token = g_scanner_get_next_token(m_scanner); char *rdrfield; NewSimulatorEntityPath ep; bool success = true; bool commonBlock = true; if (cur_token != G_TOKEN_LEFT_CURLY) { err("Processing parse configuration: Expected left curly token."); return false; } m_depth++; while ( commonBlock && success) { cur_token = g_scanner_get_next_token(m_scanner); switch (cur_token) { case G_TOKEN_EOF: err("Processing parse rpt entry: File ends too early"); success = false; break; case G_TOKEN_RIGHT_CURLY: m_depth--; break; case G_TOKEN_LEFT_CURLY: m_depth++; break; case RDR_DETAIL_TOKEN_HANDLER: commonBlock = false; break; case G_TOKEN_STRING: rdrfield = g_strdup(m_scanner->value.v_string); cur_token = g_scanner_get_next_token(m_scanner); if (cur_token != G_TOKEN_EQUAL_SIGN) { err("Processing parse rdr entry: Missing equal sign"); success = false; } cur_token = g_scanner_get_next_token(m_scanner); if (!strcmp(rdrfield, "RecordId")) { // will be assigned by the daemon -> ignore it stdlog << "DBG: rdr - RecordId is ignored\n"; } else if (!strcmp(rdrfield, "RdrType")) { if (cur_token == G_TOKEN_INT) { m_rdr.RdrType = (SaHpiRdrTypeT) m_scanner->value.v_int; stdlog << "DBG: rdr - RdrType " << m_rdr.RdrType << "\n"; } else { err("Processing parse rpt entry: Wrong kind of RdrType"); } } else if (!strcmp(rdrfield, "Entity")) { if (cur_token == G_TOKEN_LEFT_CURLY) success = process_entity( m_rdr.Entity ); if ( !success ) err("Error at parsing the entity path"); } else if (!strcmp(rdrfield, "IsFru")) { if (cur_token == G_TOKEN_INT) { m_rdr.IsFru = m_scanner->value.v_int; stdlog << "DBG: rdr - IsFru " << m_rdr.IsFru << "\n"; } else { success = false; err("Processing parse rdr entry: Wrong kind of IsFru"); } } else if (!strcmp(rdrfield, "IdString")) { if ( cur_token == G_TOKEN_LEFT_CURLY ) { success = process_textbuffer( m_rdr.IdString ); stdlog << "DBG: IdString " << m_rdr.IdString << "\n"; } else { success = false; err("Processing parse rdr entry: Couldn't parse IdSting"); } } else { // Unknown Token err("Processing parse rdr entry: Unknown Rdr field %s", rdrfield); success = false; } break; default: err("Processing parse rdr entry: Unknown token"); success = false; break; } } return success; }