@ -41,7 +41,7 @@ pub fn send_quest_category_list(id: ClientId, rql: &RequestQuestList, client_loc
let room = rooms . get_mut ( room_id . 0 )
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? . as_mut ( )
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? ;
let qcl = quest ::quest_category_list ( & room . quests [ rql . flag as usize ] ) ;
let qcl = quest ::quest_category_list ( & room . quests [ rql . flag . clamp ( 0 , ( room . quests . len ( ) - 1 ) as u32 ) as usize ] ) ;
room . set_quest_group ( rql . flag as usize ) ;
Ok ( Box ::new ( vec ! [ ( id , SendShipPacket ::QuestCategoryList ( qcl ) ) ] . into_iter ( ) ) )
}
@ -51,7 +51,7 @@ pub fn select_quest_category(id: ClientId, menuselect: &MenuSelect, client_locat
let room = rooms . get_mut ( room_id . 0 )
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? . as_mut ( )
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? ;
let ( _ , category_quests ) = room . quests [ room . quest_group ] . iter ( ) // TODO: error handling for invalid quest group
let ( _ , category_quests ) = room . quests [ room . quest_group . value ( ) ] . iter ( )
. nth ( menuselect . item as usize )
. ok_or ( ShipError ::InvalidQuestCategory ( menuselect . item ) ) ? ;
@ -68,7 +68,7 @@ pub fn quest_detail(id: ClientId, questdetailrequest: &QuestDetailRequest, clien
let room = rooms . get_mut ( room_id . 0 )
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? . as_mut ( )
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? ;
let ( _ , category_quests ) = room . quests [ room . quest_group ] . iter ( )
let ( _ , category_quests ) = room . quests [ room . quest_group . value ( ) ] . iter ( )
. nth ( questdetailrequest . category as usize )
. ok_or ( ShipError ::InvalidQuestCategory ( questdetailrequest . category as u32 ) ) ? ;
@ -88,7 +88,7 @@ pub fn player_chose_quest(id: ClientId, questmenuselect: &QuestMenuSelect, clien
let room = rooms . get_mut ( room_id . 0 )
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? . as_mut ( )
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? ;
let ( _ , category_quests ) = room . quests [ room . quest_group ] . iter ( )
let ( _ , category_quests ) = room . quests [ room . quest_group . value ( ) ] . iter ( )
. nth ( questmenuselect . category as usize )
. ok_or ( ShipError ::InvalidQuestCategory ( questmenuselect . category as u32 ) ) ? ;
@ -121,7 +121,7 @@ pub fn quest_file_request(id: ClientId, quest_file_request: &QuestFileRequest, c
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? ;
let ( category_id , quest_id , datatype ) = parse_filename ( & quest_file_request . filename ) ? ;
let ( _ , category_quests ) = room . quests [ room . quest_group ] . iter ( )
let ( _ , category_quests ) = room . quests [ room . quest_group . value ( ) ] . iter ( )
. nth ( category_id as usize )
. ok_or ( ShipError ::InvalidQuestCategory ( category_id as u32 ) ) ? ;
@ -150,7 +150,7 @@ pub fn quest_chunk_ack(id: ClientId, quest_chunk_ack: &QuestChunkAck, client_loc
. ok_or ( ShipError ::InvalidRoom ( room_id . 0 as u32 ) ) ? ;
let ( category_id , quest_id , datatype ) = parse_filename ( & quest_chunk_ack . filename ) ? ;
let ( _ , category_quests ) = room . quests [ room . quest_group ] . iter ( )
let ( _ , category_quests ) = room . quests [ room . quest_group . value ( ) ] . iter ( )
. nth ( category_id as usize )
. ok_or ( ShipError ::InvalidQuestCategory ( category_id as u32 ) ) ? ;