Adjust replace_with_new to fit with updates to Lox library
This commit is contained in:
parent
3e3f50c215
commit
6372e894ae
|
@ -90,6 +90,12 @@ impl LoxServerContext {
|
||||||
return_bridges
|
return_bridges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_single_bridge(&self) {
|
||||||
|
let mut extra_bridges = self.extra_bridges.lock().unwrap();
|
||||||
|
let length = extra_bridges.len();
|
||||||
|
_ = extra_bridges.remove(length - 1)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new_unreplaced_bridge(&self, bridge: BridgeLine) {
|
pub fn new_unreplaced_bridge(&self, bridge: BridgeLine) {
|
||||||
let mut unreplaced_bridges = self.unreplaced_bridges.lock().unwrap();
|
let mut unreplaced_bridges = self.unreplaced_bridges.lock().unwrap();
|
||||||
unreplaced_bridges.push(bridge);
|
unreplaced_bridges.push(bridge);
|
||||||
|
@ -115,11 +121,13 @@ impl LoxServerContext {
|
||||||
|
|
||||||
pub fn replace_with_new(&self, bridgeline: BridgeLine) -> bool {
|
pub fn replace_with_new(&self, bridgeline: BridgeLine) -> bool {
|
||||||
let mut ba_obj = self.ba.lock().unwrap();
|
let mut ba_obj = self.ba.lock().unwrap();
|
||||||
let mut db_obj = self.db.lock().unwrap();
|
let eb_obj = self.extra_bridges.lock().unwrap();
|
||||||
let mut eb_obj = self.extra_bridges.lock().unwrap();
|
let available_bridge = eb_obj.last();
|
||||||
let mut available_bridge = eb_obj.last();
|
// .last() doesn't actually remove the object so we still have to do that
|
||||||
|
if eb_obj.len() > 0 {
|
||||||
ba_obj.bridge_replace(&bridgeline, available_bridge, &mut db_obj)
|
self.remove_single_bridge();
|
||||||
|
}
|
||||||
|
ba_obj.bridge_replace(&bridgeline, available_bridge)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_unreachable(&self, bridgeline: BridgeLine) -> bool {
|
pub fn add_unreachable(&self, bridgeline: BridgeLine) -> bool {
|
||||||
|
|
|
@ -142,8 +142,7 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
println!("'Gone' BridgeLine NOT replaced, saved for next update! : {:?}", bridgeline);
|
println!("'Gone' BridgeLine NOT replaced, saved for next update! : {:?}", bridgeline);
|
||||||
context.new_unreplaced_bridge(bridgeline);
|
context.new_unreplaced_bridge(bridgeline);
|
||||||
}
|
}
|
||||||
} else {
|
} else if count < MAX_BRIDGES_PER_BUCKET {
|
||||||
if count < MAX_BRIDGES_PER_BUCKET {
|
|
||||||
bucket[count] = bridgeline;
|
bucket[count] = bridgeline;
|
||||||
count += 1;
|
count += 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -155,7 +154,6 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Handle the extra buckets that were not allocated already
|
// Handle the extra buckets that were not allocated already
|
||||||
if count != 0 {
|
if count != 0 {
|
||||||
for val in 0..count {
|
for val in 0..count {
|
||||||
|
|
Loading…
Reference in New Issue