Verbessere Fehlerbehandlung in Transport- und Produktionslogik: Optimiere die Bedingungen für den Transportstart und die Verarbeitung abgeschlossener Produktionen, um die Lesbarkeit zu erhöhen und Fehler effizienter zu handhaben.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m24s
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m24s
This commit is contained in:
@@ -291,9 +291,8 @@ impl DirectorWorker {
|
||||
if director.may_produce {
|
||||
self.start_productions(&director)?;
|
||||
}
|
||||
if director.may_start_transport {
|
||||
if let Err(_) = self.start_transports_stub(&director) {}
|
||||
}
|
||||
if director.may_start_transport
|
||||
&& self.start_transports_stub(&director).is_err() {}
|
||||
if director.may_sell {
|
||||
eprintln!(
|
||||
"[DirectorWorker] Starte Verkaufsprüfung für Director {} (branch_id={})",
|
||||
|
||||
@@ -79,11 +79,10 @@ impl FalukantFamilyWorker {
|
||||
self.base.set_current_step("FalukantFamilyWorker iteration");
|
||||
let now = Instant::now();
|
||||
|
||||
if !self.schema_ready {
|
||||
if let Ok(true) = self.check_schema() {
|
||||
if !self.schema_ready
|
||||
&& let Ok(true) = self.check_schema() {
|
||||
self.schema_ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
if Self::should_run(self.last_certificate_recalc, now, CERTIFICATE_RECALC_INTERVAL) {
|
||||
if let Err(e) = super::falukant_certificate::run_daily(&self.base, &self.base.broker) {
|
||||
@@ -96,11 +95,10 @@ impl FalukantFamilyWorker {
|
||||
if let Err(e) = super::falukant_debtors::run_daily(&self.base, &self.base.broker) {
|
||||
eprintln!("[FalukantFamilyWorker] falukant_debtors::run_daily: {e}");
|
||||
}
|
||||
if self.schema_ready {
|
||||
if let Err(e) = self.process_daily() {
|
||||
if self.schema_ready
|
||||
&& let Err(e) = self.process_daily() {
|
||||
eprintln!("[FalukantFamilyWorker] process_daily: {e}");
|
||||
}
|
||||
}
|
||||
self.last_daily = Some(now);
|
||||
}
|
||||
|
||||
@@ -111,23 +109,20 @@ impl FalukantFamilyWorker {
|
||||
self.last_monthly = Some(now);
|
||||
}
|
||||
|
||||
if self.servants_schema_ready || self.lover_installment_schema_ready {
|
||||
if Self::should_run(self.last_game_month_slice, now, GAME_MONTH_SLICE_INTERVAL) {
|
||||
if self.servants_schema_ready {
|
||||
if let Err(e) =
|
||||
if (self.servants_schema_ready || self.lover_installment_schema_ready)
|
||||
&& Self::should_run(self.last_game_month_slice, now, GAME_MONTH_SLICE_INTERVAL) {
|
||||
if self.servants_schema_ready
|
||||
&& let Err(e) =
|
||||
super::falukant_servants::run_monthly(&self.base, &self.base.broker)
|
||||
{
|
||||
eprintln!("[FalukantFamilyWorker] falukant_servants::run_monthly: {e}");
|
||||
}
|
||||
}
|
||||
if self.lover_installment_schema_ready {
|
||||
if let Err(e) = self.process_lover_installments() {
|
||||
if self.lover_installment_schema_ready
|
||||
&& let Err(e) = self.process_lover_installments() {
|
||||
eprintln!("[FalukantFamilyWorker] process_lover_installments: {e}");
|
||||
}
|
||||
}
|
||||
self.last_game_month_slice = Some(now);
|
||||
}
|
||||
}
|
||||
|
||||
std::thread::sleep(Duration::from_secs(1));
|
||||
if !state.running_worker.load(Ordering::Relaxed) {
|
||||
@@ -650,7 +645,7 @@ impl FalukantFamilyWorker {
|
||||
}
|
||||
p = p.clamp(0.0, 25.0);
|
||||
if self.dist.sample(&mut self.rng) * 100.0 < p {
|
||||
let _ = self.base.broker.publish(format!(
|
||||
self.base.broker.publish(format!(
|
||||
r#"{{"event":"falukant_family_scandal_hint","relationship_id":{}}}"#,
|
||||
l.rel_id
|
||||
));
|
||||
@@ -852,13 +847,11 @@ impl FalukantFamilyWorker {
|
||||
let mut free_slots_by_char: HashMap<i32, i32> = HashMap::new();
|
||||
let mut seen_payer: HashSet<i32> = HashSet::new();
|
||||
for it in &items {
|
||||
if let Some(cid) = it.payer_cid {
|
||||
if seen_payer.insert(cid) {
|
||||
if let Ok(n) = super::political_benefits::sum_free_lover_slots(&mut conn, cid) {
|
||||
if let Some(cid) = it.payer_cid
|
||||
&& seen_payer.insert(cid)
|
||||
&& let Ok(n) = super::political_benefits::sum_free_lover_slots(&mut conn, cid) {
|
||||
free_slots_by_char.insert(cid, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut cur_group = -2i32;
|
||||
|
||||
@@ -118,10 +118,7 @@ impl ProduceWorker {
|
||||
self.base
|
||||
.set_current_step("Fetch Finished Productions");
|
||||
|
||||
let finished_productions = match self.get_finished_productions() {
|
||||
Ok(rows) => rows,
|
||||
Err(_) => Vec::new(),
|
||||
};
|
||||
let finished_productions = self.get_finished_productions().unwrap_or_default();
|
||||
|
||||
self.base
|
||||
.set_current_step("Process Finished Productions");
|
||||
@@ -169,10 +166,7 @@ impl ProduceWorker {
|
||||
user_id: i32,
|
||||
) -> bool {
|
||||
let mut remaining_quantity = quantity;
|
||||
let stocks = match self.get_available_stocks(branch_id) {
|
||||
Ok(rows) => rows,
|
||||
Err(_) => Vec::new(),
|
||||
};
|
||||
let stocks = self.get_available_stocks(branch_id).unwrap_or_default();
|
||||
|
||||
for stock in stocks {
|
||||
if remaining_quantity <= 0 {
|
||||
@@ -216,7 +210,7 @@ impl ProduceWorker {
|
||||
Err(_) => return false,
|
||||
};
|
||||
|
||||
if let Err(_) = conn.prepare("check_branch_capacity", QUERY_GET_BRANCH_CAPACITY) {
|
||||
if conn.prepare("check_branch_capacity", QUERY_GET_BRANCH_CAPACITY).is_err() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ struct HouseConditions {
|
||||
}
|
||||
|
||||
// Query-Konstanten (1:1 aus der C++-Version übernommen)
|
||||
const Q_SELECT_BY_PERFORMER: &str = r#"
|
||||
const Q_SELECT_UNDERGROUND_BY_CHARACTER: &str = r#"
|
||||
SELECT u.id,
|
||||
t.tr AS underground_type,
|
||||
u.performer_id,
|
||||
@@ -316,8 +316,8 @@ impl UndergroundWorker {
|
||||
let mut conn = pool
|
||||
.get()
|
||||
.map_err(|e| DbError::new(format!("DB-Verbindung fehlgeschlagen: {e}")))?;
|
||||
conn.prepare("ug_select_by_performer", Q_SELECT_BY_PERFORMER)?;
|
||||
let rows = conn.execute("ug_select_by_performer", &[&victim_id])?;
|
||||
conn.prepare("ug_select_underground_by_character", Q_SELECT_UNDERGROUND_BY_CHARACTER)?;
|
||||
let rows = conn.execute("ug_select_underground_by_character", &[&victim_id])?;
|
||||
|
||||
let mut activities = Vec::new();
|
||||
for r in rows {
|
||||
|
||||
@@ -541,8 +541,8 @@ impl UserCharacterWorker {
|
||||
"[UserCharacterWorker] falukant_debtors::on_credit_payment_success: {err}"
|
||||
);
|
||||
}
|
||||
} else if prism_started_previously {
|
||||
if let Err(err) = self
|
||||
} else if prism_started_previously
|
||||
&& let Err(err) = self
|
||||
.base
|
||||
.change_falukant_user_money(user_id, pay_rate, "debitor_prism")
|
||||
{
|
||||
@@ -550,7 +550,6 @@ impl UserCharacterWorker {
|
||||
"[UserCharacterWorker] Fehler bei change_falukant_user_money (debitor_prism): {err}"
|
||||
);
|
||||
}
|
||||
}
|
||||
// Verzug / Schuldturm: täglich `falukant_debtors::run_daily` (FalukantFamilyWorker)
|
||||
|
||||
conn.execute("update_credit", &[&remaining_amount, &user_id])?;
|
||||
|
||||
Reference in New Issue
Block a user