I think you can simply use a_Chunk->GetBlock(itr->x, itr->y, itr->z) and remove the idb var. The code uses idx only because the index is reused later for GetMeta() and SetMeta()

Also, this code will crash when the fire is in Y == 0. You should move the GetBlock() down to where the value is actually used and add a condition for the Y coord.