Forgot to follow the naming convention...
Rename everything like MY_VAR_SOMETHING to MyVarSomething.
Start file
int WaterAdder::OnTimer(Universe u) { const int MY_VAR_TYPE_ID = Universe::TYPE_ID_PLANETARY_SYSTEM; Universe::Object MY_VAR_SUN_TEMPLATE; this->InitializeTheSun(MY_VAR_SUN_TEMPLATE); // auto & MY_VAR_BRIGHT_STAR = ptheir_->StarClass("G2V"); // Fails after some time passes in u: // Assert(Universe::IsElement(MY_VAR_SUN_TEMPLATE, MY_VAR_BRIGHT_STAR)); // Just to doublecheck. Assert(MY_VARIANT(ptheir_->OTHER_GUYS_VAR).IsEqual(MY_VAR_SUN_TEMPLATE)); // TODO: initialize MY_VAR_EARTH_TEMPLATE Universe::TYPE_ID_INFO<MY_VAR_TYPE_ID>::Type MY_VAR_SOLAR_SYSTEM_TEMPLATE(); MY_VAR_SOLAR_SYSTEM_TEMPLATE.Add({MY_VAR_SUN_TEMPLATE, ptheir_->THEIR_VAR_MERCURY, ptheir_->THEIR_VAR_VENUS, MY_VAR_EARTH_TEMPLATE}); Universe::TYPE_ID_INFO<MY_VAR_TYPE_ID>::Type *MY_VAR_SOLAR_SYSTEM = u.SearchByTemplate<MY_VAR_TYPE_ID>(MY_VAR_SOLAR_SYSTEM_TEMPLATE); Assert(MY_VARIABLE_CHECK(MY_VAR_SOLAR_SYSTEM)); auto & MY_VAR_SUN = MY_VAR_SOLAR_SYSTEM->GetStar(0); auto MY_VAR_MASS = MY_VAR_SUN.GetMass(); auto MY_VAR_DIST = Universe::Quantity::Meters(MY_VAR_MASS.InKg() * 1e-20); Universe::Quantity::VELOCITY_T::Type v; Assert(GeneralRelativity::GetOrbitalVelocity(u, MY_VAR_MASS, MY_VAR_DIST, &v)); auto MY_VAR_VELOCITY = vector4<Universe::Quantity::TYPE_SPEED::Type>::From3( GeneralRelativity::c, rnd.UnitVector3() * v); vector3 MY_VAR_POSITION = GeneralRelativity::RegularizedShift(u, MY_VAR_SUN.GetPos(), rnd.UnitVector3(), MY_VAR_DIST); auto MY_VAR_WATER_MASS = std::max( MY_VAR_MASS * 4e-17, Universe::Quantity::Kg(63311*1.0e9)); // Let the fun begin. WaterAdder::AddWater(u, MY_VAR_WATER_MASS, MY_VAR_POSITION, MY_VAR_VELOCITY); WaterAdder::SetTimer(Universe::Quantity::Second()); } // TODO: Don't use long variable names like // MY_VAR_SOLAR_SYSTEM_TEMPLATE_CHECKER_FOR_WATER_ADDER
End file
int WaterAdder::OnTimer(Universe u) { const int MyVarTypeId = Universe::TYPE_ID_PLANETARY_SYSTEM; Universe::Object MyVarSunTemplate; this->InitializeTheSun(MyVarSunTemplate); // auto & MyVarBrightStar = ptheir_->StarClass("G2V"); // Fails after some time passes in u: // Assert(Universe::IsElement(MyVarSunTemplate, MyVarBrightStar)); // Just to doublecheck. Assert(MY_VARIANT(ptheir_->OTHER_GUYS_VAR).IsEqual(MyVarSunTemplate)); // TODO: initialize MyVarEarthTemplate Universe::TYPE_ID_INFO<MyVarTypeId>::Type MyVarSolarSystemTemplate(); MyVarSolarSystemTemplate.Add({MyVarSunTemplate, ptheir_->THEIR_VAR_MERCURY, ptheir_->THEIR_VAR_VENUS, MyVarEarthTemplate}); Universe::TYPE_ID_INFO<MyVarTypeId>::Type *MyVarSolarSystem = u.SearchByTemplate<MyVarTypeId>(MyVarSolarSystemTemplate); Assert(MY_VARIABLE_CHECK(MyVarSolarSystem)); auto & MyVarSun = MyVarSolarSystem->GetStar(0); auto MyVarMass = MyVarSun.GetMass(); auto MyVarDist = Universe::Quantity::Meters(MyVarMass.InKg() * 1e-20); Universe::Quantity::VELOCITY_T::Type v; Assert(GeneralRelativity::GetOrbitalVelocity(u, MyVarMass, MyVarDist, &v)); auto MyVarVelocity = vector4<Universe::Quantity::TYPE_SPEED::Type>::From3( GeneralRelativity::c, rnd.UnitVector3() * v); vector3 MyVarPosition = GeneralRelativity::RegularizedShift(u, MyVarSun.GetPos(), rnd.UnitVector3(), MyVarDist); auto MyVarWaterMass = std::max( MyVarMass * 4e-17, Universe::Quantity::Kg(63311*1.0e9)); // Let the fun begin. WaterAdder::AddWater(u, MyVarWaterMass, MyVarPosition, MyVarVelocity); WaterAdder::SetTimer(Universe::Quantity::Second()); } // TODO: Don't use long variable names like // MyVarSolarSystemTemplateCheckerForWaterAdder
View Diff
3,5c3,5 < const int MY_VAR_TYPE_ID = Universe::TYPE_ID_PLANETARY_SYSTEM; < Universe::Object MY_VAR_SUN_TEMPLATE; < this->InitializeTheSun(MY_VAR_SUN_TEMPLATE); --- > const int MyVarTypeId = Universe::TYPE_ID_PLANETARY_SYSTEM; > Universe::Object MyVarSunTemplate; > this->InitializeTheSun(MyVarSunTemplate); 7c7 < // auto & MY_VAR_BRIGHT_STAR = ptheir_->StarClass("G2V"); --- > // auto & MyVarBrightStar = ptheir_->StarClass("G2V"); 9c9 < // Assert(Universe::IsElement(MY_VAR_SUN_TEMPLATE, MY_VAR_BRIGHT_STAR)); --- > // Assert(Universe::IsElement(MyVarSunTemplate, MyVarBrightStar)); 12c12 < Assert(MY_VARIANT(ptheir_->OTHER_GUYS_VAR).IsEqual(MY_VAR_SUN_TEMPLATE)); --- > Assert(MY_VARIANT(ptheir_->OTHER_GUYS_VAR).IsEqual(MyVarSunTemplate)); 14c14 < // TODO: initialize MY_VAR_EARTH_TEMPLATE --- > // TODO: initialize MyVarEarthTemplate 16,17c16,17 < Universe::TYPE_ID_INFO<MY_VAR_TYPE_ID>::Type MY_VAR_SOLAR_SYSTEM_TEMPLATE(); < MY_VAR_SOLAR_SYSTEM_TEMPLATE.Add({MY_VAR_SUN_TEMPLATE, --- > Universe::TYPE_ID_INFO<MyVarTypeId>::Type MyVarSolarSystemTemplate(); > MyVarSolarSystemTemplate.Add({MyVarSunTemplate, 19c19 < MY_VAR_EARTH_TEMPLATE}); --- > MyVarEarthTemplate}); 21,23c21,23 < Universe::TYPE_ID_INFO<MY_VAR_TYPE_ID>::Type *MY_VAR_SOLAR_SYSTEM = < u.SearchByTemplate<MY_VAR_TYPE_ID>(MY_VAR_SOLAR_SYSTEM_TEMPLATE); < Assert(MY_VARIABLE_CHECK(MY_VAR_SOLAR_SYSTEM)); --- > Universe::TYPE_ID_INFO<MyVarTypeId>::Type *MyVarSolarSystem = > u.SearchByTemplate<MyVarTypeId>(MyVarSolarSystemTemplate); > Assert(MY_VARIABLE_CHECK(MyVarSolarSystem)); 25,27c25,27 < auto & MY_VAR_SUN = MY_VAR_SOLAR_SYSTEM->GetStar(0); < auto MY_VAR_MASS = MY_VAR_SUN.GetMass(); < auto MY_VAR_DIST = Universe::Quantity::Meters(MY_VAR_MASS.InKg() * 1e-20); --- > auto & MyVarSun = MyVarSolarSystem->GetStar(0); > auto MyVarMass = MyVarSun.GetMass(); > auto MyVarDist = Universe::Quantity::Meters(MyVarMass.InKg() * 1e-20); 29,31c29,31 < Assert(GeneralRelativity::GetOrbitalVelocity(u, MY_VAR_MASS, < MY_VAR_DIST, &v)); < auto MY_VAR_VELOCITY = vector4<Universe::Quantity::TYPE_SPEED::Type>::From3( --- > Assert(GeneralRelativity::GetOrbitalVelocity(u, MyVarMass, > MyVarDist, &v)); > auto MyVarVelocity = vector4<Universe::Quantity::TYPE_SPEED::Type>::From3( 33,35c33,35 < vector3 MY_VAR_POSITION = GeneralRelativity::RegularizedShift(u, < MY_VAR_SUN.GetPos(), rnd.UnitVector3(), MY_VAR_DIST); < auto MY_VAR_WATER_MASS = std::max( MY_VAR_MASS * 4e-17, --- > vector3 MyVarPosition = GeneralRelativity::RegularizedShift(u, > MyVarSun.GetPos(), rnd.UnitVector3(), MyVarDist); > auto MyVarWaterMass = std::max( MyVarMass * 4e-17, 39c39 < WaterAdder::AddWater(u, MY_VAR_WATER_MASS, MY_VAR_POSITION, MY_VAR_VELOCITY); --- > WaterAdder::AddWater(u, MyVarWaterMass, MyVarPosition, MyVarVelocity); 44c44 < // MY_VAR_SOLAR_SYSTEM_TEMPLATE_CHECKER_FOR_WATER_ADDER --- > // MyVarSolarSystemTemplateCheckerForWaterAdder
Solutions by @zulolosi:
Unlock 2 remaining solutions by signing in and submitting your own entry